:root {
  --navy: #061832;
  --navy-2: #0d274a;
  --blue: #2164d7;
  --blue-2: #174da8;
  --sky: #eaf2ff;
  --ink: #0c1b33;
  --muted: #65748b;
  --line: #d9e2ef;
  --panel: #ffffff;
  --bg: #f3f6fb;
  --success: #147444;
  --warning: #a05d00;
  --danger: #b42318;
  --purple: #6a3cc2;
  --shadow: 0 18px 45px rgba(9, 30, 66, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

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

.sidebar {
  background: linear-gradient(180deg, var(--navy), #081c3c);
  color: #fff;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 6px 4px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
}

.brand-logo-block {
  display: block;
}

.brand-logo {
  width: 100%;
  max-width: 230px;
  display: block;
  border-radius: 12px;
  background: #fff;
  padding: 8px 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
}

.brand-logo-block .brand-subtitle {
  margin-top: 10px;
  padding-left: 4px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: radial-gradient(circle at 25% 20%, #fff, #7fb0ff 34%, var(--blue) 35%, #0a2a58 100%);
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
}

.brand-title { font-size: 21px; font-weight: 850; line-height: 1; }
.brand-subtitle { font-size: 11px; color: rgba(255,255,255,.7); margin-top: 5px; }

.tenant-card {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 14px;
}

.tenant-card label {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,.72);
  margin-bottom: 8px;
}

.field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(33,100,215,.12); }

.nav-list { display: flex; flex-direction: column; gap: 6px; }

.nav-item {
  color: rgba(255,255,255,.76);
  background: transparent;
  border: 0;
  border-radius: 12px;
  padding: 12px 13px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: .18s ease;
}

.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: #fff; color: var(--navy); font-weight: 800; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.14);
}

.main { padding: 28px 34px 44px; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 22px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(28px, 3vw, 42px); line-height: 1.1; letter-spacing: -0.03em; }
h2 { font-size: 22px; letter-spacing: -0.015em; }
h3 { font-size: 16px; }

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

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 15px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
}

.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-2); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn.danger { background: #ffe9e6; color: var(--danger); }
.btn.success { background: #e7f7ef; color: var(--success); }
.btn.full { width: 100%; }

.icon-btn {
  border: 0;
  background: #f0f4fa;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 22px;
  color: var(--ink);
}

.alert-bar {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 14px;
  padding: 13px 16px;
  margin-bottom: 22px;
  color: #20314d;
}

.view-mount { display: grid; gap: 22px; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.main-split { grid-template-columns: minmax(0, 1.45fr) minmax(310px, .75fr); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 rgba(13,39,74,.02);
  padding: 18px;
  min-width: 0;
}

.card.lift { box-shadow: var(--shadow); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.card-title { font-size: 18px; font-weight: 850; }
.card-subtitle { color: var(--muted); font-size: 13px; margin-top: 5px; }

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-height: 126px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-value { font-size: 34px; font-weight: 900; letter-spacing: -0.05em; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat-trend { font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  padding: 5px 9px;
  white-space: nowrap;
}
.pill.sent { background: #eaf2ff; color: #174da8; }
.pill.pending { background: #fff4d6; color: #7a4d00; }
.pill.agreed, .pill.safe { background: #e7f7ef; color: var(--success); }
.pill.disagreed { background: #ffe9e6; color: var(--danger); }
.pill.scanner { background: #efe8ff; color: var(--purple); }
.pill.neutral { background: #eef2f7; color: #42526e; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 12px 11px; border-bottom: 1px solid #e9eef6; vertical-align: top; }
th { color: #536179; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; background: #f8fafd; }
td { font-size: 14px; }
tr:hover td { background: #fafcff; }

.row-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.link-btn {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar .field { max-width: 280px; }

.notice-preview {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 18px;
  background: #fff;
  line-height: 1.55;
}
.notice-preview .letterhead {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 14px;
  color: var(--navy);
  font-weight: 900;
}

.segment-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
}
.segment-number { font-size: 28px; font-weight: 900; letter-spacing: -.04em; }
.segment-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.progress {
  width: 100%;
  height: 12px;
  background: #e9eef6;
  border-radius: 999px;
  overflow: hidden;
}
.progress span { display: block; height: 100%; background: var(--blue); border-radius: inherit; }

.audit-timeline { display: grid; gap: 12px; }
.audit-item { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.audit-time { color: var(--muted); font-size: 12px; font-weight: 800; }

.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-group label { display: block; font-size: 13px; font-weight: 850; margin-bottom: 7px; }
textarea.field { min-height: 150px; resize: vertical; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 24, 50, .58);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}
.modal {
  width: min(880px, 100%);
  max-height: min(90vh, 900px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.modal-header, .modal-footer { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
.modal-body { padding: 20px; overflow-y: auto; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--navy);
  color: #fff;
  padding: 13px 16px;
  border-radius: 13px;
  box-shadow: var(--shadow);
  font-weight: 800;
  z-index: 30;
}

.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.4; }
.text-right { text-align: right; }
.stack { display: grid; gap: 12px; }
.spacer { height: 8px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .nav-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.main-split, .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
}

@media (max-width: 620px) {
  .main { padding: 22px 16px 34px; }
  .nav-list { grid-template-columns: 1fr; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; }
  .form-grid.two { grid-template-columns: 1fr; }
  .audit-item { grid-template-columns: 1fr; }
}
