:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1c2330;
  --muted: #6b7482;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --green: #1a7f37;
  --green-soft: #e6f4ea;
  --red: #c62828;
  --red-soft: #fdecea;
  --amber: #9a6700;
  --amber-soft: #fff4d6;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1.25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .9rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
.muted { color: var(--muted); }
.d-block { display: block; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1.25rem .75rem;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); padding: 0 .75rem 1.25rem; }
.brand:hover { text-decoration: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: var(--text); padding: .55rem .75rem; border-radius: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.logout { margin-top: auto; padding: 0 .75rem; display: flex; justify-content: space-between; align-items: center; }
.content { flex: 1; padding: 2rem; max-width: 1100px; min-width: 0; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem; margin: 0; }
.badge { background: var(--red); color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 .45rem; font-weight: 600; line-height: 1.4rem; min-width: 1.4rem; text-align: center; }
.tag { display: inline-block; font-size: .75rem; padding: .05rem .5rem; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.tag-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.tag-red { background: var(--red-soft); color: var(--red); border-color: transparent; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .75rem; }
.flash-success { background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--red-soft); color: var(--red); }
.flash-warning { background: var(--amber-soft); color: var(--amber); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-size: .9rem; font-weight: 500; padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  list-style: none; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1a5fcc; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #a82020; }
.btn-danger-outline { color: var(--red); }
.btn-block { width: 100%; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

input, textarea, select {
  font: inherit; width: 100%; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; font-size: .9rem; margin-bottom: 1rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
.error { font-weight: 400; color: var(--red); font-size: .82rem; }
.has-error input, .has-error textarea { border-color: var(--red); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 0 .75rem .6rem; }
td { padding: .75rem; border-top: 1px solid var(--border); vertical-align: middle; }
.user { display: flex; flex-direction: column; gap: .1rem; }
.user .muted { font-size: .85rem; }

.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .45rem .9rem; border-radius: 8px; color: var(--muted); display: inline-flex; gap: .4rem; align-items: center; }
.tabs a:hover { background: var(--surface); text-decoration: none; }
.tabs a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.search { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search input { width: 240px; }
.pagination { display: flex; justify-content: center; gap: 1rem; align-items: center; margin: 1rem 0; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .2rem; color: var(--text); }
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value.accent { color: var(--red); }
.setup { border-color: #f0d58a; background: #fffcf2; }
.checklist { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .4rem; }
.checklist li::before { display: inline-block; width: 1.4rem; font-weight: 700; }
.checklist .done { color: var(--muted); }
.checklist .done::before { content: "✓"; color: var(--green); }
.checklist .todo::before { content: "○"; color: var(--amber); }

/* Payments */
.payments { display: grid; gap: 1rem; }
.payment { display: flex; gap: 1.25rem; margin: 0; }
.receipt-thumb { flex-shrink: 0; width: 150px; height: 200px; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); cursor: zoom-in; }
.receipt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.payment-body { flex: 1; min-width: 0; }
.payment dl { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: .9rem 0; font-size: .92rem; }
.payment dt { color: var(--muted); }
.payment dd { margin: 0; }
.actions { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }
.reject { flex: 1; min-width: 260px; }
.reject summary::-webkit-details-marker { display: none; }
.reject[open] summary { margin-bottom: .6rem; }
.reject form { display: grid; gap: .5rem; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { font: inherit; font-size: .8rem; padding: .2rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; }
.chip:hover { border-color: var(--muted); }
#lightbox { border: 0; border-radius: var(--radius); padding: 1rem; max-width: 92vw; max-height: 92vh; text-align: center; }
#lightbox::backdrop { background: rgba(10, 14, 20, .75); }
#lightbox img { max-width: 100%; max-height: calc(92vh - 5rem); display: block; margin: 0 auto .75rem; }

/* Subscribers */
.row-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
form.inline { display: flex; gap: .35rem; align-items: center; }
input.days { width: 72px; }

/* Settings */
.settings { max-width: 760px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.status-line { padding: .55rem .8rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.status-line.ok { background: var(--green-soft); color: var(--green); }
.status-line.bad { background: var(--amber-soft); color: var(--amber); }
.form-footer { position: sticky; bottom: 0; padding: .75rem 0; background: var(--bg); }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; padding: 2rem; }
.login-card h1 { margin-bottom: .25rem; }
.login-card p { margin-top: 0; margin-bottom: 1.5rem; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; padding: .75rem 16px; gap: .5rem; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 0 .5rem 0 0; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .logout { margin: 0 0 0 auto; gap: .75rem; }
  .content { padding: 1.25rem 16px; }
  .payment { flex-direction: column; }
  .receipt-thumb { width: 100%; height: 220px; }
  .grid-2 { grid-template-columns: 1fr; }
  table thead { display: none; }
  table tr { display: block; border-top: 1px solid var(--border); padding: .5rem 0; }
  table td { display: block; border: 0; padding: .3rem 0; }
  .right, .row-actions { text-align: left; justify-content: flex-start; }
  .search input { width: 100%; }
}
