:root {
    --navy: #2b2b2a;
    --navy-2: #5f5f5e;
    --blue: #5f5f5e;
    --blue-soft: #fff9c8;
    --accent: #f1dc20;
    --accent-hover: #dfc90e;
    --green: #16845b;
    --green-soft: #e7f7f0;
    --amber: #b66a08;
    --amber-soft: #fff3df;
    --red: #bd3f4b;
    --red-soft: #fdecee;
    --ink: #292928;
    --muted: #6d6d69;
    --line: #deded8;
    --surface: #ffffff;
    --background: #f5f5f1;
    --shadow: 0 12px 30px rgba(43, 43, 42, .08);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--background); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: #4d4d4b; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }

.topbar { min-height: 88px; padding: 10px max(22px, calc((100vw - 1280px) / 2)); background: white; color: var(--ink); border-bottom: 5px solid var(--accent); display: flex; align-items: center; justify-content: space-between; gap: 24px; position: sticky; top: 0; z-index: 20; box-shadow: 0 8px 25px rgba(43, 43, 42, .12); }
.brand { color: var(--ink); display: flex; align-items: center; }
.brand:hover { text-decoration: none; }
.brand img { display: block; width: 238px; height: auto; }
.nav { display: flex; align-items: center; gap: 6px; }
.nav > a { color: #4d4d4b; padding: 10px 12px; border-radius: 9px; font-weight: 750; font-size: .9rem; }
.nav > a:hover, .nav > a.active { color: var(--ink); background: #fff8ad; text-decoration: none; }
.nav .button-primary { background: var(--accent); color: var(--ink); margin-left: 8px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.1); }
.nav .button-primary:hover { background: var(--accent-hover); color: var(--ink); }
.nav-toggle { display: none; color: var(--ink); border: 1px solid #bababa; background: #f7f7f4; padding: 8px 12px; border-radius: 9px; }
.user-menu { display: flex; align-items: center; gap: 12px; margin-left: 8px; padding-left: 14px; border-left: 1px solid var(--line); }
.user-menu > span { display: grid; line-height: 1.15; }
.user-menu strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; }
.user-menu small { color: var(--muted); font-size: .7rem; margin-top: 3px; }
.user-menu form { margin: 0; }

.container { width: min(1280px, calc(100% - 44px)); margin: 0 auto; padding: 42px 0 64px; min-height: calc(100vh - 140px); }
.page-heading { margin-bottom: 28px; }
.page-heading h1 { font-size: clamp(1.8rem, 3vw, 2.55rem); line-height: 1.1; margin: 5px 0 8px; letter-spacing: -.035em; }
.page-heading p { color: var(--muted); margin: 0; }
.page-heading .eyebrow, .panel .eyebrow { color: #555551; }
.eyebrow { text-transform: uppercase; letter-spacing: .11em; font-size: .72rem; font-weight: 850; margin: 0 0 3px; }
.heading-with-actions { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.live-indicator { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: .84rem; font-weight: 800; padding: 8px 12px; background: var(--green-soft); border-radius: 99px; }
.live-indicator span, .status-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: #24ab78; box-shadow: 0 0 0 5px rgba(36,171,120,.13); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 20px; }
.metric-card { min-height: 160px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.metric-card::after { content: ""; position: absolute; width: 86px; height: 86px; border-radius: 50%; right: -32px; top: -34px; background: var(--blue-soft); border: 1px solid rgba(241,220,32,.35); }
.metric-card > span { color: var(--muted); font-weight: 750; font-size: .84rem; }
.metric-card strong { display: block; margin: 12px 0 2px; font-size: 2.45rem; letter-spacing: -.05em; line-height: 1; }
.metric-card strong em { font-size: .9rem; color: var(--muted); font-style: normal; letter-spacing: 0; }
.metric-card small { color: var(--muted); }
.metric-open::after { background: var(--amber-soft); }
.metric-open strong { color: var(--amber); }
.metric-complete::after { background: var(--green-soft); }
.metric-complete strong { color: var(--green); }
.metric-time::after { background: #eeeeea; border-color: #d8d8d1; }

.dashboard-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; margin-bottom: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.panel-header h2, .panel h2 { margin: 0; font-size: 1.12rem; letter-spacing: -.015em; }
.panel-header p { color: var(--muted); margin: 3px 0 0; font-size: .85rem; }
.panel-header > a { font-size: .85rem; font-weight: 800; }

.active-list { display: grid; gap: 9px; }
.active-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); transition: border-color .2s, transform .2s; }
.active-item:hover { border-color: #b6aa3d; transform: translateY(-1px); text-decoration: none; }
div.active-item:hover { transform: none; border-color: var(--line); }
.active-copy { min-width: 0; }
.active-copy strong, .active-copy span { display: block; }
.active-copy span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: .82rem; }
.elapsed { white-space: nowrap; color: var(--amber); font-size: .82rem; font-weight: 850; }
.empty-state { min-height: 120px; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 4px; }
.empty-state strong { color: var(--ink); }

.bar-chart { display: grid; gap: 16px; }
.bar-row { display: grid; grid-template-columns: 100px 1fr 30px; align-items: center; gap: 12px; font-size: .82rem; }
.bar-row > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.bar-track { height: 10px; border-radius: 10px; background: #ededE8; overflow: hidden; }
.bar-track i { display: block; height: 100%; min-width: 5px; border-radius: inherit; background: linear-gradient(90deg, #5f5f5e, #f1dc20); }
.bar-row strong { text-align: right; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 14px 12px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
.description-cell { min-width: 230px; max-width: 420px; }
.table-action, .link-button { font-weight: 800; font-size: .82rem; white-space: nowrap; }
.link-button { color: #4d4d4b; border: 0; border-bottom: 2px solid var(--accent); background: transparent; padding: 0; cursor: pointer; }
.link-danger { color: var(--red); border-bottom-color: #e9aab1; }
.row-actions { display: flex; align-items: center; gap: 12px; }
.row-actions form { margin: 0; }
.pill { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 99px; font-size: .73rem; font-weight: 850; white-space: nowrap; }
.pill-open { color: var(--amber); background: var(--amber-soft); }
.pill-complete { color: var(--green); background: var(--green-soft); }
.pill-muted { color: var(--muted); background: #edf1f5; }

.filter-panel { display: grid; grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(130px, .7fr)) auto; align-items: end; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; box-shadow: var(--shadow); }
.field { display: grid; gap: 7px; }
.field > span { font-size: .78rem; color: #465267; font-weight: 800; }
.field small { color: var(--muted); font-size: .75rem; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #cfd7e2; background: white; color: var(--ink); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .2s, box-shadow .2s; }
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #8d8123; box-shadow: 0 0 0 3px rgba(241,220,32,.28); }
.filter-actions { display: flex; align-items: center; gap: 12px; padding-bottom: 1px; white-space: nowrap; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; padding-top: 20px; border-top: 1px solid var(--line); margin-top: 12px; font-size: .85rem; }

.button { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 850; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .15s, background .15s; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button-primary { background: var(--accent); color: var(--ink); box-shadow: inset 0 -2px 0 rgba(0,0,0,.1); }
.button-primary:hover { background: var(--accent-hover); color: var(--ink); }
.button-secondary { background: #e7e7e1; color: var(--ink); }
.button-success { background: var(--green); color: white; }
.button-danger { background: var(--red-soft); color: var(--red); }
.button-block { width: 100%; }

.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 20px; align-items: start; }
.form-panel { padding: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field-full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 20px; padding-top: 24px; margin-top: 24px; border-top: 1px solid var(--line); }
.side-stack { display: grid; gap: 18px; }
.incident-status-card { text-align: center; }
.incident-status-card > strong { display: block; font-size: 2.2rem; margin-top: 16px; line-height: 1; }
.incident-status-card > span:not(.pill) { color: var(--muted); font-size: .83rem; }
.incident-status-card form { margin-top: 22px; }
.help-card p, .danger-zone p { color: var(--muted); font-size: .87rem; }
.danger-zone { border-color: #f0ccd0; }
.catalog-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.compact-form h2 { margin-bottom: 20px; }
.compact-form .button { margin-top: 16px; }
.compact-form form { display: grid; gap: 16px; }
.compact-form form .button { margin-top: 2px; }
.cancel-link { text-align: center; font-size: .85rem; font-weight: 750; }

.login-layout { min-height: calc(100vh - 280px); display: grid; place-items: center; }
.login-panel { width: min(440px, 100%); padding: 34px; }
.login-panel h1 { margin: 5px 0 8px; font-size: 2rem; letter-spacing: -.035em; }
.login-panel > p:not(.eyebrow) { color: var(--muted); margin: 0 0 24px; }
.login-panel form { display: grid; gap: 18px; }
.login-panel .button { margin-top: 4px; }

.alert { margin: -18px 0 24px; padding: 13px 16px; border-radius: 11px; font-weight: 700; }
.alert-success { color: #116b4a; background: var(--green-soft); border: 1px solid #bfe6d6; }
.alert-error { color: #9e303b; background: var(--red-soft); border: 1px solid #f3c8cd; }
.footer { width: min(1280px, calc(100% - 44px)); margin: 0 auto; padding: 20px 0 30px; border-top: 1px solid var(--line); color: var(--muted); display: flex; justify-content: space-between; font-size: .78rem; }
.footer-actions { display: flex; align-items: center; gap: 16px; }
.install-app { border: 0; padding: 0; color: #4d4d4b; background: transparent; border-bottom: 2px solid var(--accent); font-weight: 800; cursor: pointer; }
.install-app[hidden] { display: none; }
.connection-status { position: fixed; left: 50%; bottom: 18px; z-index: 50; width: min(520px, calc(100% - 28px)); transform: translateX(-50%); padding: 12px 16px; border: 1px solid #e1b45c; border-radius: 11px; background: #fff3df; color: #764505; box-shadow: 0 10px 30px rgba(43, 43, 42, .18); text-align: center; font-size: .85rem; font-weight: 750; }
.connection-status[hidden] { display: none; }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .field-search { grid-column: span 2; }
}

@media (max-width: 800px) {
    .topbar { flex-wrap: wrap; }
    .nav-toggle { display: block; }
    .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 8px; }
    .nav.open { display: flex; }
    .nav .button-primary { margin-left: 0; }
    .user-menu { margin: 8px 0 0; padding: 14px 10px 4px; border-left: 0; border-top: 1px solid var(--line); justify-content: space-between; }
    .dashboard-grid, .form-layout, .catalog-layout { grid-template-columns: 1fr; }
    .filter-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .heading-with-actions { align-items: flex-start; }
}

@media (max-width: 560px) {
    .topbar { min-height: 78px; }
    .brand img { width: 190px; }
    .container { width: min(100% - 28px, 1280px); padding-top: 28px; }
    .metric-grid, .filter-panel, .form-grid { grid-template-columns: 1fr; }
    .field-search, .field-full { grid-column: auto; }
    .metric-card { min-height: 135px; }
    .heading-with-actions { display: grid; }
    .panel, .form-panel { padding: 18px; }
    .login-panel { padding: 24px; }
    .filter-actions, .form-actions { align-items: stretch; flex-direction: column-reverse; }
    .footer { width: calc(100% - 28px); display: grid; gap: 8px; }
    .footer-actions { align-items: flex-start; flex-direction: column; gap: 6px; }
}
