:root {
    --app-bg: #f4f6f9;
    --surface: #ffffff;
    --border: #dfe5ec;
    --text: #253241;
    --muted: #718096;
    --sidebar: #2f4050;
    --sidebar-deep: #243342;
    --accent: #1877c9;
    --accent-dark: #125d9e;
    --danger: #b84242;
    --success: #217a4b;
    --warning: #966b08;
}

html,
body { min-height: 100%; }

body {
    background: var(--app-bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.5;
}

.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.app-shell-public { display: block; }
.app-main { min-width: 0; }

.app-sidebar {
    background: var(--sidebar);
    color: #d8e2eb;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.brand-panel { background: var(--sidebar-deep); padding: 20px 22px 17px; }
.brand { color: #fff; display: block; font-size: 19px; font-weight: 700; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-caption { color: #aebdca; display: block; font-size: 12px; margin-top: 3px; }

.sidebar-user { border-bottom: 1px solid rgba(255, 255, 255, .1); padding: 17px 22px; }
.sidebar-user strong { color: #fff; display: block; font-size: 14px; }
.sidebar-user span { color: #aebdca; display: block; font-size: 12px; margin-top: 2px; }

.sidebar-nav { margin: 15px 0; }
.sidebar-nav a,
.sidebar-nav .nav-action {
    background: transparent;
    border: 0;
    color: #d8e2eb;
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin: 1px 10px;
    padding: 10px 12px;
    text-align: left;
    text-decoration: none;
    width: calc(100% - 20px);
}
.sidebar-nav a:hover,
.sidebar-nav .nav-action:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.sidebar-nav-footer { border-top: 1px solid rgba(255, 255, 255, .1); margin-top: auto; padding-top: 12px; }

.app-topbar {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    display: flex;
    font-size: 13px;
    font-weight: 600;
    height: 57px;
    padding: 0 28px;
}

.workspace { margin: 0 auto; max-width: 1440px; padding: 27px 30px 36px; }
.page-title { align-items: flex-start; display: flex; gap: 16px; justify-content: space-between; margin-bottom: 20px; }
.page-title h1 { color: #27384a; font-size: 24px; font-weight: 600; letter-spacing: 0; line-height: 1.25; margin: 0; }
.page-subtitle { color: var(--muted); font-size: 14px; margin: 5px 0 0; }
.muted { color: var(--muted); font-size: 13px; }

.button,
button,
input[type='button'],
input[type='reset'],
input[type='submit'] {
    background: var(--accent);
    border-color: var(--accent);
    border-radius: 3px;
    font-size: 12px;
    height: 36px;
    letter-spacing: 0;
    line-height: 34px;
    padding: 0 15px;
    text-transform: none;
}
.button:focus, .button:hover, button:focus, button:hover, input[type='submit']:focus, input[type='submit']:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.button-outline { border-color: #bac6d2; color: #4b6175; }
.button.button-outline:hover { background: #eef3f7; border-color: #9eafbf; color: #33495e; }
.button-small { font-size: 12px; height: 31px; line-height: 29px; padding: 0 10px; }

.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat, .form-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(29, 45, 60, .04);
    padding: 18px;
}
.stat strong { color: #27384a; display: block; font-size: 29px; font-weight: 600; }

.table-responsive, .table-scroll { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; overflow-x: auto; width: 100%; }
table { margin: 0; }
th { background: #f8fafc; color: #607286; font-size: 12px; font-weight: 700; text-transform: uppercase; }
td, th { border-bottom: 1px solid #e8edf2; padding: 13px 15px; vertical-align: middle; }
td:first-child, th:first-child { padding-left: 15px; }
td:last-child, th:last-child { padding-right: 15px; }
tbody tr:last-child td { border-bottom: 0; }

.toolbar { align-items: center; display: flex; flex-wrap: wrap; gap: 9px; margin: 0; }
.toolbar a { font-size: 13px; font-weight: 600; }
.status { border-radius: 3px; display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 7px; }
.status-queued, .status-pending_review, .status-reviewed { background: #e5f2fc; color: #1769a9; }
.status-processing { background: #fff4d6; color: var(--warning); }
.status-completed, .status-approved { background: #e6f5ea; color: var(--success); }
.status-failed, .status-needs_correction { background: #fce8e8; color: var(--danger); }

fieldset { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; margin-bottom: 16px; padding: 18px; }
legend { color: #34495e; font-size: 15px; margin-bottom: 12px; padding: 0 4px; }
label { color: #475b6e; font-size: 13px; margin-bottom: 7px; }
input[type='email'], input[type='number'], input[type='password'], input[type='search'], input[type='tel'], input[type='text'], input[type='url'], input[type='date'], input[type='datetime-local'], textarea, select { background: #fff; border-color: #cbd5df; border-radius: 3px; font-size: 14px; }
input[type='email']:focus, input[type='number']:focus, input[type='password']:focus, input[type='search']:focus, input[type='tel']:focus, input[type='text']:focus, input[type='url']:focus, input[type='date']:focus, input[type='datetime-local']:focus, textarea:focus, select:focus { border-color: var(--accent); }
.form-panel { max-width: 620px; }

.image-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.detail-table th { width: 220px; }
.ecg-preview, .montage-preview { background: #fff; border: 1px solid var(--border); border-radius: 4px; max-height: 520px; max-width: 100%; object-fit: contain; }
.report-textarea { font-family: Consolas, Monaco, monospace; min-height: 360px; }
.draft-report { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 3px; max-height: 440px; overflow: auto; padding: 14px; white-space: pre-wrap; }
.filter-bar { align-items: end; display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.filter-bar .input { margin-bottom: 0; min-width: 220px; }
.validation-table textarea { min-height: 54px; }
.validation-heading { align-items: center; display: flex; gap: 14px; justify-content: space-between; margin: -5px 0 12px; }
.validation-heading span { color: var(--muted); font-size: 13px; }
.validation-heading .button { flex: 0 0 auto; margin: 0; }
.validation-check { align-items: center; cursor: pointer; display: inline-flex; font-size: 13px; gap: 8px; margin: 0; white-space: nowrap; }
.validation-check input { height: 18px; margin: 0; width: 18px; }
.validation-row td { transition: background-color .15s ease; }
.validation-row.is-confirmed td { background: #f3faf6; }
.validation-row textarea:disabled { background: #f1f4f6; color: #8794a2; cursor: not-allowed; }
.error-list { background: #fce8e8; border: 1px solid #efbbbb; border-radius: 4px; color: #8e3030; padding: 12px 18px; }
.lock-notice { background: #fff5d8; border: 1px solid #ead18a; border-radius: 4px; color: #76570b; margin-bottom: 18px; padding: 12px; }
.paginator { color: var(--muted); font-size: 13px; margin-top: 18px; }
.pagination li { display: inline-block; margin-right: 4px; }
.pagination a, .pagination span { border: 1px solid var(--border); border-radius: 3px; display: inline-block; padding: 5px 9px; }

@media (max-width: 760px) {
    .app-shell { display: block; }
    .app-sidebar { min-height: auto; }
    .brand-panel { padding: 15px 18px; }
    .sidebar-user { display: none; }
    .sidebar-nav { display: flex; flex-wrap: wrap; margin: 8px; }
    .sidebar-nav a, .sidebar-nav .nav-action { margin: 0; padding: 8px 10px; width: auto; }
    .sidebar-nav-footer { border-top: 0; margin-top: 0; padding-top: 0; }
    .app-topbar { height: 46px; padding: 0 18px; }
    .workspace { padding: 20px 16px 28px; }
    .page-title { flex-direction: column; gap: 12px; }
    .page-title .button { width: 100%; }
    .filter-bar .input { min-width: 100%; width: 100%; }
    .validation-heading { align-items: stretch; flex-direction: column; }
    .validation-heading .button { width: 100%; }
    .table-responsive table, .table-scroll table { display: table; min-width: 720px; }
    .table-responsive thead, .table-scroll thead { display: table-header-group; }
    .table-responsive tbody, .table-scroll tbody { display: table-row-group; }
    .table-responsive tr, .table-scroll tr { display: table-row; }
    .table-responsive td, .table-responsive th, .table-scroll td, .table-scroll th { display: table-cell; }
}
