/* ==========================================================================
   Ledger — SaaS Admin Dashboard Kit
   Design tokens
   ========================================================================== */

:root {
  /* Core palette */
  --ink: #101915;          /* app shell background, deep forest-black */
  --surface: #17221c;      /* sidebar / topbar surface */
  --surface-raised: #1e2b23; /* hovered/active surface */
  --paper: #f6f4ee;        /* light content background */
  --card: #ffffff;         /* card surface on light content */
  --line-dark: rgba(236, 231, 218, 0.12);
  --line-light: rgba(16, 25, 21, 0.09);

  --text-on-dark: #ece7da;
  --text-on-dark-dim: rgba(236, 231, 218, 0.6);
  --text-on-light: #16211b;
  --text-on-light-dim: rgba(22, 33, 27, 0.58);

  --accent: #d9a441;        /* gold — primary actions, highlights */
  --accent-ink: #3a2b09;    /* text on gold */
  --positive: #4fb3a9;      /* teal — growth, success */
  --negative: #e0674f;      /* coral — alerts, decline */

  --radius-sm: 6px;
  --radius-md: 10px;
  --font-display: "Fraunces", "Iowan Old Style", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text-on-light);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tnum { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */

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

.sidebar {
  background: var(--surface);
  color: var(--text-on-dark);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.01em;
}

.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-label {
  font-size: 12px;
  color: var(--text-on-dark-dim);
  padding: 8px 10px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-on-dark-dim);
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link svg { flex-shrink: 0; opacity: 0.85; }

.nav-link:hover { background: var(--surface-raised); color: var(--text-on-dark); }

.nav-link.active {
  background: var(--surface-raised);
  color: var(--text-on-dark);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--line-dark);
  padding-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--positive);
  color: #0d2320;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-footer-text { line-height: 1.3; }
.sidebar-footer-name { font-size: 13px; color: var(--text-on-dark); }
.sidebar-footer-role { font-size: 12px; color: var(--text-on-dark-dim); }

/* ---------- Main column ---------- */

.main { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line-light);
  gap: 20px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0;
}

.page-sub {
  font-size: 13px;
  color: var(--text-on-light-dim);
  margin: 2px 0 0;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  width: 280px;
  color: var(--text-on-light-dim);
  font-size: 13px;
}

.search input {
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  width: 100%;
  color: var(--text-on-light);
}

.topbar-actions { display: flex; align-items: center; gap: 14px; }

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  background: transparent;
  border-color: var(--line-light);
  color: var(--text-on-light);
}
.btn-ghost:hover { background: var(--card); }

.content {
  padding: 28px 32px 48px;
  flex: 1;
}

/* ---------- Cards & grid ---------- */

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line-light);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-on-light-dim);
  margin: 0 0 8px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0;
}

.stat-delta {
  font-size: 12.5px;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-delta.up { color: var(--positive); }
.stat-delta.down { color: var(--negative); }

.grid-main {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0;
}

.card-link {
  font-size: 12.5px;
  color: var(--text-on-light-dim);
  text-decoration: none;
}
.card-link:hover { color: var(--text-on-light); }

/* activity feed */
.feed { display: flex; flex-direction: column; gap: 14px; }
.feed-item { display: flex; gap: 10px; align-items: flex-start; }
.feed-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-top: 6px; flex-shrink: 0;
}
.feed-text { font-size: 13.5px; }
.feed-time { font-size: 12px; color: var(--text-on-light-dim); }

/* table */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  color: var(--text-on-light-dim);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-light);
}
td {
  padding: 13px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line-light);
}
tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.pill.active { background: rgba(79,179,169,0.15); color: #1c6f66; }
.pill.trial { background: rgba(217,164,65,0.18); color: #8a5f10; }
.pill.churned { background: rgba(224,103,79,0.15); color: #a53b26; }

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}

.filters { display: flex; gap: 8px; }
.filter-chip {
  border: 1px solid var(--line-light);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: var(--text-on-light-dim);
}
.filter-chip.active { background: var(--ink); color: var(--text-on-dark); border-color: var(--ink); }

/* ---------- Auth / login page ---------- */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-visual {
  background: var(--surface);
  color: var(--text-on-dark);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth-quote {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.35;
  max-width: 420px;
}

.auth-quote-by {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-on-dark-dim);
}

.auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.auth-form {
  width: 100%;
  max-width: 360px;
}

.auth-form h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 6px;
}

.auth-form p.lead {
  color: var(--text-on-light-dim);
  font-size: 14px;
  margin: 0 0 28px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-on-light-dim);
}
.field input, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-light);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: var(--card);
  color: var(--text-on-light);
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }

.auth-submit { width: 100%; justify-content: center; margin-top: 6px; }

.auth-foot {
  margin-top: 22px;
  font-size: 13px;
  color: var(--text-on-light-dim);
  text-align: center;
}

/* ---------- Settings ---------- */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }

.plan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-light);
}
.plan-row:last-child { border-bottom: none; }

/* ---------- Responsive ---------- */

.menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--line-light);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 25% 0 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .grid-main, .settings-grid, .form-row { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .search { width: 160px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
