:root {
  --ink: #1c2b3a;
  --ink-soft: #33465a;
  --bg: #f7f5f1;
  --card: #ffffff;
  --border: #e4e0d8;
  --accent: #e0a458;
  --accent-dark: #c98b36;
  --sage: #7fa69c;
  --sage-dark: #5f8880;
  --red: #c4574a;
  --red-soft: #f6e3e0;
  --text: #24303d;
  --text-muted: #667180;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 43, 58, 0.06), 0 4px 14px rgba(28, 43, 58, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--sage-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */

.topbar {
  background: var(--ink);
  color: #fff;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-logo { height: 28px; width: auto; display: block; }
.brand span { color: var(--accent); font-weight: 500; }
.brand:hover { text-decoration: none; opacity: 0.9; }

.mainnav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}
.mainnav a {
  color: rgba(255,255,255,0.72);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
}
.mainnav a:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,0.08); }
.mainnav a.active { color: #fff; background: rgba(255,255,255,0.14); }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  margin-left: 2px;
  vertical-align: middle;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
}
.user-link {
  color: rgba(255,255,255,0.85);
  padding: 6px 10px;
  border-radius: 8px;
}
.user-link:hover { color: #fff; background: rgba(255,255,255,0.08); text-decoration: none; }
.user-link.active { color: #fff; background: rgba(255,255,255,0.14); }
.logout-link { color: rgba(255,255,255,0.6); font-size: 0.85rem; }

/* ---------- Layout ---------- */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.auth-page {
  max-width: 420px;
  margin: 10vh auto;
  padding: 0 24px;
}
.login-logo { height: 64px; width: auto; margin-bottom: 16px; }

.auth-body {
  background: var(--ink);
  min-height: 100vh;
}
.auth-body .subtitle { color: rgba(255,255,255,0.65); }
.auth-body .card { box-shadow: 0 12px 40px rgba(0,0,0,0.35); }

h1 { font-size: 1.6rem; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 0 0 14px; }
.page-header { margin-bottom: 28px; }
.subtitle { color: var(--text-muted); margin: 0; }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.balance-card { padding: 18px; }
.balance-card .type-name { font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.balance-card .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.balance-card .remaining { font-size: 1.9rem; font-weight: 700; color: var(--ink); }
.balance-card .used { color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Forms ---------- */

.form-group { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; color: var(--ink-soft); }
input[type=text], input[type=password], input[type=email], input[type=date], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
textarea { min-height: 90px; resize: vertical; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.field-errors { color: var(--red); font-size: 0.82rem; margin-top: 4px; }

.duration-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.duration-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink-soft);
}
.duration-option input { width: auto; margin: 0; }
.duration-option:has(input:checked) {
  border-color: var(--accent);
  background: #fdf1de;
  color: var(--accent-dark);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #2b1c0a; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }
.btn-secondary { background: #fff; border: 1px solid var(--border); color: var(--ink); }
.btn-secondary:hover { background: #f2efe9; text-decoration: none; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #efd0cb; text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

/* ---------- Status pills (signature element) ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.pill-pending { background: #fdf1de; color: var(--accent-dark); }
.pill-approved { background: #e7f0ee; color: var(--sage-dark); }
.pill-rejected { background: var(--red-soft); color: var(--red); }
.pill-cancelled { background: #ececec; color: #767676; }

/* ---------- Flash messages ---------- */

.flash-stack { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 11px 16px; border-radius: 8px; font-size: 0.9rem; }
.flash-success { background: #e7f0ee; color: var(--sage-dark); }
.flash-error { background: var(--red-soft); color: var(--red); }
.flash-info { background: #eef1f5; color: var(--ink-soft); }

/* ---------- Empty states ---------- */

.empty-state { color: var(--text-muted); padding: 24px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- Calendar page ---------- */

#calendar { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.fc-event { border: none !important; border-radius: 999px !important; padding: 1px 6px !important; font-size: 0.78rem !important; }

/* ---------- Subscribe page ---------- */

.feed-url-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f2efe9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.85rem;
  word-break: break-all;
  margin: 10px 0 18px;
}
.steps { padding-left: 20px; color: var(--text-muted); line-height: 1.7; }
.steps li { margin-bottom: 4px; }

/* ---------- Admin sub-navigation ---------- */

.admin-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.admin-subnav a {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
}
.admin-subnav a:hover { color: var(--ink); background: #f2efe9; text-decoration: none; }
.admin-subnav a.active { color: var(--accent-dark); background: #fdf1de; }

/* ---------- Responsive / scrollable tables (e.g. weekly report) ---------- */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: -22px;
  padding: 22px;
}
.table-scroll table { min-width: 640px; }
.table-scroll th, .table-scroll td { white-space: nowrap; }
.table-scroll th:first-child, .table-scroll td:first-child {
  position: sticky;
  left: 0;
  background: var(--card);
  box-shadow: 1px 0 0 var(--border);
}

@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 12px; }
  .form-row { flex-direction: column; gap: 0; }
  .admin-subnav { gap: 2px; }
  .admin-subnav a { padding: 6px 10px; font-size: 0.82rem; }
}
