:root {
    --petrol: #0d5c63;
    --petrol-dark: #083f45;
    --petrol-soft: #e7f2f2;
    --ink: #172326;
    --muted: #657578;
    --line: #dbe3e3;
    --paper: #ffffff;
    --canvas: #f4f7f7;
    --danger: #a52727;
    --danger-soft: #fff0f0;
    --warning: #8a5a00;
    --warning-soft: #fff7de;
    --success: #276447;
    --success-soft: #e9f6ef;
    --shadow: 0 14px 36px rgba(16, 47, 50, .08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
a { color: var(--petrol); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 254px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 20px; padding: 24px 18px 18px; color: #fff; background: linear-gradient(165deg, var(--petrol-dark), #0d5c63 70%, #0d7379); overflow-y: auto; }
.brand { display: block; color: #fff; text-decoration: none; padding: 4px 8px; }
.brand img { display: block; width: 168px; height: auto; }
.brand span, .auth-brand span { display: block; margin-top: 9px; color: rgba(255,255,255,.74); font-size: .77rem; text-transform: uppercase; letter-spacing: .15em; }
.primary-nav { display: grid; gap: 4px; }
.primary-nav a { color: rgba(255,255,255,.82); text-decoration: none; padding: 9px 12px; border-radius: 9px; font-size: .9rem; font-weight: 650; }
.primary-nav a:hover, .primary-nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.13); }
.nav-section { margin: 12px 12px 3px; color: rgba(255,255,255,.52); font-size: .66rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.nav-section:first-child { margin-top: 0; }
.sidebar-user { margin-top: auto; padding: 16px 10px 4px; border-top: 1px solid rgba(255,255,255,.17); }
.sidebar-user span, .sidebar-user small { display: block; overflow-wrap: anywhere; }
.sidebar-user small { margin: 4px 0 12px; color: rgba(255,255,255,.65); }
.sidebar .link-button { color: #fff; }

.main-content { min-width: 0; width: 100%; max-width: 1500px; padding: 42px clamp(22px, 4vw, 64px) 28px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 26px; }
.page-header h1, .auth-card h1 { margin: 2px 0 0; font-size: clamp(1.85rem, 3vw, 2.7rem); line-height: 1.08; letter-spacing: -.035em; }
.page-subtitle, .muted { color: var(--muted); line-height: 1.55; }
.page-subtitle { margin: 8px 0 0; }
.eyebrow { margin: 0 0 6px; color: var(--petrol); font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { display: flex; flex-direction: column; min-height: 170px; padding: 23px; color: var(--ink); text-decoration: none; background: var(--paper); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease; }
.metric-card:hover { transform: translateY(-2px); border-color: #9bbfc1; }
.metric-label { color: var(--muted); font-size: .86rem; font-weight: 700; }
.metric-card strong { margin: 12px 0 8px; color: var(--petrol); font-size: 2.35rem; line-height: 1; }
.metric-card span:last-child { margin-top: auto; color: var(--muted); font-size: .83rem; line-height: 1.4; }

.hub-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .75fr); gap: 20px; align-items: start; }
.worklist { display: grid; gap: 12px; }
.work-item { display: grid; grid-template-columns: 45px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 15px; color: var(--ink); text-decoration: none; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.work-item:hover { border-color: #9bbfc1; background: #fbfdfd; }
.work-count { display: grid; place-items: center; width: 42px; height: 42px; color: #fff; background: var(--petrol); border-radius: 12px; font-size: 1.1rem; font-weight: 850; }
.work-item strong, .work-item small { display: block; }
.work-item small { margin-top: 3px; color: var(--muted); line-height: 1.35; }
.work-arrow { color: var(--petrol); font-weight: 900; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.quick-card { min-height: 118px; padding: 17px; color: var(--ink); text-decoration: none; background: #f7fafa; border: 1px solid var(--line); border-radius: 12px; }
.quick-card strong, .quick-card span { display: block; }
.quick-card strong { margin-bottom: 7px; color: var(--petrol); font-size: .86rem; line-height: 1.25; }
.quick-card span { color: var(--muted); font-size: .82rem; line-height: 1.4; }

.tab-nav { display: flex; gap: 8px; margin: 0 0 20px; overflow-x: auto; }
.tab-nav a { flex: 0 0 auto; padding: 9px 12px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .82rem; font-weight: 760; }
.tab-nav a[aria-current="page"], .tab-nav a:hover { color: #fff; border-color: var(--petrol); background: var(--petrol); }

.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; }
.filter-grid .filter-actions { display: flex; align-items: end; gap: 8px; grid-column: 1 / -1; }
.filter-summary { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 14px; }
.filter-chip { padding: 5px 9px; color: var(--petrol-dark); background: var(--petrol-soft); border-radius: 999px; font-size: .73rem; font-weight: 750; }

.split-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 15px; }
.stack { display: grid; gap: 13px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; background: currentColor; border-radius: 999px; }
progress.progress { width: 100%; height: 10px; overflow: hidden; appearance: none; border: 0; background: #e4ebeb; border-radius: 999px; }
progress.progress::-webkit-progress-bar { background: #e4ebeb; border-radius: 999px; }
progress.progress::-webkit-progress-value { background: var(--petrol); border-radius: 999px; }
progress.progress::-moz-progress-bar { background: var(--petrol); border-radius: 999px; }
.table--wide { min-width: 1380px; }
.callout { padding: 17px 18px; background: var(--petrol-soft); border-left: 4px solid var(--petrol); border-radius: 0 11px 11px 0; line-height: 1.5; }
.callout--warning { color: #6f4a00; background: var(--warning-soft); border-left-color: #bf850d; }
.callout p { margin: 0; }
.subtle-card { padding: 16px; background: #f7fafa; border: 1px solid var(--line); border-radius: 11px; }
.subtle-card h3 { margin: 0 0 7px; font-size: .98rem; }
.subtle-card p { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.inline-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.inline-form > div { flex: 1; min-width: 200px; }
.danger-link { color: var(--danger); }

.panel { margin-bottom: 20px; padding: clamp(18px, 3vw, 28px); background: var(--paper); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.panel h2 { margin: 0; font-size: 1.23rem; }
.panel-heading, .detail-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 20px; }
.text-link, .back-link, .table-link { font-weight: 750; }
.back-link { text-decoration: none; }

.filter-bar { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; padding: 17px; background: #edf3f3; border: 1px solid var(--line); border-radius: 13px; }
.filter-bar > div { min-width: 190px; flex: 1; }
.filter-bar--wide > div:first-child { flex: 2; min-width: 260px; }
label { display: block; margin-bottom: 6px; color: #304649; font-size: .82rem; font-weight: 750; }
input, select, textarea { width: 100%; padding: 11px 12px; color: var(--ink); background: #fff; border: 1px solid #b9c7c8; border-radius: 8px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--petrol); box-shadow: 0 0 0 3px rgba(13, 92, 99, .13); }
textarea { resize: vertical; line-height: 1.5; }

.button { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 8px; font-weight: 760; text-decoration: none; cursor: pointer; }
.button--primary { color: #fff; background: var(--petrol); }
.button--primary:hover { background: var(--petrol-dark); }
.button--quiet { color: var(--petrol); background: #fff; border-color: #b8c9ca; }
.button--danger { color: #fff; background: var(--danger); }
.button--small { min-height: 34px; padding: 7px 10px; color: var(--petrol); background: #fff; border-color: #a9bfc0; font-size: .8rem; }
.button--wide { width: 100%; }
.link-button { padding: 0; color: var(--petrol); background: transparent; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.result-summary { margin-bottom: 14px; color: var(--muted); font-size: .86rem; font-weight: 650; }
.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: .88rem; }
th { padding: 10px 12px; color: var(--muted); border-bottom: 1px solid var(--line); text-align: left; font-size: .71rem; letter-spacing: .06em; text-transform: uppercase; }
td { padding: 14px 12px; border-bottom: 1px solid #e8eded; vertical-align: top; line-height: 1.42; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.error-text { max-width: 330px; color: var(--danger); }

.badge, .tag { display: inline-flex; align-items: center; border-radius: 999px; font-size: .73rem; font-weight: 800; white-space: nowrap; }
.badge { padding: 5px 9px; }
.tag { margin: 2px 5px 2px 0; padding: 4px 8px; color: var(--petrol-dark); background: var(--petrol-soft); }
.badge--success { color: var(--success); background: var(--success-soft); }
.badge--warning { color: var(--warning); background: var(--warning-soft); }
.badge--danger { color: var(--danger); background: var(--danger-soft); }
.badge--muted { color: #526164; background: #edf0f0; }
.badge--info { color: var(--petrol); background: var(--petrol-soft); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; padding-top: 20px; color: var(--muted); }
.pagination a { font-weight: 750; }
.empty-state { padding: 28px 12px; color: var(--muted); text-align: center; }

.detail-grid, .status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.detail-list { display: grid; gap: 0; margin: 0; }
.detail-list > div { display: grid; grid-template-columns: minmax(120px, .7fr) minmax(0, 1.3fr); gap: 20px; padding: 13px 0; border-bottom: 1px solid #e9eeee; }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-size: .8rem; font-weight: 750; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.detail-list--columns { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.detail-list--columns > div { display: block; border: 0; padding: 0; }
.detail-list--columns dd { margin-top: 5px; }
.preline { white-space: pre-line; }
.danger-zone { margin-top: 20px; padding: 18px 20px; background: var(--danger-soft); border: 1px solid #edb8b8; border-radius: 12px; }
.danger-zone summary { color: var(--danger); font-weight: 800; cursor: pointer; }

.notice { margin: 0 0 18px; padding: 13px 15px; border: 1px solid; border-radius: 9px; line-height: 1.45; }
.notice--success { color: var(--success); background: var(--success-soft); border-color: #bcdcc9; }
.notice--error { color: var(--danger); background: var(--danger-soft); border-color: #edb8b8; }
.notice--warning { color: var(--warning); background: var(--warning-soft); border-color: #edd99b; }
.notice--info { color: var(--petrol-dark); background: var(--petrol-soft); border-color: #bad9da; }

.status-list { display: grid; gap: 10px; margin: 20px 0 0; padding: 0; list-style: none; }
.status-list li { display: flex; justify-content: space-between; gap: 15px; padding: 9px 0; border-bottom: 1px solid #e9eeee; }
.status-ok { color: var(--success); }
.status-missing { color: var(--danger); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 26px; background: radial-gradient(circle at top right, #d9eded, transparent 40%), linear-gradient(145deg, #f5f8f8, #edf3f3); }
.auth-card { width: min(100%, 520px); padding: clamp(25px, 5vw, 42px); background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 65px rgba(9, 52, 56, .15); }
.auth-brand { margin: calc(clamp(25px, 5vw, 42px) * -1) calc(clamp(25px, 5vw, 42px) * -1) 34px; padding: 23px clamp(25px, 5vw, 42px); background: var(--petrol); border-radius: 18px 18px 0 0; }
.auth-brand img { display: block; width: 190px; height: auto; }
.stack-form { display: grid; gap: 10px; margin-top: 22px; }
.stack-form label:not(.check-row) { margin-top: 5px; }
.auth-note { margin: 20px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.5; text-align: center; }
.cancel-form { margin-top: 18px; text-align: center; }
.setup-steps { padding-left: 22px; color: var(--muted); line-height: 1.6; }
.setup-steps li { margin-bottom: 6px; }
.qr-wrap { display: grid; place-items: center; margin: 18px auto; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qr-wrap img { display: block; width: min(100%, 320px); height: auto; }
.manual-secret { padding: 13px; background: #f2f6f6; border-radius: 9px; }
.manual-secret summary { font-weight: 750; cursor: pointer; }
.manual-secret code { display: block; margin-top: 10px; padding: 10px; overflow-wrap: anywhere; background: #fff; border-radius: 6px; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 20px 0; padding: 17px; background: #f2f6f6; border-radius: 10px; }
.recovery-codes code { padding: 7px; background: #fff; border: 1px solid var(--line); border-radius: 5px; text-align: center; }
.check-row { display: flex; align-items: flex-start; gap: 9px; margin: 5px 0; line-height: 1.45; }
.check-row input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px; }
.app-footer { margin-top: 38px; color: #849194; font-size: .75rem; text-align: right; }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hub-grid { grid-template-columns: 1fr; }
    .filter-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
    .detail-grid, .status-grid { grid-template-columns: 1fr; }
    .detail-list--columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 18px; gap: 16px; }
    .brand img { width: 145px; }
    .primary-nav { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; }
    .primary-nav a { flex: 0 0 auto; padding: 9px 11px; font-size: .83rem; }
    .sidebar-user { display: flex; align-items: center; gap: 9px; margin-top: 0; padding: 12px 7px 0; }
    .sidebar-user small { margin: 0; }
    .sidebar-user span { display: none; }
    .sidebar-user form { margin-left: auto; }
    .main-content { padding: 25px 16px 22px; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .metric-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 145px; }
    .filter-bar { align-items: stretch; flex-direction: column; }
    .filter-bar > div { width: 100%; min-width: 0; }
    .filter-bar .button { width: 100%; }
    .filter-grid { grid-template-columns: 1fr; }
    .filter-grid .filter-actions { align-items: stretch; flex-direction: column; }
    .filter-grid .filter-actions .button { width: 100%; }
    .work-item { grid-template-columns: 42px minmax(0, 1fr); }
    .work-arrow { display: none; }
    .quick-grid { grid-template-columns: 1fr; }
    .detail-list > div { grid-template-columns: 1fr; gap: 4px; }
    .detail-list--columns { grid-template-columns: 1fr; }
    .recovery-codes { grid-template-columns: 1fr; }
    .auth-page { padding: 12px; }
    .auth-card { padding: 23px; }
    .auth-brand { margin: -23px -23px 28px; padding: 20px 23px; }
}

@media print {
    .auth-brand, .stack-form, .auth-note, .notice { display: none !important; }
    .auth-page, .auth-card { display: block; min-height: 0; padding: 0; background: #fff; box-shadow: none; border: 0; }
    .recovery-codes { grid-template-columns: repeat(2, 1fr); }
}
