@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700&display=swap');

:root {
    --itr-blue: #145A8E;
    --itr-blue-dark: #0f4770;
    --itr-orange: #F59C16;
    --itr-turquoise: #5EBDB9;
    --itr-text: #21323c;
    --itr-muted: #6b7b87;
    --itr-bg: #f4f7fa;
    --itr-border: #e1e7ec;
    --itr-white: #ffffff;
    --itr-danger: #c0392b;
    --itr-success: #2f9e44;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Open Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--itr-bg);
    color: var(--itr-text);
    min-height: 100vh;
}

a { color: var(--itr-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    background: var(--itr-white);
    border-bottom: 3px solid var(--itr-blue);
    padding: 0.75rem 1.5rem;
    gap: 2rem;
    box-shadow: 0 1px 3px rgba(20, 90, 142, 0.06);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    color: var(--itr-blue);
    font-size: 1.1rem;
}

.brand img { height: 38px; display: block; }
.brand .tagline {
    border-left: 2px solid var(--itr-turquoise);
    padding-left: 0.75rem;
    font-weight: 400;
    color: var(--itr-muted);
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

.topbar nav {
    display: flex;
    gap: 1.25rem;
    flex: 1;
}

.topbar nav a {
    color: var(--itr-text);
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    transition: background 0.15s ease;
}
.topbar nav a:hover,
.topbar nav a.active {
    background: rgba(94, 189, 185, 0.15);
    color: var(--itr-blue);
    text-decoration: none;
}

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--itr-muted);
    font-size: 0.9rem;
}

.topbar .user-info .role {
    background: var(--itr-orange);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 700;
}

.content {
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

.footer {
    background: var(--itr-blue);
    color: white;
    padding: 0.75rem 1.5rem;
    font-size: 0.8rem;
    text-align: center;
    letter-spacing: 0.03em;
}

/* Typography */
h1, h2, h3 { color: var(--itr-blue); font-weight: 700; }
h1 { font-size: 1.75rem; margin: 0 0 1.25rem; }
h1 .accent { color: var(--itr-orange); }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Cards / Tables */
.card {
    background: var(--itr-white);
    border: 1px solid var(--itr-border);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 2px rgba(20, 90, 142, 0.04);
    margin-bottom: 1.5rem;
}

table.data {
    width: 100%;
    border-collapse: collapse;
}
table.data th, table.data td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--itr-border);
    font-size: 0.9rem;
}
table.data th {
    background: rgba(20, 90, 142, 0.06);
    color: var(--itr-blue);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(94, 189, 185, 0.05); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
    line-height: 1.2;
}

.btn-primary {
    background: var(--itr-blue);
    color: white;
}
.btn-primary:hover { background: var(--itr-blue-dark); color: white; text-decoration: none; }

.btn-accent {
    background: var(--itr-orange);
    color: white;
}
.btn-accent:hover { filter: brightness(0.95); color: white; text-decoration: none; }

.btn-ghost {
    background: transparent;
    color: var(--itr-blue);
    border-color: var(--itr-blue);
}
.btn-ghost:hover { background: rgba(20, 90, 142, 0.08); text-decoration: none; }

.btn-danger {
    background: transparent;
    color: var(--itr-danger);
    border-color: var(--itr-danger);
}
.btn-danger:hover { background: var(--itr-danger); color: white; text-decoration: none; }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

/* Forms */
.form-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}
.form-row label {
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--itr-text);
    font-size: 0.9rem;
}
.form-row input[type=text],
.form-row input[type=email],
.form-row input[type=password],
.form-row input[type=number],
.form-row input[type=file],
.form-row select,
.form-row textarea {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--itr-border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.95rem;
    background: white;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none;
    border-color: var(--itr-turquoise);
    box-shadow: 0 0 0 3px rgba(94, 189, 185, 0.2);
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* Flashes */
.flashes { margin-bottom: 1.5rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border-left: 4px solid;
    font-size: 0.95rem;
}
.flash.success { background: #e4f4e8; color: #1d6a35; border-color: var(--itr-success); }
.flash.danger  { background: #fde7e4; color: #8a2519; border-color: var(--itr-danger); }
.flash.info    { background: #e4f1f7; color: #0f4770; border-color: var(--itr-blue); }

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(135deg, rgba(20,90,142,0.85), rgba(94,189,185,0.75)),
        radial-gradient(circle at 20% 20%, rgba(245,156,22,0.25), transparent 40%);
    padding: 2rem;
}
.login-card {
    background: white;
    border-radius: 10px;
    padding: 2rem 2.25rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 15px 40px rgba(15, 71, 112, 0.25);
}
.login-card .brand {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}
.login-card .brand img { height: 44px; }
.login-card .brand .tagline {
    border-left: none;
    padding-left: 0;
    margin-top: 0.25rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-uploaded  { background: #dfe9ef; color: #395261; }
.badge-analyzing { background: rgba(245,156,22,0.18); color: #8a5607; }
.badge-done      { background: rgba(94,189,185,0.25); color: #195955; }
.badge-failed    { background: rgba(192,57,43,0.15); color: #8a2519; }

.badge-admin     { background: var(--itr-orange); color: white; }
.badge-user      { background: rgba(20,90,142,0.12); color: var(--itr-blue); }

/* JSON / pre */
pre.code {
    background: #0f1e28;
    color: #e6f1f7;
    padding: 1rem;
    border-radius: 6px;
    max-height: 500px;
    overflow: auto;
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.meta-grid .meta {
    background: var(--itr-bg);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border-left: 3px solid var(--itr-turquoise);
}
.meta-grid .meta .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--itr-muted);
    letter-spacing: 0.06em;
    font-weight: 600;
}
.meta-grid .meta .value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--itr-text);
    margin-top: 2px;
}

.empty-state {
    text-align: center;
    color: var(--itr-muted);
    padding: 2rem;
}
.empty-state svg { opacity: 0.6; margin-bottom: 1rem; }

.inline-form { display: inline; }
