/* Operyx — clean, modern, minimal. No framework. */
:root {
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --text: #1a2332;
    --text-muted: #6b7688;
    --border: #e4e8ef;
    --border-strong: #cbd3e0;
    --primary: #0b6efd;
    --primary-dark: #0a5ad4;
    --primary-tint: #e8f1ff;
    --success: #1b8a5a;
    --success-tint: #e4f6ed;
    --warn: #b7801d;
    --warn-tint: #fdf4e0;
    --error: #c0392b;
    --error-tint: #fbeae8;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
    --radius: 8px;
    --radius-lg: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
    height: 36px;
    width: auto;
}
.brand {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--primary);
}
.brand-tag {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-link {
    padding: 8px 14px;
    color: var(--text);
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.12s ease;
}
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-link.active { background: var(--primary-tint); color: var(--primary-dark); }
.nav-user {
    color: var(--text-muted);
    font-size: 13px;
    padding: 0 12px;
    border-left: 1px solid var(--border);
    margin-left: 6px;
}
.nav-logout { color: var(--text-muted); }

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
.page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}
.page-head {
    margin-bottom: 24px;
}
.page-head h1 {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
}
.page-head .muted { margin: 0; }
.back-link {
    font-size: 13px;
    color: var(--text-muted);
    display: inline-block;
    margin-bottom: 10px;
}

.muted { color: var(--text-muted); }

/* ============================================================
   FORMS
   ============================================================ */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.field > span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="file"],
.field input[type="date"],
.field select,
.filter-bar input,
.filter-bar select {
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:focus,
.field select:focus,
.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-tint);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg); }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); text-decoration: none; }
.btn-block { display: flex; width: 100%; }

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(180deg, #eef2f7 0%, #dce5f1 100%);
}
.auth-card {
    background: var(--bg-card);
    padding: 40px 36px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
}
.auth-head { text-align: center; margin-bottom: 28px; }
.auth-head .brand { font-size: 28px; display: block; }
.auth-head .brand-tag { font-size: 13px; display: block; margin-top: 4px; }
.auth-foot {
    margin-top: 18px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13.5px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-ok    { background: var(--success-tint); color: var(--success); border-color: #cbe9d7; }
.alert-warn  { background: var(--warn-tint);    color: var(--warn);    border-color: #f0e0b6; }
.alert-error { background: var(--error-tint);   color: var(--error);   border-color: #f2c8c2; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.filter-bar label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}
.filter-bar input,
.filter-bar select {
    min-width: 130px;
    padding: 7px 10px;
    font-size: 13.5px;
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.data-table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 11px 14px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfd; }
.data-table .nowrap { white-space: nowrap; }
.data-table .score {
    font-weight: 700;
    color: var(--primary-dark);
    text-align: right;
}
.data-table .why {
    max-width: 420px;
    color: var(--text-muted);
    font-size: 12.5px;
}
.patient-link { font-weight: 500; }

.pill {
    display: inline-block;
    padding: 3px 10px;
    background: var(--primary-tint);
    color: var(--primary-dark);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-card);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}
.empty-state p { margin: 6px 0; }

/* ============================================================
   UPLOAD PAGE
   ============================================================ */
.upload-form {
    max-width: 560px;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.help-block {
    margin-top: 28px;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.help-block h2 { font-size: 15px; margin: 0 0 8px; }
.col-list { padding-left: 20px; font-size: 13px; color: var(--text-muted); }
.col-list li { padding: 2px 0; }
.errors-block {
    margin: 12px 0 16px;
    padding: 12px 14px;
    background: var(--warn-tint);
    border: 1px solid #f0e0b6;
    border-radius: 6px;
    font-size: 13px;
}
.errors-block summary { cursor: pointer; font-weight: 500; }
.errors-block ul { margin: 8px 0 0 18px; padding: 0; }

/* ============================================================
   PATIENT DETAIL
   ============================================================ */
.detail-block {
    margin-top: 28px;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.detail-block h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 14px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.match-list { margin: 0; padding: 0; list-style: none; }
.match-list li {
    padding: 4px 0;
    font-size: 13px;
}
.match-weight {
    display: inline-block;
    min-width: 26px;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 600;
    text-align: center;
    margin-right: 6px;
}
.match-weight.pos { background: var(--success-tint); color: var(--success); }
.match-weight.neg { background: var(--error-tint);   color: var(--error); }
.snippet {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-muted);
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    background: var(--bg);
    border-radius: 3px;
}
.signal-list { list-style: none; margin: 0; padding: 0; }
.signal-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.signal-list li:last-child { border-bottom: none; }
.signal-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
}
.tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}
.signal-body {
    font-family: var(--font);
    white-space: pre-wrap;
    margin: 0;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 720px) {
    .topbar { flex-direction: column; height: auto; padding: 12px; gap: 8px; }
    .topbar-nav { flex-wrap: wrap; }
    .page { padding: 16px 12px 40px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar label { width: 100%; }
    .data-table { font-size: 12.5px; }
    .data-table thead th, .data-table tbody td { padding: 8px 10px; }
}
