:root {
  color-scheme: light;
  --navy: #0b172a;
  --navy-2: #152a46;
  --ink: #142033;
  --muted: #637083;
  --line: #dde4ed;
  --surface: #fff;
  --canvas: #f3f6fa;
  --teal: #0b9f86;
  --teal-bright: #19c3a3;
  --teal-soft: #e7f8f4;
  --danger: #c53b4d;
  --warning: #c67b12;
  --shadow: 0 18px 50px rgba(11, 23, 42, .10);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2.4rem, 5vw, 5rem); line-height: .98; letter-spacing: -.055em; }
h2 { font-size: clamp(1.55rem, 3vw, 2.25rem); letter-spacing: -.035em; }
h3 { letter-spacing: -.02em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.compact { margin: .15rem 0 0; font-size: .85rem; }
.skip-link { position: fixed; z-index: 100; top: -60px; left: 1rem; padding: .7rem 1rem; background: #fff; border-radius: 8px; }
.skip-link:focus { top: 1rem; }
.eyebrow { margin: 0 0 .65rem; color: var(--teal); font-weight: 800; font-size: .75rem; letter-spacing: .13em; text-transform: uppercase; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; background: var(--navy); }
.auth-brand { position: relative; overflow: hidden; padding: clamp(3rem, 8vw, 8rem); color: #fff; display: flex; flex-direction: column; justify-content: center; }
.auth-brand::before, .auth-brand::after { content: ""; position: absolute; border: 1px solid rgba(25,195,163,.22); border-radius: 50%; width: 45vw; height: 45vw; right: -20vw; top: -18vw; }
.auth-brand::after { width: 28vw; height: 28vw; right: -10vw; top: -8vw; }
.auth-brand > * { position: relative; z-index: 1; max-width: 700px; }
.auth-brand > p:not(.eyebrow) { max-width: 620px; color: #bac8d9; font-size: 1.1rem; line-height: 1.65; }
.brand-mark { width: 74px; height: 74px; margin-bottom: 2.5rem; display: grid; place-items: center; border-radius: 23px; background: var(--teal-bright); color: var(--navy); font-size: 1.25rem; font-weight: 900; box-shadow: 0 16px 45px rgba(25,195,163,.25); }
.brand-mark.small { width: 42px; height: 42px; margin: 0; border-radius: 13px; font-size: .8rem; flex: 0 0 auto; }
.value-list { list-style: none; padding: 1.3rem 0 0; margin: 0; display: grid; gap: .75rem; color: #d9e4ef; }
.value-list li::before { content: "✓"; margin-right: .7rem; color: var(--teal-bright); font-weight: 900; }
.auth-panel { padding: 2rem; display: grid; place-items: center; background: #edf3f8; }
.auth-card { width: min(100%, 470px); padding: clamp(1.7rem, 5vw, 3.5rem); display: grid; gap: 1.15rem; border: 1px solid rgba(255,255,255,.7); border-radius: 28px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }

label { display: grid; gap: .45rem; color: #344258; font-size: .85rem; font-weight: 750; }
input, select, textarea { width: 100%; min-height: 44px; border: 1px solid #cfd8e5; border-radius: 10px; padding: .72rem .8rem; color: var(--ink); background: #fff; outline: none; transition: border .2s, box-shadow .2s; }
textarea { min-height: 112px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11,159,134,.13); }
.button { min-height: 42px; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-weight: 800; transition: transform .15s, opacity .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button.primary { background: var(--teal); color: #fff; }
.button.secondary { background: var(--navy); color: #fff; }
.button.subtle { color: var(--navy); background: #edf2f7; }
.button.ghost { color: #d7e3ef; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); }
.button.link { min-height: auto; padding: .4rem; color: var(--teal); background: transparent; }
.button.danger { color: #fff; background: var(--danger); }
.wide { width: 100%; }
.form-message { min-height: 1.25rem; margin: 0; color: var(--danger); font-size: .85rem; text-align: center; }
.form-message.success { color: var(--teal); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: 1.3rem; color: #dce7f2; background: var(--navy); z-index: 30; }
.app-brand { display: flex; align-items: center; gap: .8rem; padding: .15rem .55rem 1.2rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.1); }
.app-brand span:last-child { display: grid; }
.app-brand small { color: #9eb0c4; }
.sidebar nav { display: grid; gap: .35rem; }
.sidebar nav a { display: flex; align-items: center; gap: .8rem; padding: .72rem .8rem; color: #bdcbd9; text-decoration: none; border-radius: 10px; font-size: .9rem; font-weight: 720; }
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; background: rgba(25,195,163,.14); }
.sidebar nav a.active { box-shadow: inset 3px 0 var(--teal-bright); }
.sidebar nav a span { width: 18px; text-align: center; color: var(--teal-bright); font-weight: 900; }
.nav-label { margin: 1.15rem .8rem .25rem; color: #6f8399; font-size: .66rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.sidebar-footer { margin-top: auto; display: grid; gap: .7rem; }
.support-badge { padding: .75rem; border-radius: 10px; color: #132338; background: #ffe59d; font-size: .75rem; font-weight: 800; }
.workspace { min-width: 0; }
.topbar { height: 74px; padding: 0 clamp(1rem, 3vw, 2.5rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.company-name { margin: 0; font-weight: 900; }
.top-actions { display: flex; align-items: center; gap: .7rem; }
.user-chip { max-width: 260px; padding: .55rem .75rem; border-radius: 999px; background: var(--teal-soft); color: #08705f; font-size: .82rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { position: relative; width: min(100%, 1540px); margin: 0 auto; padding: clamp(1rem, 3vw, 2.5rem); }
.loading { position: fixed; z-index: 70; inset: 74px 0 0 250px; display: grid; place-items: center; align-content: center; gap: .8rem; color: var(--muted); background: rgba(243,246,250,.72); backdrop-filter: blur(3px); }
.loading span { width: 34px; height: 34px; border: 3px solid #cbd6e2; border-top-color: var(--teal); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 80; right: 1.5rem; bottom: 1.5rem; max-width: min(420px, calc(100vw - 3rem)); padding: .9rem 1.1rem; color: #fff; background: var(--navy); border-radius: 12px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }

.page-heading { margin-bottom: 1.5rem; display: flex; justify-content: space-between; align-items: end; gap: 1rem; }
.page-heading h1 { margin: 0 0 .35rem; font-size: clamp(1.7rem, 3vw, 2.65rem); letter-spacing: -.045em; }
.page-heading p { margin: 0; color: var(--muted); }
.card { padding: clamp(1rem, 2vw, 1.4rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 7px 24px rgba(11,23,42,.045); }
.card h3 { margin-bottom: 1rem; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(150px,1fr)); gap: 1rem; }
.metric { position: relative; overflow: hidden; min-height: 135px; }
.metric::after { content: ""; position: absolute; width: 85px; height: 85px; right: -28px; top: -28px; border-radius: 50%; background: var(--metric-color, var(--teal-soft)); opacity: .8; }
.metric .value { margin: .2rem 0; font-size: 2rem; font-weight: 920; letter-spacing: -.05em; }
.metric .label { color: var(--muted); font-size: .82rem; font-weight: 750; }
.metric .hint { margin-top: .75rem; color: var(--teal); font-size: .75rem; font-weight: 800; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.grid.three { grid-template-columns: repeat(3,minmax(0,1fr)); }
.dashboard-grid { margin-top: 1rem; display: grid; grid-template-columns: 1.2fr .8fr; gap: 1rem; }
.section-stack { display: grid; gap: 1rem; }
.bar-list { display: grid; gap: .8rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px,1fr) 3fr auto; align-items: center; gap: .7rem; font-size: .82rem; }
.bar-track { height: 9px; overflow: hidden; background: #edf1f5; border-radius: 9px; }
.bar-fill { height: 100%; min-width: 2px; background: var(--bar-color,var(--teal)); border-radius: inherit; }
.bar-row strong { min-width: 24px; text-align: right; }

.filters { margin-bottom: 1rem; display: grid; grid-template-columns: repeat(auto-fit,minmax(145px,1fr)); gap: .65rem; align-items: end; }
.filters .filter-search { grid-column: span 2; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .8rem .9rem; border-bottom: 1px solid #edf1f5; text-align: left; vertical-align: middle; white-space: nowrap; }
th { position: sticky; top: 0; color: #526074; background: #f8fafc; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7fbfa; }
tbody tr:last-child td { border-bottom: 0; }
.title-cell { min-width: 230px; max-width: 410px; white-space: normal; }
.title-cell strong, .title-cell small { display: block; }
.title-cell small { margin-top: .2rem; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: .35rem; min-height: 25px; padding: .2rem .55rem; border-radius: 999px; color: var(--badge-color,#334155); background: color-mix(in srgb, var(--badge-color,#64748b) 13%, white); font-size: .72rem; font-weight: 850; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--badge-color,#64748b); }
.empty-state { padding: 4rem 1.2rem; text-align: center; }
.empty-state > div { margin-bottom: .8rem; color: var(--teal); font-size: 2.3rem; }

.form-card { max-width: 1050px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.form-grid .full { grid-column: 1/-1; }
.form-actions { grid-column: 1/-1; display: flex; justify-content: flex-end; gap: .7rem; padding-top: .5rem; }
.tabs { margin-bottom: 1rem; display: flex; gap: .3rem; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs button { padding: .75rem 1rem; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; cursor: pointer; white-space: nowrap; font-weight: 800; }
.tabs button.active { color: var(--teal); border-bottom-color: var(--teal); }
.inline-form { margin-bottom: 1rem; display: grid; grid-template-columns: repeat(4,minmax(110px,1fr)) auto; gap: .6rem; align-items: end; }
.compact-form { margin-top: .8rem; display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: .65rem; align-items: end; }
.compact-form .full, .compact-form .permission-grid { grid-column: 1 / -1; }
.editor { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .85rem; }
.editor > summary, .table-editor > summary { color: var(--teal); cursor: pointer; font-weight: 850; }
.settings-list { display: grid; gap: .55rem; margin-top: 1rem; }
.settings-item { border: 1px solid var(--line); border-radius: 10px; background: #fafbfd; }
.settings-item > summary, .settings-item.static { padding: .7rem .8rem; display: flex; justify-content: space-between; align-items: center; gap: .7rem; cursor: pointer; list-style: none; }
.settings-item > summary::-webkit-details-marker { display: none; }
.settings-item > summary small, .settings-item.static small { display: block; margin-top: .15rem; color: var(--muted); font-weight: 600; }
.settings-item > form { margin: 0; padding: .8rem; border-top: 1px solid var(--line); }
.check-line { min-height: 44px; display: flex; grid-auto-flow: column; justify-content: start; align-items: center; gap: .5rem; }
.check-line input { width: auto; min-height: auto; }
.table-editor { min-width: 290px; }
.table-editor .compact-form { grid-template-columns: 1fr; }
.permission-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .45rem; }
.permission-check { display: flex; flex-direction: row; align-items: center; gap: .55rem; padding: .5rem; border: 1px solid var(--line); border-radius: 8px; }
.permission-check input { width: auto; min-height: auto; }

.dialog { width: min(1050px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: 22px; color: var(--ink); box-shadow: 0 30px 90px rgba(2,9,20,.35); }
.dialog::backdrop { background: rgba(3,10,21,.67); backdrop-filter: blur(4px); }
.dialog-close { position: sticky; z-index: 2; float: right; top: 1rem; margin: 1rem 1rem -3.7rem; background: #eef2f7; }
.dialog-body { padding: clamp(1.2rem,4vw,2.3rem); }
.dialog-head { padding-right: 3.5rem; }
.dialog-head h2 { margin-bottom: .25rem; }
.detail-meta { margin: 1rem 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.detail-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 1rem; }
.description { white-space: pre-wrap; line-height: 1.65; }
.detail-actions { display: grid; gap: .7rem; }
.detail-actions form { padding: .9rem; border: 1px solid var(--line); border-radius: 12px; background: #fafbfd; }
.timeline { display: grid; gap: .7rem; }
.timeline-item { position: relative; padding-left: 1.2rem; border-left: 2px solid #d8e2eb; }
.timeline-item::before { content: ""; position: absolute; width: 8px; height: 8px; left: -5px; top: .35rem; border-radius: 50%; background: var(--teal); }
.timeline-item p { margin: .15rem 0; }
.timeline-item small { color: var(--muted); }
.comment { padding: .8rem; border-radius: 10px; background: #f4f7fa; }
.comment p { margin: .25rem 0 0; white-space: pre-wrap; }
.evidence-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.evidence-item { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.evidence-list a { padding: .6rem .75rem; color: var(--teal); text-decoration: none; font-size: .8rem; font-weight: 800; }
.evidence-delete { width: 34px; border: 0; border-left: 1px solid var(--line); color: var(--danger); background: #fff5f5; cursor: pointer; font-size: 1.1rem; font-weight: 900; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 10px; cursor: pointer; font-size: 1.25rem; }
.mobile-only { display: none; }

@media (max-width: 1080px) {
  .metrics { grid-template-columns: repeat(2,minmax(150px,1fr)); }
  .inline-form { grid-template-columns: repeat(2,minmax(120px,1fr)); }
}

@media (max-width: 800px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 42vh; padding: 2rem 1.5rem; }
  .auth-brand h1 { font-size: 2.5rem; }
  .brand-mark { margin-bottom: 1.5rem; }
  .value-list { display: none; }
  .auth-panel { padding: 1rem; align-items: start; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -270px; width: 250px; transition: left .22s; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  .mobile-only { display: inline-grid; place-items: center; }
  .loading { inset-left: 0; inset: 74px 0 0; }
  .dashboard-grid, .grid.two, .grid.three, .detail-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 1rem; }
  .user-chip { max-width: 135px; }
  .page-heading { align-items: start; flex-direction: column; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .filter-search { grid-column: 1/-1; }
}

@media (max-width: 560px) {
  .metrics, .form-grid, .permission-grid, .inline-form, .filters { grid-template-columns: 1fr; }
  .filters > *, .filters .filter-search { grid-column: 1; }
  .metric { min-height: 110px; }
  .top-actions .button { display: none; }
  main { padding: 1rem; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
