/* ---------------------------------------------------------------------
   Perks — a digital ledger. Crisp white ground, vivid teal accent. A
   serif for the wordmark and statement headers, a humanist sans for data.
   Deliberately a single light look, not a dark-mode-switching palette.
------------------------------------------------------------------------ */

:root {
  --bg: #f5fbfa;
  --surface: #ffffff;
  --surface-2: #eaf6f4;
  --border: #d7e9e6;
  --border-strong: #b7d9d4;
  --text: #0f2624;
  --text-dim: #4d6d6a;
  --text-faint: #85a3a0;
  --accent: #0d9488;
  --accent-soft: #d7f3ef;

  --pos: #16a34a;
  --pos-soft: #dcf5e3;
  --warn: #d97706;
  --warn-soft: #faead0;
  --neg: #dc2626;
  --neg-soft: #fae0de;
  --info: #4f46e5;
  --info-soft: #e6e4fb;
  --neutral: #6b8683;
  --neutral-soft: #eaf6f4;

  --shadow: 0 1px 2px rgba(15, 38, 36, 0.06), 0 4px 14px rgba(15, 38, 36, 0.06);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.serif {
  font-family: "Fraunces", Georgia, serif;
}

a {
  color: var(--accent);
}

button {
  font-family: inherit;
}

/* ---------------------------------- Login ---------------------------------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 700px 500px at 50% -10%, var(--accent-soft), transparent),
    var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 44px 40px 36px;
  width: 340px;
  text-align: center;
}

.login-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 18px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Fraunces", Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  box-shadow: 0 4px 18px -4px var(--accent);
}

.login-card h1 {
  margin: 0 0 4px;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -0.01em;
}

.login-sub {
  margin: 0 0 28px;
  color: var(--text-dim);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card input {
  padding: 12px 14px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-card button {
  padding: 12px 14px;
  border-radius: 7px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.login-card button:hover {
  opacity: 0.85;
}

.login-error {
  margin: 16px 0 0;
  color: var(--neg);
  font-size: 13px;
}

/* ---------------------------------- Shell ---------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 272px 1fr;
  min-height: 100vh;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Fraunces", Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.brand-name {
  font-family: "Fraunces", Georgia, serif;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.summary {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.summary-value {
  font-family: "Fraunces", Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.summary-value.is-warn {
  color: var(--warn);
}

.summary-label {
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: right;
  line-height: 1.3;
}

.filter-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-form-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 11px;
  color: var(--text-faint);
}

.field input[type="text"],
.field select {
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.field input[type="text"]:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
}

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

.btn-apply {
  flex: 1;
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-reset {
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

.btn-logout:hover {
  color: var(--text-dim);
}

/* ---------------------------------- Content ---------------------------------- */

.content {
  padding: 34px 40px 80px;
  max-width: 900px;
}

.empty {
  color: var(--text-dim);
  text-align: center;
  padding: 70px 0;
  font-size: 14px;
}

.ledger-sheet {
  margin-bottom: 22px;
}

.sheet-head {
  padding-bottom: 10px;
  border-bottom: 2px solid var(--text);
  margin-bottom: 2px;
}

.sheet-head-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.sheet-earn {
  margin: 5px 0 0;
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
}

.sheet-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.sheet-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 18px;
  font-weight: 500;
  margin: 0;
}

.sheet-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.sheet-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.progress-track {
  width: 64px;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--pos);
  border-radius: 3px;
}

.progress-label {
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sheet-empty {
  padding: 14px 2px;
  font-size: 12.5px;
  color: var(--text-faint);
  font-style: italic;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 18px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--border);
}

.row:last-child {
  border-bottom: none;
}

.row.is-resolved {
  opacity: 0.55;
}

.row-info {
  min-width: 0;
}

.row-name-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.row-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  text-decoration: none;
}

a.row-name {
  background-image: linear-gradient(var(--text-faint), var(--text-faint));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
}

a.row-name:hover {
  color: var(--accent);
  background-image: linear-gradient(var(--accent), var(--accent));
}

.row-desc {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  max-width: 56ch;
}

.tag-row {
  display: flex;
  gap: 6px;
  margin-top: 5px;
}

.tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--neutral-soft);
  color: var(--text-dim);
  white-space: nowrap;
}

.row-value {
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  min-width: 3.5em;
}

.row-value.is-empty {
  color: var(--text-faint);
  font-weight: 400;
}

.row-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.row-status.status-active { color: var(--info); }
.row-status.status-active .status-dot { background: var(--info); }
.row-status.status-expiring { color: var(--warn); }
.row-status.status-expiring .status-dot { background: var(--warn); }
.row-status.status-expired { color: var(--neg); }
.row-status.status-expired .status-dot { background: var(--neg); }
.row-status.status-used { color: var(--pos); }
.row-status.status-used .status-dot { background: var(--pos); }
.row-status.status-ongoing { color: var(--text-faint); }
.row-status.status-ongoing .status-dot { background: var(--text-faint); }
.row-status.status-autopay { color: var(--accent); }
.row-status.status-autopay .status-dot { background: var(--accent); }
.row-status.status-excluded { color: var(--text-faint); }
.row-status.status-excluded .status-dot { background: var(--text-faint); }

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-menu {
  position: relative;
}

.row-menu summary {
  list-style: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 15px;
  border: 1px solid transparent;
}

.row-menu summary::-webkit-details-marker {
  display: none;
}

.row-menu summary:hover {
  border-color: var(--border-strong);
  color: var(--text-dim);
}

.row-menu[open] summary {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  z-index: 10;
}

.menu-item {
  text-align: left;
  padding: 7px 9px;
  border-radius: 5px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}

.menu-item:hover {
  background: var(--surface-2);
}

.btn-toggle {
  font-size: 12px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-toggle:hover {
  border-color: var(--text-dim);
}

.btn-toggle.is-used {
  background: transparent;
  border-color: transparent;
  color: var(--text-faint);
}

.btn-toggle.is-used:hover {
  color: var(--text-dim);
}

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

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

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 26px 18px 60px;
  }

  .row {
    grid-template-columns: 1fr;
    row-gap: 8px;
  }

  .row-value,
  .row-status {
    text-align: left;
    justify-content: flex-start;
  }

  .sheet-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}
