:root {
  --navy-950: #07182a;
  --navy-900: #0d2238;
  --navy-800: #12304f;
  --navy-700: #1a436b;
  --teal-600: #098f88;
  --teal-500: #12aaa1;
  --teal-100: #dff7f4;
  --blue-100: #e6f0fa;
  --ink: #142033;
  --muted: #677487;
  --line: #dce3eb;
  --surface: #ffffff;
  --background: #f3f6f9;
  --warning: #a86500;
  --warning-bg: #fff2d7;
  --danger: #a63333;
  --danger-bg: #fde8e8;
  --success: #167254;
  --success-bg: #e1f5ec;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(12, 38, 64, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--background); }
a { color: var(--navy-700); text-decoration: none; }
a:hover { color: var(--teal-600); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .55rem; font-size: clamp(1.9rem, 3vw, 2.8rem); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: .4rem; font-size: 1.35rem; letter-spacing: -.02em; }
h3 { margin-bottom: .5rem; font-size: 1.05rem; }
p { line-height: 1.58; }
small { color: var(--muted); }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 248px;
  padding: 24px 18px;
  color: #fff;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  box-shadow: 8px 0 30px rgba(7, 24, 42, .12);
}

.brand { display: flex; align-items: center; gap: 11px; color: #fff; }
.brand:hover { color: #fff; }
.brand > span, .brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: white;
  font-weight: 800;
  letter-spacing: -.04em;
  background: linear-gradient(135deg, var(--teal-500), #64d5cd);
  box-shadow: 0 8px 20px rgba(18, 170, 161, .25);
}
.brand div { display: flex; flex-direction: column; }
.brand strong { font-size: 1rem; }
.brand small { color: #9fb4c8; font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; }
.sidebar nav { display: grid; gap: 7px; margin-top: 38px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; color: #b9c8d8; border-radius: 11px; font-size: .92rem; }
.sidebar nav a span { width: 20px; text-align: center; color: #87a3bb; font-size: 1.05rem; }
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; background: rgba(255,255,255,.085); }
.sidebar nav a.active span { color: #62d5cd; }
.sidebar-foot { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.1); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.user-chip > span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-weight: 700; }
.user-chip div { display: flex; min-width: 0; flex-direction: column; }
.user-chip strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.user-chip small { color: #8fa8bf; font-size: .7rem; }
.link-button { padding: 0; color: #9db1c4; border: 0; background: none; font-size: .8rem; }
.link-button:hover { color: #fff; }
.mobile-head { display: none; }

.app-main { min-height: 100vh; margin-left: 248px; padding: 34px clamp(22px, 4vw, 64px) 28px; }
.app-footer { display: flex; justify-content: space-between; gap: 24px; margin-top: 30px; padding: 18px 2px 0; color: #8793a3; border-top: 1px solid var(--line); font-size: .73rem; }
.page-head, .case-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 26px; }
.page-head p:last-child, .case-head p:last-child { margin-bottom: 0; color: var(--muted); }
.eyebrow { margin-bottom: .45rem; color: var(--teal-600); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.back { display: inline-block; margin-bottom: 18px; color: var(--muted); font-size: .82rem; }
.case-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-bottom: 6px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 10px 17px;
  color: #fff;
  border: 1px solid var(--navy-800);
  border-radius: 10px;
  background: var(--navy-800);
  box-shadow: 0 5px 14px rgba(18, 48, 79, .14);
  font-weight: 700;
  font-size: .88rem;
  transition: .18s ease;
}
.button:hover { color: #fff; border-color: var(--teal-600); background: var(--teal-600); transform: translateY(-1px); }
.button.small { min-height: 37px; padding: 8px 13px; font-size: .78rem; }
.button.tiny { min-height: 30px; padding: 5px 9px; font-size: .7rem; }
.button.ghost { color: var(--navy-700); background: transparent; box-shadow: none; }
.button.ghost:hover { color: var(--teal-600); background: var(--teal-100); }
.button.wide { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 22px; }
.metric { padding: 19px 20px; border: 1px solid #e1e7ee; border-radius: 14px; background: var(--surface); box-shadow: 0 6px 22px rgba(12,38,64,.04); }
.metric span, .metric small { display: block; color: var(--muted); font-size: .72rem; }
.metric strong { display: block; margin: 8px 0 4px; color: var(--navy-800); font-size: 1.75rem; line-height: 1; }

.card { margin-bottom: 20px; padding: clamp(20px, 3vw, 30px); border: 1px solid #e0e6ed; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); scroll-margin-top: 18px; }
.card.narrow { max-width: 900px; }
.card-head, .section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.card-head p, .section-title p { margin-bottom: 0; }
.subsection { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--line); }
.muted { color: var(--muted); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.narrow { max-width: 960px; }

.search { width: min(320px, 40vw); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th { padding: 11px 12px; color: #798596; border-bottom: 1px solid var(--line); text-align: left; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
td { padding: 14px 12px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td small { display: block; margin-top: 4px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; }
.align-right { text-align: right; }
.align-right small { display: block; margin-top: 4px; }

.badge { display: inline-flex; align-items: center; width: max-content; min-height: 25px; padding: 4px 9px; border-radius: 999px; color: #4d5a6c; background: #eef2f6; white-space: nowrap; font-size: .67rem; font-weight: 800; letter-spacing: .025em; }
.badge.approved, .badge.accepted, .badge.closed, .badge.active, .badge.ok, .badge.paid { color: var(--success); background: var(--success-bg); }
.badge.blocked, .badge.pending, .badge.documentation_pending, .badge.not_started, .badge.proposed, .badge.accrued { color: #626d7b; background: #eef1f4; }
.badge.human_review, .badge.ecoality_review, .badge.preanalysis, .badge.review, .badge.liquidable, .badge.alert { color: var(--warning); background: var(--warning-bg); }
.badge.rejected, .badge.cancelled, .badge.expired, .badge.reversed { color: var(--danger); background: var(--danger-bg); }
.badge.structured, .badge.commercial, .badge.reserved, .badge.ready { color: #225a8b; background: var(--blue-100); }

label { display: grid; gap: 7px; color: #475466; font-size: .77rem; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  border: 1px solid #ccd5df;
  border-radius: 9px;
  outline: none;
  background: #fff;
  font-weight: 500;
  transition: border .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(18,170,161,.12); }
label small { font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.span-2 { grid-column: span 2; }
.stack { display: grid; gap: 16px; }
.inline-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.inline-form label { min-width: 160px; }
.inline-form .grow, .grow { flex: 1; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
hr { width: 100%; margin: 22px 0; border: 0; border-top: 1px solid var(--line); }

.notice { padding: 14px 16px; color: #3f5266; border-left: 4px solid var(--teal-500); border-radius: 6px 10px 10px 6px; background: #edf8f7; }
.notice p { margin: 4px 0 0; font-size: .82rem; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty.compact { padding: 18px; border: 1px dashed #cfd8e2; border-radius: 12px; }
.empty h1 { color: var(--navy-800); font-size: 4rem; }
.empty h3 { color: var(--ink); }

.anchor-nav { position: sticky; top: 12px; z-index: 20; display: flex; gap: 4px; margin: -8px 0 20px; padding: 6px; overflow-x: auto; border: 1px solid #e1e7ed; border-radius: 12px; background: rgba(255,255,255,.94); box-shadow: 0 6px 18px rgba(10,32,54,.06); backdrop-filter: blur(12px); }
.anchor-nav a { padding: 8px 11px; color: #647184; border-radius: 8px; white-space: nowrap; font-size: .72rem; font-weight: 700; }
.anchor-nav a:hover { color: var(--teal-600); background: var(--teal-100); }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.detail-grid.compact { margin-top: 20px; }
.detail { min-height: 82px; padding: 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail:nth-child(4n) { border-right: 0; }
.detail span, .detail strong { display: block; }
.detail span { margin-bottom: 7px; color: var(--muted); font-size: .68rem; }
.detail strong { color: var(--navy-800); font-size: .86rem; line-height: 1.35; }

.check-list { display: grid; gap: 1px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 13px 15px; background: #fff; border-bottom: 1px solid var(--line); }
.check-item:last-child { border-bottom: 0; }
.check-item small { display: block; margin-top: 3px; }
.check-icon { display: grid; flex: 0 0 27px; place-items: center; width: 27px; height: 27px; border-radius: 50%; color: #6d7886; background: #edf1f4; font-weight: 900; }
.check-icon.accepted { color: var(--success); background: var(--success-bg); }
.check-icon.rejected { color: var(--danger); background: var(--danger-bg); }
.review-form { display: flex; align-items: center; gap: 6px; }
.review-form select { width: 115px; min-height: 32px; padding: 5px 8px; }
.review-form input { width: 210px; min-height: 32px; padding: 5px 8px; }

.document-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.document { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; }
.document:hover { color: var(--ink); border-color: var(--teal-500); background: #f7fcfb; }
.document > span:last-child { min-width: 0; }
.document strong, .document small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document strong { font-size: .78rem; }
.document small { margin-top: 3px; font-size: .66rem; }
.doc-icon { display: grid; flex: 0 0 39px; place-items: center; width: 39px; height: 39px; border-radius: 9px; color: var(--navy-700); background: var(--blue-100); font-size: .64rem; font-weight: 800; }
.upload-form { display: grid; grid-template-columns: 135px 1fr 1.1fr 145px 1.25fr auto; align-items: end; gap: 10px; margin-top: 16px; }
.file-label input { padding: 7px; font-size: .72rem; }

.locked { display: flex; align-items: center; gap: 16px; padding: 20px; border: 1px dashed #c7d1dc; border-radius: 12px; background: #f8fafc; }
.locked > span { font-size: 1.5rem; }
.locked p { margin: 3px 0 0; color: var(--muted); }
.analysis-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.analysis-summary > div { padding: 14px; border-radius: 10px; background: #f3f7fa; }
.analysis-summary span, .analysis-summary strong { display: block; }
.analysis-summary span { color: var(--muted); font-size: .66rem; }
.analysis-summary strong { margin-top: 5px; color: var(--navy-800); font-size: .84rem; }
.check-review-grid { display: grid; gap: 8px; }
.review-row { display: grid; grid-template-columns: 1.4fr 150px 1.5fr; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.review-row small { display: block; margin-top: 3px; }
.approval-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; margin-top: 18px; padding: 17px; border-radius: 12px; background: #edf8f7; }
.engine-form, details { margin-top: 22px; border-top: 1px solid var(--line); }
summary { padding: 17px 0 0; color: var(--navy-700); font-size: .82rem; font-weight: 800; cursor: pointer; }
details > form { margin-top: 18px; }

.provider-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.provider-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.provider-card h3 { margin: 5px 0 4px; }
.provider-card p { margin-bottom: 4px; color: var(--muted); font-size: .78rem; }
.provider-card .review-form { grid-column: 1 / -1; }
.provider-type { color: var(--teal-600); font-size: .67rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.list { display: grid; gap: 0; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item strong, .list-item small { display: block; }
.list-item small { margin-top: 4px; }
.timeline { display: grid; }
.timeline article { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: 10px; padding-bottom: 20px; }
.timeline article:not(:last-child)::before { position: absolute; top: 13px; bottom: -2px; left: 5px; width: 1px; content: ""; background: #d5dde6; }
.timeline-dot { z-index: 1; width: 11px; height: 11px; margin-top: 4px; border: 3px solid #d7f1ee; border-radius: 50%; background: var(--teal-500); }
.timeline small { display: block; margin-top: 3px; }
.timeline p { margin: 5px 0 0; color: #4e5c6e; font-size: .8rem; }

.flash-stack { position: fixed; top: 18px; right: 20px; z-index: 100; display: grid; gap: 9px; width: min(520px, calc(100vw - 40px)); }
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; color: #374456; border: 1px solid #d7dfe8; border-radius: 11px; background: #fff; box-shadow: 0 12px 32px rgba(8,29,49,.16); }
.flash > span { display: grid; flex: 0 0 24px; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-weight: 900; }
.flash p { flex: 1; margin: 1px 0 0; overflow-wrap: anywhere; font-size: .81rem; }
.flash button { color: #8a95a2; border: 0; background: none; font-size: 1.1rem; }
.flash.success > span { color: var(--success); background: var(--success-bg); }
.flash.error > span { color: var(--danger); background: var(--danger-bg); }

.auth-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 75% 20%, rgba(18,170,161,.18), transparent 30%), linear-gradient(135deg, var(--navy-950), var(--navy-800)); }
.auth-card { width: min(440px, 100%); padding: 36px; border: 1px solid rgba(255,255,255,.12); border-radius: 20px; background: rgba(255,255,255,.98); box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.auth-card .brand-mark { margin-bottom: 28px; }
.auth-card h1 { color: var(--navy-900); }
.legal-note { margin: 22px 0 0; color: #8b95a2; font-size: .68rem; text-align: center; }

.installer-page { background: linear-gradient(135deg, #07182a, #12304f); }
.installer-shell { display: grid; grid-template-columns: .85fr 1.15fr; width: min(1140px, calc(100% - 40px)); min-height: calc(100vh - 60px); margin: 30px auto; overflow: hidden; border-radius: 22px; background: #fff; box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.installer-intro { padding: clamp(34px, 6vw, 70px); color: white; background: radial-gradient(circle at 20% 90%, rgba(18,170,161,.32), transparent 32%), var(--navy-900); }
.installer-intro h1 { margin-top: 25px; }
.installer-intro p { color: #b8c8d7; }
.feature-list { display: grid; gap: 13px; margin: 34px 0 0; padding: 0; list-style: none; }
.feature-list li::before { margin-right: 9px; color: #4dd4cb; content: "✓"; font-weight: 900; }
.installer-card { padding: clamp(30px, 5vw, 58px); overflow: auto; }
.server-checks { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0 24px; }
.server-checks span { padding: 5px 8px; border-radius: 999px; font-size: .66rem; font-weight: 700; }
.server-checks .ok { color: var(--success); background: var(--success-bg); }
.server-checks .warn { color: var(--warning); background: var(--warning-bg); }
.server-checks .bad { color: var(--danger); background: var(--danger-bg); }
code { padding: 2px 5px; border-radius: 5px; background: #edf1f5; }

@media (max-width: 1120px) {
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail:nth-child(2n) { border-right: 0; }
  .upload-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-form .button { width: max-content; }
  .document-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-105%); transition: transform .2s ease; }
  body.menu-open .sidebar { transform: translateX(0); }
  .mobile-head { position: sticky; top: 0; z-index: 35; display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 10px 18px; color: #fff; background: var(--navy-950); }
  .mobile-head .brand > span { width: 34px; height: 34px; border-radius: 10px; }
  .mobile-head button { color: #fff; border: 0; background: transparent; font-size: 1.3rem; }
  .app-main { margin-left: 0; padding: 26px 18px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .installer-shell { grid-template-columns: 1fr; }
  .installer-intro { display: none; }
}

@media (max-width: 650px) {
  h1 { font-size: 1.8rem; }
  .page-head, .case-head, .card-head, .section-title { align-items: flex-start; flex-direction: column; }
  .case-badges { justify-content: flex-start; }
  .metric-grid, .detail-grid, .analysis-summary, .provider-grid, .document-grid, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .detail { border-right: 0; }
  .review-form, .inline-form { align-items: stretch; flex-direction: column; }
  .review-form input, .review-form select, .inline-form label { width: 100%; }
  .check-item { align-items: flex-start; flex-wrap: wrap; }
  .check-item .review-form { width: 100%; margin-left: 39px; }
  .review-row { grid-template-columns: 1fr; }
  .approval-form { grid-template-columns: 1fr; }
  .upload-form { grid-template-columns: 1fr; }
  .anchor-nav { top: 70px; }
  .app-footer { flex-direction: column; gap: 5px; }
  .installer-shell { width: 100%; min-height: 100vh; margin: 0; border-radius: 0; }
}
