:root {
  --navy: #0f172a;
  --blue: #2563eb;
  --green: #22c55e;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #e2e8f0;
  --muted: #64748b;
  --text: #111827;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 18px 45px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, .12), transparent 34rem),
    linear-gradient(180deg, #fff 0%, var(--bg) 42%);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}
.brand-mark, .brand-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: var(--blue);
  color: #fff;
  font-weight: 950;
  letter-spacing: 0;
}
.login-card h1 { margin: 18px 0 8px; color: var(--navy); font-size: 1.8rem; }
.login-card p { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.login-card form, .modal-grid { display: grid; gap: 14px; }
label {
  display: grid;
  gap: 7px;
  color: var(--navy);
  font-weight: 800;
  font-size: .9rem;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  background: #fff;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}
.login-card button, .primary-button {
  border: 0;
  border-radius: 12px;
  min-height: 44px;
  padding: 0 16px;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}
.form-error { color: var(--danger); font-weight: 800; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(16px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand strong { display: block; color: var(--navy); }
.brand small { color: var(--muted); font-weight: 700; }
.nav {
  display: grid;
  gap: 8px;
}
.nav-item, .ghost-button, .icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #334155;
  text-align: left;
  font-weight: 850;
  padding: 0 12px;
}
.nav-item.is-active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--blue);
}
.ghost-button {
  margin-top: auto;
  border-color: var(--line);
  text-align: center;
  background: #fff;
}
.content {
  min-width: 0;
  padding: 28px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 950;
}
.topbar h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.75rem, 3vw, 2.4rem);
}
.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.icon-button {
  border-color: var(--line);
  background: #fff;
  text-align: center;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.kpi, .panel, .case-card, .case-detail {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 12px 34px rgba(15, 23, 42, .06);
}
.kpi {
  padding: 18px;
}
.kpi span {
  color: var(--muted);
  font-weight: 800;
  font-size: .85rem;
}
.kpi strong {
  display: block;
  margin-top: 8px;
  color: var(--navy);
  font-size: 2rem;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.45fr .75fr;
  gap: 16px;
  margin-bottom: 16px;
}
.panel {
  padding: 20px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel h2, .case-detail h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.05rem;
}
.panel-head span, .empty-detail p {
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
}
.chart {
  min-height: 230px;
  display: grid;
  align-items: end;
}
.bar-chart {
  height: 230px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  align-items: end;
}
.bar {
  display: grid;
  align-content: end;
  gap: 8px;
  min-width: 0;
}
.bar-fill {
  min-height: 8px;
  border-radius: 999px 999px 8px 8px;
  background: linear-gradient(180deg, var(--blue), #60a5fa);
}
.bar small {
  color: var(--muted);
  text-align: center;
  font-weight: 800;
  font-size: .76rem;
}
.donut-wrap {
  place-items: center;
  min-height: 230px;
}
.donut-label {
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}
.recent-list, .cases-list {
  display: grid;
  gap: 12px;
}
.recent-item, .case-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}
.recent-item {
  grid-template-columns: 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.recent-item:last-child { border-bottom: 0; }
.case-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.case-title strong { color: var(--navy); }
.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: .83rem;
  font-weight: 750;
}
.badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: .76rem;
  font-weight: 900;
}
.badge.green { background: #dcfce7; color: #166534; }
.badge.orange { background: #ffedd5; color: #9a3412; }
.badge.red { background: #fee2e2; color: #991b1b; }
.filters {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
  margin-bottom: 16px;
}
.cases-layout {
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(360px, 1.1fr);
  gap: 16px;
  align-items: start;
}
.case-card {
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.case-card:hover, .case-card.is-active {
  transform: translateY(-2px);
  border-color: #bfdbfe;
  box-shadow: var(--shadow);
}
.case-detail {
  position: sticky;
  top: 24px;
  min-height: 430px;
  padding: 20px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
}
.detail-field {
  padding: 12px;
  border-radius: 14px;
  background: #f8fafc;
}
.detail-field span {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 900;
  text-transform: uppercase;
}
.detail-field strong {
  display: block;
  margin-top: 4px;
  color: var(--navy);
}
.detail-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.note-box {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.timeline {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}
.timeline-item {
  padding-left: 12px;
  border-left: 3px solid #bfdbfe;
  color: #334155;
  font-size: .9rem;
}
.timeline-item small {
  display: block;
  color: var(--muted);
  font-size: .76rem;
}
.media-list {
  display: grid;
  gap: 8px;
}
.media-list a {
  color: var(--blue);
  font-weight: 850;
  text-decoration: none;
}
.integration-panel {
  max-width: 820px;
}
.code-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
}
.code-card span {
  color: var(--green);
  font-weight: 950;
}
.code-card code {
  overflow-wrap: anywhere;
  color: var(--navy);
}
.clean-list {
  display: grid;
  gap: 10px;
  padding-left: 20px;
  color: #334155;
}
.modal {
  width: min(760px, calc(100% - 24px));
  border: 0;
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(15, 23, 42, .38); }
.modal form { padding: 20px; }
.modal header, .modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.close-modal {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-height: 38px;
  padding: 0 12px;
  font-weight: 850;
}
.modal-grid {
  grid-template-columns: repeat(2, 1fr);
  margin: 18px 0;
}
.full { grid-column: 1 / -1; }
[hidden] { display: none !important; }

@media (max-width: 1020px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }
  .nav { grid-auto-flow: column; grid-auto-columns: max-content; }
  .ghost-button { margin-top: 0; margin-left: auto; }
  .kpi-grid, .dashboard-grid, .cases-layout { grid-template-columns: 1fr; }
  .case-detail { position: relative; top: auto; }
}

@media (max-width: 680px) {
  .content { padding: 18px; }
  .topbar, .top-actions, .sidebar { align-items: stretch; flex-direction: column; }
  .filters, .modal-grid, .detail-grid, .detail-actions { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .bar-chart { gap: 7px; }
}
