:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #68737d;
  --line: #d7dee5;
  --panel: #ffffff;
  --bg: #f4f7f8;
  --soft: #ecf2f5;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --gold: #a15c07;
  --red: #b42318;
  --green: #167443;
  --blue: #2563eb;
  --shadow: 0 18px 50px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}

.side {
  background: #101820;
  color: #f6fafb;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e8562b;
  color: white;
  font-weight: 900;
}

.brand-title {
  font-weight: 800;
  font-size: 18px;
}

.brand-sub {
  color: #aebcc6;
  font-size: 12px;
  margin-top: 2px;
}

.mobile-only,
.mobile-scrim,
.mobile-tabbar {
  display: none;
}

.icon-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
}

.side .icon-btn {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 7px;
  background: transparent;
  color: #c9d4db;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.side-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: #aebcc6;
  font-size: 12px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 68px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.topbar-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.content {
  padding: 22px 24px 36px;
  display: grid;
  gap: 18px;
}

.band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.band-pad {
  padding: 18px;
}

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

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

.stat {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat .value {
  font-size: 28px;
  font-weight: 850;
  line-height: 1;
}

.stat .label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar h2,
.panel-title {
  margin: 0;
  font-size: 16px;
}

.toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.btn {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn.danger {
  background: #fff1f0;
  border-color: #ffc9c3;
  color: var(--red);
}

.btn.ghost {
  background: transparent;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: #f8fafb;
}

.status,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
  background: var(--soft);
  color: var(--muted);
}

.pill.high {
  color: var(--red);
  background: #fff1f0;
}

.pill.medium {
  color: var(--gold);
  background: #fff8e6;
}

.pill.low,
.pill.digest {
  color: var(--blue);
  background: #edf4ff;
}

.pill.on {
  color: var(--green);
  background: #eaf8ef;
}

.pill.off {
  color: var(--muted);
  background: #eef1f3;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-weight: 800;
  font-size: 12px;
  color: #3f4b54;
}

.field small {
  color: var(--muted);
  line-height: 1.4;
}

.input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.45;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: var(--bg);
}

.login-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 18px;
}

.login-panel .brand {
  justify-content: center;
}

.login-panel .brand-sub {
  color: var(--muted);
}

.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f6f8;
}

.auth-tabs button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(23, 32, 38, 0.08);
}

.login-copy {
  display: grid;
  gap: 6px;
  text-align: center;
}

.login-copy h1 {
  font-size: 26px;
  line-height: 1.15;
  margin: 0;
}

.login-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.login-submit {
  width: 100%;
  min-height: 44px;
}

.google-btn {
  min-height: 44px;
  border-radius: 7px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  color: #1f2933;
  border: 1px solid #cfd8df;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.google-btn:hover {
  background: #f8fafb;
}

.google-mark {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
}

.setup-box {
  border: 1px solid var(--line);
  background: #f9fbfc;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.notice {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #ffd9a8;
  background: #fff8e8;
  color: #6f4100;
  font-size: 13px;
}

.error {
  color: var(--red);
  font-weight: 700;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  background: #eef2f4;
  border-radius: 6px;
  padding: 8px;
  overflow-wrap: anywhere;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 32, 0.54);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal {
  width: min(980px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: #fff;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  background: #101820;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  max-width: 340px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .shell {
    display: block;
  }

  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 310px);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    padding: 18px;
    box-shadow: 18px 0 60px rgba(16, 24, 32, 0.22);
  }

  .shell.nav-open .side {
    transform: translateX(0);
  }

  .mobile-scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(16, 24, 32, 0.34);
  }

  .shell.nav-open .mobile-scrim {
    display: block;
  }

  .mobile-only {
    display: inline-grid;
  }

  .nav button {
    min-height: 48px;
    font-size: 15px;
  }

  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
  }

  .mobile-tabbar button {
    min-width: 0;
    border-radius: 8px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 2px;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
  }

  .mobile-tabbar button span:first-child {
    font-size: 18px;
    line-height: 1;
  }

  .mobile-tabbar button.active {
    background: #e9f5f3;
    color: var(--accent-strong);
  }

  .content {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .stats,
  .form-grid,
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar,
  .content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    min-height: 62px;
    align-items: center;
    flex-direction: row;
    gap: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .topbar-title {
    flex: 1;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar p {
    display: none;
  }

  .user {
    max-width: 48%;
    justify-content: flex-end;
  }

  .user strong,
  .user .brand-sub {
    display: none;
  }

  .avatar {
    width: 36px;
    height: 36px;
  }

  .user .btn {
    min-height: 36px;
    padding: 0 8px;
    font-size: 12px;
  }

  .content {
    gap: 14px;
    padding-top: 14px;
  }

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

  .stat {
    padding: 13px;
  }

  .stat .value {
    font-size: 24px;
  }

  .band-pad {
    padding: 14px;
  }

  .toolbar {
    align-items: flex-start;
  }

  .actions,
  .actions .btn,
  .toolbar > .btn,
  .toolbar > .actions {
    width: 100%;
  }

  .actions .btn,
  .toolbar > .btn {
    min-height: 44px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tr {
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
  }

  tr:last-child {
    border-bottom: 0;
  }

  td {
    border-bottom: 0;
    padding: 8px 12px;
  }

  td[data-label] {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
  }

  td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
  }

  td[data-label="Lead"],
  td[data-label="Name"] {
    grid-template-columns: 1fr;
  }

  td[data-label="Lead"]::before,
  td[data-label="Name"]::before {
    display: none;
  }

  td[data-label="Actions"] {
    grid-template-columns: 1fr;
  }

  td[data-label="Actions"]::before {
    display: none;
  }

  td[data-label="Actions"] .btn {
    width: 100%;
    min-height: 44px;
  }

  .form-grid {
    gap: 12px;
  }

  .input,
  textarea,
  select {
    min-height: 44px;
  }

  .login-screen {
    padding: 18px;
  }

  .login-panel {
    gap: 14px;
  }

  .login-card {
    padding: 18px;
  }

  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }

  .modal {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-header {
    padding: 12px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    max-width: none;
  }
}

@media (max-width: 380px) {
  .topbar {
    padding-left: 8px;
    padding-right: 8px;
  }

  .content {
    padding-left: 8px;
    padding-right: 8px;
  }

  .user .btn {
    font-size: 0;
    width: 38px;
  }

  .user .btn::before {
    content: "↪";
    font-size: 18px;
  }
}
