:root {
  --ink: #172033;
  --muted: #667085;
  --line: #dfe5ee;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --navy: #1f3a5f;
  --blue: #3369d7;
  --blue-soft: #eaf1ff;
  --green: #197a55;
  --green-soft: #e7f7ef;
  --orange: #a45317;
  --orange-soft: #fff1e5;
  --red: #b63c42;
  --red-soft: #fff0f1;
  --purple: #6d4bb5;
  --purple-soft: #f1ecff;
  --shadow: 0 10px 28px rgba(31, 58, 95, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #edf2f8;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #edf2f8; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.public-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 34px 18px;
  background:
    radial-gradient(circle at 15% 10%, rgba(73, 128, 230, .18), transparent 32%),
    radial-gradient(circle at 90% 86%, rgba(116, 78, 190, .14), transparent 30%),
    #edf2f8;
}

.public-card {
  width: min(1160px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.public-header, .public-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
}

.public-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--navy);
  font-weight: 800;
  letter-spacing: -.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: linear-gradient(135deg, #315fc6, #6e4fc0);
  font-weight: 900;
  font-size: 14px;
}

.public-nav, .action-row, .button-row, .filter-row, .toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.public-nav button, .link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
}

.public-nav button:hover, .link-button:hover { color: var(--blue); }

.hero {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  gap: 34px;
  padding: 58px 58px 44px;
}

.eyebrow, .kicker {
  margin: 0 0 9px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 16px; font-size: clamp(32px, 5vw, 58px); line-height: 1.02; letter-spacing: -.055em; }
h2 { margin-bottom: 8px; font-size: 25px; letter-spacing: -.03em; }
h3 { margin-bottom: 6px; font-size: 17px; }
h4 { margin-bottom: 5px; font-size: 14px; }
.lead { max-width: 680px; color: var(--muted); font-size: 17px; line-height: 1.65; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.hero-panel, .public-panel, .login-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
  padding: 20px;
}

.hero-panel { align-self: center; }
.hero-panel h3 { color: var(--navy); }

.credential-box {
  margin-top: 20px;
  padding: 14px;
  border: 1px dashed #9bb5e9;
  border-radius: 13px;
  background: var(--blue-soft);
  color: #244d97;
  font-size: 13px;
  line-height: 1.65;
}

.credential-box code {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .72);
  color: #183a78;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  transition: .16s ease;
}

.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--blue); border-color: var(--blue); }
.button-secondary { color: var(--navy); background: white; border-color: #b9c7dc; }
.button-quiet { color: var(--navy); background: var(--surface-2); border-color: var(--line); }
.button-success { color: white; background: var(--green); border-color: var(--green); }
.button-warning { color: white; background: var(--orange); border-color: var(--orange); }
.button-danger { color: white; background: var(--red); border-color: var(--red); }
.button-note { color: #3057a3; background: var(--blue-soft); border-color: #c8d8fb; }

.public-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 0 58px 44px;
}

.public-panel p, .card p { line-height: 1.55; }

.form-page {
  width: min(620px, 100%);
  margin: auto;
  padding: 46px 28px 54px;
}

.form-page h1 { font-size: 36px; }
.form-page form { margin-top: 22px; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #344054; font-size: 12px; font-weight: 800; }
.field input, .field select, .field textarea, .top-select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #cfd8e6;
  border-radius: 9px;
  outline: none;
  background: white;
  color: var(--ink);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .top-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(51, 105, 215, .12); }
.form-error { margin: 12px 0; padding: 10px 12px; border-radius: 8px; color: #8c222c; background: var(--red-soft); font-size: 13px; }
.form-help { color: var(--muted); font-size: 12px; line-height: 1.55; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px 1fr;
  background: #edf2f8;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 13px;
  overflow-y: auto;
  color: #dbe8ff;
  background: #162840;
}

.sidebar .brand { color: white; padding: 0 9px; }
.demo-chip {
  margin: 0 9px;
  padding: 9px 11px;
  border: 1px solid rgba(167, 194, 237, .25);
  border-radius: 10px;
  color: #b9cff1;
  background: rgba(255, 255, 255, .06);
  font-size: 11px;
  line-height: 1.5;
}

.nav-label {
  padding: 0 11px 7px;
  color: #8da7cf;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.side-nav { display: grid; gap: 4px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #c7d6ee;
  background: transparent;
  text-align: left;
  font-size: 13px;
}
.nav-item:hover { color: white; background: rgba(255, 255, 255, .08); }
.nav-item.active { color: white; border-color: rgba(126, 164, 235, .45); background: rgba(78, 123, 217, .25); }
.nav-item.locked { color: #768aa8; }
.nav-item .nav-lock { margin-left: auto; font-size: 11px; }
.sidebar-footer { margin-top: auto; padding: 0 9px; color: #91a8cb; font-size: 11px; line-height: 1.55; }

.app-main { min-width: 0; }
.topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-title { color: var(--navy); font-size: 14px; font-weight: 800; }
.topbar-right .top-select { width: auto; min-width: 135px; min-height: 36px; padding: 6px 9px; font-size: 12px; }
.status-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: var(--green); }
.status-dot.closed { background: var(--red); }
.role-chip, .status-pill, .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.role-chip { color: #573c99; background: var(--purple-soft); }
.status-pill.success, .tag.success { color: #116744; background: var(--green-soft); }
.status-pill.warning, .tag.warning { color: #8c4818; background: var(--orange-soft); }
.status-pill.danger, .tag.danger { color: #982b35; background: var(--red-soft); }
.tag.info { color: #2c59a4; background: var(--blue-soft); }
.tag.neutral { color: #526074; background: #eef1f5; }

.content { padding: 30px 32px 48px; }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.page-header h1 { margin-bottom: 6px; font-size: clamp(25px, 3vw, 36px); }
.page-header p { max-width: 720px; margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.page-header .action-row { justify-content: flex-end; }
.note-trigger {
  border: 1px solid #c8d8fb;
  border-radius: 999px;
  padding: 6px 9px;
  color: #3057a3;
  background: var(--blue-soft);
  font-size: 11px;
  font-weight: 800;
}
.note-trigger:hover { background: #dce8ff; }

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(31, 58, 95, .035);
}
.card-pad { padding: 18px; }
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.card-header h3, .card-header p { margin-bottom: 0; }
.card-header p { color: var(--muted); font-size: 12px; line-height: 1.45; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.metric { padding: 16px; }
.metric .metric-label { color: var(--muted); font-size: 12px; }
.metric .metric-value { margin: 7px 0 3px; color: var(--navy); font-size: 24px; font-weight: 850; letter-spacing: -.04em; }
.metric .metric-hint { color: var(--muted); font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 15px; margin-top: 15px; }
.dashboard-grid-wide { grid-column: 1 / -1; }
.flow-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 18px; }
.flow-step {
  position: relative;
  min-height: 94px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 11px;
  border: 1px dashed #9eb4d7;
  border-radius: 10px;
  background: #f9fbff;
}
.flow-step:not(:last-child)::after { content: "→"; position: absolute; right: -12px; top: 36px; z-index: 1; color: #7393c4; }
.flow-step .step-number { color: var(--blue); font-size: 11px; font-weight: 900; }
.flow-step strong { font-size: 12px; }
.flow-step span { color: var(--muted); font-size: 10px; line-height: 1.35; }

.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 16px; }
.quick-grid .button { justify-content: flex-start; }
.info-callout {
  padding: 12px 14px;
  border-left: 3px solid var(--blue);
  border-radius: 9px;
  background: var(--blue-soft);
  color: #2d4b80;
  font-size: 12px;
  line-height: 1.55;
}
.info-callout.warning { border-left-color: var(--orange); background: var(--orange-soft); color: #714115; }
.info-callout.success { border-left-color: var(--green); background: var(--green-soft); color: #155c42; }

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 17px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}
.tab {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-color: #b9c8e1; background: white; box-shadow: 0 2px 7px rgba(31, 58, 95, .06); }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .72fr); gap: 15px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.four-col { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stack { display: grid; gap: 15px; }
.stack-sm { display: grid; gap: 9px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 11px 13px; border-bottom: 1px solid #edf0f5; text-align: left; vertical-align: top; }
th { color: var(--muted); background: #fafbfd; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.empty { padding: 24px 14px; color: var(--muted); text-align: center; font-size: 12px; }

.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; padding: 15px; }
.product-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
}
.product-card .product-icon { width: 31px; height: 31px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 9px; color: #315fa8; background: var(--blue-soft); font-weight: 900; }
.product-card strong { font-size: 13px; }
.product-card p { margin-bottom: 12px; color: var(--muted); font-size: 11px; }
.product-card .button { width: 100%; }

.cart-list { padding: 14px 18px; display: grid; gap: 10px; }
.cart-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid #edf0f5; }
.cart-row:last-child { border-bottom: 0; }
.cart-row strong { font-size: 12px; }
.cart-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.qty-actions { display: flex; align-items: center; gap: 5px; }
.qty-actions button { width: 25px; height: 25px; padding: 0; border: 1px solid #cbd6e6; border-radius: 6px; color: var(--navy); background: white; }
.qty-actions span { min-width: 18px; text-align: center; font-size: 11px; font-weight: 800; }
.total-box { padding: 14px 18px; border-top: 1px solid var(--line); background: #fbfcfe; }
.total-line { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.total-line.total { margin-top: 10px; color: var(--navy); font-size: 15px; font-weight: 850; }
.cart-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }

.gate {
  display: grid;
  place-items: center;
  min-height: 340px;
  padding: 25px;
  border: 1px dashed #e5b88f;
  border-radius: 14px;
  background: #fffaf4;
  text-align: center;
}
.gate-icon { width: 50px; height: 50px; display: grid; place-items: center; margin: 0 auto 15px; border-radius: 50%; color: var(--orange); background: var(--orange-soft); font-size: 22px; }
.gate p { max-width: 440px; color: var(--muted); line-height: 1.55; }

.list-card { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; }
.list-card h4 { color: var(--navy); }
.list-card p { margin-bottom: 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.list-card ul { margin: 0; padding-left: 19px; color: var(--muted); font-size: 12px; line-height: 1.7; }

.report-layout { display: grid; grid-template-columns: 280px 1fr; gap: 15px; }
.report-menu { max-height: 680px; overflow-y: auto; padding: 10px; }
.report-group + .report-group { margin-top: 15px; }
.report-group-title { padding: 6px 8px; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.report-link { width: 100%; display: block; padding: 8px 9px; border: 1px solid transparent; border-radius: 7px; color: #445166; background: transparent; text-align: left; font-size: 11px; }
.report-link:hover { color: var(--blue); background: var(--blue-soft); }
.report-link.active { color: var(--navy); border-color: #c5d5f4; background: #eef4ff; font-weight: 800; }
.report-preview { min-height: 520px; }
.report-preview .preview-chart { min-height: 150px; display: flex; align-items: end; gap: 10px; padding: 20px; border: 1px dashed #b8c8df; border-radius: 10px; background: #fbfcfe; }
.bar { flex: 1; min-width: 20px; border-radius: 5px 5px 0 0; background: linear-gradient(#6d91e5, #315fc5); }
.bar-label { margin-top: 7px; color: var(--muted); font-size: 10px; text-align: center; }

.role-table td:first-child { font-weight: 800; color: var(--navy); }
.access-list { display: flex; flex-wrap: wrap; gap: 5px; }
.access-list .tag { font-size: 10px; }
.legend-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.legend-item { padding: 11px; border: 1px dashed #a7b9d6; border-radius: 9px; background: #fbfcfe; }
.legend-swatch { width: 100%; height: 7px; margin-bottom: 8px; border-radius: 99px; background: var(--blue); }
.legend-swatch.sub { background: var(--red); }
.legend-swatch.button-swatch { background: var(--orange); }
.legend-swatch.tab-swatch { background: var(--green); }
.legend-item strong { display: block; margin-bottom: 4px; font-size: 12px; }
.legend-item p { margin-bottom: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 29, 49, .52);
}
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
  box-shadow: 0 24px 80px rgba(15, 27, 48, .25);
}
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-header h3 { margin-bottom: 4px; color: var(--navy); }
.modal-header p { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.modal-close { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: white; }
.modal-body { padding: 18px 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fbfcfe; }
.note-body { color: #46556b; font-size: 13px; line-height: 1.7; white-space: pre-line; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: 350px;
  padding: 13px 16px;
  border: 1px solid #b9d9c8;
  border-radius: 10px;
  color: #155c42;
  background: #effbf4;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
}

.right { text-align: right; }
.nowrap { white-space: nowrap; }
.divider { height: 1px; margin: 16px 0; background: var(--line); }
.mt-15 { margin-top: 15px; }
.mb-0 { margin-bottom: 0; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 205px 1fr; }
  .content { padding: 24px 20px 40px; }
  .hero { padding: 42px 34px 34px; }
  .public-grid { padding-right: 34px; padding-left: 34px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .flow-strip { grid-template-columns: repeat(3, 1fr); }
  .flow-step:nth-child(3)::after, .flow-step:nth-child(6)::after { display: none; }
}

@media (max-width: 800px) {
  .hero, .dashboard-grid, .two-col, .report-layout { grid-template-columns: 1fr; }
  .public-grid, .three-col, .four-col { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 36px 24px 28px; }
  .public-grid { padding: 0 24px 32px; }
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; }
  .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-footer { margin-top: 0; }
  .topbar { padding: 13px 18px; }
  .content { padding: 22px 16px 34px; }
  .page-header { display: block; }
  .page-header .action-row { justify-content: flex-start; margin-top: 14px; }
  .report-menu { max-height: none; }
}

@media (max-width: 520px) {
  .public-header { padding: 16px 18px; }
  .public-nav { display: none; }
  .public-grid, .field-grid, .product-grid, .legend-grid { grid-template-columns: 1fr; }
  .metric-grid, .flow-strip { grid-template-columns: 1fr 1fr; }
  .flow-step::after { display: none !important; }
  .topbar-right { width: 100%; }
  .topbar-right .top-select { flex: 1; min-width: 0; }
  .side-nav { grid-template-columns: 1fr; }
  .cart-actions { grid-template-columns: 1fr; }
}
