:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --panel-alt: #f7fafc;
  --text: #16202a;
  --muted: #667085;
  --line: #d7dee7;
  --brand: #0f766e;
  --brand-soft: #d8f3ef;
  --blue: #1570ef;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.12), transparent 22rem),
    linear-gradient(180deg, #f6faf9 0%, var(--bg) 18rem);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.app-shell.auth-hidden {
  grid-template-columns: 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 18px;
  background: linear-gradient(180deg, #0b1723 0%, #122234 100%);
  color: #f8fbff;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.app-shell.auth-hidden .sidebar {
  display: none;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #10b981, #0ea5e9);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.86rem;
}

.sidebar-body {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-section {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  margin-top: 4px;
  padding-right: 6px;
}

.sidebar-label {
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  padding: 0 12px 10px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.sidebar-footer {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  gap: 12px;
}

.sidebar-user {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-user-label {
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-logout {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 14px 30px rgba(220, 38, 38, 0.22);
}

.sidebar-logout:hover {
  filter: brightness(1.05);
}

.nav-link {
  padding: 12px 14px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.88);
  transition: background-color 160ms ease, transform 160ms ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(2px);
}

.content-shell {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2vw, 2.5rem);
}

.topbar-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  color: var(--muted);
}

.page-view {
  display: grid;
  gap: 18px;
}

.page-view.login-view {
  display: block;
}

.hero {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(12, 74, 110, 0.92));
  color: white;
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-shell {
  min-height: calc(100vh - 120px);
  display: grid;
  grid-template-columns: minmax(360px, 520px) 1fr;
  border-radius: 32px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--panel);
}

.login-panel {
  padding: 36px 32px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfc 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-logo-badge {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, #0f766e, #0891b2);
}

.login-switch {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.login-switch .active-link,
.login-switch a {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
}

.login-switch .active-link {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: rgba(15, 118, 110, 0.25);
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.login-help {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.login-help a {
  color: var(--brand);
  font-weight: 600;
}

.login-side {
  position: relative;
  color: white;
  padding: 38px;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.16), transparent 20rem),
    linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(30, 64, 175, 0.92));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-side::after {
  content: "";
  position: absolute;
  inset: auto -80px -80px auto;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.login-side h2,
.login-side p {
  position: relative;
  z-index: 1;
}

.login-side p {
  color: rgba(255, 255, 255, 0.82);
  max-width: 44ch;
}

.login-links {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.login-links a {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
}

.hero p {
  max-width: 68ch;
  color: rgba(255, 255, 255, 0.82);
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.master-detail {
  grid-template-columns: minmax(320px, 0.95fr) minmax(340px, 1.15fr);
}

.card {
  background: var(--panel);
  border: 1px solid rgba(215, 222, 231, 0.95);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card.soft {
  background: var(--panel-alt);
}

.card h2,
.card h3,
.card h4,
.card p {
  margin-top: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.muted {
  color: var(--muted);
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.doc-stat-card {
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.doc-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: auto -32px -32px auto;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.26);
}

.stat-card .value {
  font-size: 2.2rem;
  font-weight: 800;
  margin: 6px 0;
}

.tone-green { background: linear-gradient(135deg, #16a34a, #0f766e); color: white; }
.tone-blue { background: linear-gradient(135deg, #2563eb, #0ea5e9); color: white; }
.tone-red { background: linear-gradient(135deg, #dc2626, #f97316); color: white; }
.tone-amber { background: linear-gradient(135deg, #d97706, #f59e0b); color: white; }

.search-row,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.input,
.button,
.tab-button {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  padding: 10px 12px;
}

.button {
  cursor: pointer;
  font-weight: 600;
  background: var(--brand);
  color: white;
  border-color: transparent;
}

.button.secondary {
  background: white;
  color: var(--text);
  border-color: var(--line);
}

.pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.pill.status-active {
  background: rgba(22, 163, 74, 0.14);
  color: #166534;
}

.pill.doc-missing {
  background: rgba(220, 38, 38, 0.12);
  color: #991b1b;
}

.pill.doc-pending {
  background: rgba(217, 119, 6, 0.12);
  color: #92400e;
}

.pill.doc-approved,
.pill.doc-draft {
  background: rgba(21, 112, 239, 0.1);
  color: #1d4ed8;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead th {
  color: var(--muted);
  background: #fbfcfe;
  font-size: 0.9rem;
}

tbody tr:hover {
  background: #f8fbfd;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 10px;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background-color 160ms ease;
}

.list-item:hover,
.list-item.active {
  border-color: rgba(21, 112, 239, 0.35);
  background: #f8fbff;
  transform: translateY(-1px);
}

.list-title {
  font-weight: 700;
}

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

.detail-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fbfdff;
}

.detail-box strong {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.chart-ring {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  margin: 0 auto 16px;
  position: relative;
}

.chart-ring::after {
  content: "";
  position: absolute;
  inset: 34px;
  background: white;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--line);
}

.chart-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  z-index: 1;
  font-weight: 800;
}

.legend {
  display: grid;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.analysis-list {
  display: grid;
  gap: 12px;
}

.analysis-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.tab-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab-button {
  cursor: pointer;
}

.tab-button.active {
  border-color: rgba(15, 118, 110, 0.3);
  background: var(--brand-soft);
  color: var(--brand);
}

.empty-state {
  padding: 26px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: #fbfcfe;
}

.toast {
  border-radius: 16px;
  padding: 14px 16px;
  font-weight: 600;
}

.toast.success {
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
}

.toast.error {
  background: rgba(220, 38, 38, 0.12);
  color: #991b1b;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .grid.cols-4,
  .grid.cols-3,
  .grid.master-detail {
    grid-template-columns: 1fr;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .content-shell {
    padding: 18px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .chart-ring {
    width: 200px;
    height: 200px;
  }
}
