:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --surface-3: #edf4f1;
  --text: #17211f;
  --muted: #64716d;
  --line: #dbe4e1;
  --line-strong: #b8c7c2;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #b7791f;
  --info: #315f8a;
  --danger: #b42318;
  --success: #17663a;
  --sidebar: #111b19;
  --sidebar-soft: #1b2926;
  --shadow: 0 16px 34px rgba(23, 33, 31, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: var(--sidebar);
  color: #f5fbf9;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

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

.brand:hover {
  text-decoration: none;
}

.brand strong,
.brand small,
.user-pill span,
.user-pill small,
.metric strong,
td,
.secret-box code {
  overflow-wrap: anywhere;
}

.brand small {
  display: block;
  color: #aebbb7;
  margin-top: 3px;
  font-size: 0.82rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: #eef7f4;
  color: #0f513e;
  font-weight: 900;
  border: 1px solid #c8ded6;
  flex: 0 0 auto;
}

.brand-mark.large {
  width: 60px;
  height: 60px;
  font-size: 1.15rem;
}

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

.nav a,
.logout-form .button {
  color: #dce7e4;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
}

.nav a {
  border: 1px solid transparent;
}

.nav a:hover,
.nav a.active {
  background: var(--sidebar-soft);
  color: #fff;
  text-decoration: none;
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-status {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-status strong,
.sidebar-status small {
  display: block;
}

.sidebar-status small {
  margin-top: 2px;
  color: #aebbb7;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  flex: 0 0 auto;
  background: var(--line-strong);
}

.status-dot.online {
  background: #4ade80;
}

.status-dot.offline {
  background: #f59e0b;
}

.logout-form {
  margin-top: 0;
}

.main {
  min-width: 0;
  padding: 30px;
}

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

.topbar h1,
.login-copy h1,
h2,
h3 {
  margin: 0;
  line-height: 1.14;
}

.topbar h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1rem;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 900;
}

.user-pill {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  box-shadow: 0 6px 16px rgba(23, 33, 31, 0.04);
  min-width: 180px;
  max-width: 320px;
}

.user-pill span,
.user-pill small {
  display: block;
}

.user-pill small {
  margin-top: 3px;
  color: var(--muted);
}

.surface,
.metric,
.flash {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.surface {
  padding: 22px;
  margin-bottom: 22px;
}

.surface.narrow {
  max-width: 620px;
}

.surface.wide {
  max-width: 1120px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

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

.metric {
  padding: 18px;
  display: grid;
  gap: 7px;
  min-height: 126px;
  align-content: start;
}

.metric span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  font-size: 1.7rem;
  line-height: 1.12;
}

.metric small {
  color: var(--muted);
  line-height: 1.35;
}

.metric strong.small-value {
  font-size: 1.05rem;
  line-height: 1.25;
}

.metric-primary {
  border-color: #badbd5;
  background: #f4fbf9;
}

.metric.warning strong {
  color: var(--accent);
}

.section-head,
.client-hero,
.account-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.client-hero,
.account-hero {
  align-items: center;
}

.section-note {
  margin: -4px 0 2px;
  color: var(--muted);
  line-height: 1.45;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th {
  text-align: left;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

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

tbody tr:hover {
  background: var(--surface-2);
}

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

.table-action {
  font-weight: 900;
  white-space: nowrap;
}

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: #24413b;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: capitalize;
  white-space: nowrap;
}

.status.active {
  background: #e5f8ed;
  color: var(--success);
}

.status.pending,
.status.draft {
  background: #fff4d8;
  color: #7a4b00;
}

.status.paused {
  background: #eaf2fb;
  color: var(--info);
}

.status.past_due,
.status.canceled,
.status.archived {
  background: #fff0ee;
  color: var(--danger);
}

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

.grid-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
}

.form-section,
.stacked {
  display: grid;
  gap: 14px;
  align-content: start;
}

.stacked {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.form-title {
  display: grid;
  gap: 5px;
  margin-bottom: 2px;
}

.form-title p {
  margin: 0;
}

label {
  display: grid;
  gap: 7px;
  color: #2f3d39;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  min-height: 42px;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--primary);
}

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

.checkbox input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

.button,
.link-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover,
.link-button:hover {
  text-decoration: none;
  border-color: var(--primary);
}

.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.ghost {
  width: 100%;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
  color: #f5fbf9;
}

.button.ghost:hover {
  background: var(--sidebar-soft);
}

.link-button {
  border: 0;
  min-height: 0;
  padding: 0;
  color: var(--primary-dark);
  background: transparent;
  white-space: nowrap;
}

.button-row,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-control {
  width: auto;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 8px;
}

.flash {
  padding: 16px 18px;
  margin-bottom: 18px;
  border-left: 4px solid var(--primary);
}

.flash.error {
  border-left-color: var(--danger);
}

.flash p {
  margin: 4px 0 0;
  color: var(--muted);
}

.secret-box {
  margin-top: 12px;
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fbfa;
  border: 1px dashed var(--line-strong);
}

.secret-box span {
  color: var(--muted);
  font-weight: 800;
}

.secret-box code {
  font-size: 1rem;
}

.empty-state {
  display: grid;
  gap: 8px;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
}

.empty-state.compact {
  padding: 16px;
  margin-bottom: 18px;
}

.empty-state strong {
  font-size: 1rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.error-panel {
  display: grid;
  gap: 16px;
}

.error-panel p {
  margin-bottom: 0;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf3f0;
}

.login-panel {
  width: min(940px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 22px;
  align-items: stretch;
}

.login-copy {
  padding: 36px;
  background: var(--sidebar);
  color: #fff;
  border-radius: 8px;
  display: grid;
  align-content: center;
  gap: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-copy .eyebrow {
  color: #9fd2c8;
}

.login-copy h1 {
  font-size: 2rem;
}

.login-copy p {
  color: #c7d2cf;
  max-width: 420px;
  margin: 0;
  line-height: 1.5;
}

.login-panel .surface {
  margin-bottom: 0;
  align-content: center;
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

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

  .nav a {
    text-align: center;
  }

  .sidebar-status {
    margin-top: 0;
  }

  .metrics,
  .metrics.compact,
  .two-column,
  .grid-form,
  .login-panel {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 0;
  }
}

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

  .topbar,
  .section-head,
  .client-hero,
  .account-hero {
    flex-direction: column;
  }

  .topbar h1,
  .login-copy h1 {
    font-size: 1.55rem;
  }

  .user-pill {
    min-width: 0;
    width: 100%;
  }

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

  .button-row,
  .form-actions {
    justify-content: flex-start;
  }

  .button,
  .button-row form,
  .button-row .button,
  .form-actions .button {
    width: 100%;
  }

  .table-wrap table {
    min-width: 560px;
  }

  .inline-form {
    align-items: flex-start;
  }

  .login-copy,
  .surface {
    padding: 18px;
  }
}

@media (max-width: 460px) {
  .auth-page {
    padding: 14px;
  }

  .sidebar {
    gap: 16px;
  }

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

  .metrics {
    gap: 10px;
  }

  table {
    min-width: 520px;
  }
}
