:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --text: #1f1d1a;
  --muted: #6d675f;
  --border: #e3dfd7;
  --accent: #c2410c;
  --accent-soft: #fde9dc;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --surface: #1f1d1a; --surface-2: #2a2824; --text: #f1eee8; --muted: #a59e93;
    --border: #3a3732; --accent: #fb8a4c; --accent-soft: #3d2315; --ok: #4ade80; --ok-soft: #12301d;
    --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #f87171; --bad-soft: #3b1616; --info: #93b4ff; --info-soft: #17254a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --surface: #1f1d1a; --surface-2: #2a2824; --text: #f1eee8; --muted: #a59e93;
  --border: #3a3732; --accent: #fb8a4c; --accent-soft: #3d2315; --ok: #4ade80; --ok-soft: #12301d;
  --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #f87171; --bad-soft: #3b1616; --info: #93b4ff; --info-soft: #17254a;
  --shadow: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: "Cairo", Tahoma, sans-serif; font-size: 15px; line-height: 1.6; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.loading { padding: 60px 16px; text-align: center; color: var(--muted); }

/* header */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.role { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text); font-weight: 600; }
.role.admin { background: var(--accent-soft); color: var(--accent); }
.role.editor { background: var(--info-soft); color: var(--info); }
.demo-bar { background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.demo-bar .topbar-inner { padding: 6px 16px; }
.demo-bar select { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; }

.tabs { max-width: 1280px; margin: 0 auto; padding: 0 16px; display: flex; gap: 4px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { font-size: 11px; background: var(--bad); color: #fff; border-radius: 99px; padding: 0 6px; margin-inline-start: 4px; }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }

/* buttons & inputs */
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea.input { min-height: 70px; resize: vertical; }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters .field { min-width: 140px; flex: 1 1 140px; }
.filters .field.search { flex: 2 1 220px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.bad .value { color: var(--bad); }
.stat.ok .value { color: var(--ok); }

/* table */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
table.events { width: 100%; border-collapse: collapse; font-size: 14px; }
table.events th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
table.events td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.events tr:last-child td { border-bottom: 0; }
table.events tbody tr { cursor: pointer; }
table.events tbody tr:hover { background: var(--surface-2); }
table.events tr.past td { opacity: .6; }
table.events tr.cancelled td { text-decoration: line-through; opacity: .5; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev-name { font-weight: 700; }
.sub { color: var(--muted); font-size: 12px; }
.missing { color: var(--warn); font-size: 12px; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); white-space: nowrap; font-weight: 600; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.brands { display: flex; flex-wrap: wrap; gap: 4px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* mobile cards instead of table */
.ev-cards { display: none; }
@media (max-width: 760px) {
  .table-wrap { display: none; }
  .ev-cards { display: grid; gap: 10px; }
  .ev-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; cursor: pointer; }
  .ev-card .row { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
  .ev-card .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
  .ev-card .money { margin-top: 6px; font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
}

/* calendar */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { margin: 0; font-size: 18px; min-width: 160px; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-inline-start: 1px solid var(--border); }
.cal .dow { font-size: 12px; color: var(--muted); padding: 6px; text-align: center; font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border); }
.cal .day { min-height: 104px; padding: 4px; border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 3px; }
.cal .day.other { background: var(--surface-2); }
.cal .day.other .d { opacity: .4; }
.cal .day.today .d { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; }
.cal .d { font-size: 12px; font-weight: 700; align-self: flex-start; }
.chip { font-size: 12px; line-height: 1.4; padding: 2px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; text-align: right; font-weight: 600; }
.chip.tentative { background: var(--warn-soft); color: var(--warn); }
.chip.done { background: var(--ok-soft); color: var(--ok); }
.chip.cancelled { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
@media (max-width: 760px) {
  .cal .day { min-height: 64px; }
  .chip { font-size: 10px; padding: 1px 3px; }
}

/* alerts */
.alert-group { margin-bottom: 18px; }
.alert-group h3 { font-size: 16px; margin: 0 0 8px; }
.alert { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.alert:last-child { border-bottom: 0; }
.alert:hover { background: var(--surface-2); }
.alert .what { flex: 1; }
.alert .icon { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.alert .icon.bad { background: var(--bad); }
.alert .icon.warn { background: var(--warn); }

/* activity */
.act { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.act:last-child { border-bottom: 0; }
.act .chg { font-size: 13px; color: var(--muted); margin-top: 2px; }
.act .chg s { opacity: .7; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 720px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.check-list { display: flex; flex-wrap: wrap; gap: 6px; }
.check-list label { display: inline-flex; gap: 4px; align-items: center; border: 1px solid var(--border); border-radius: 99px; padding: 2px 10px; cursor: pointer; font-size: 14px; color: var(--text); font-weight: 400; }
.check-list label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.form-error { color: var(--bad); font-size: 14px; margin-top: 8px; }
.calc { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; font-size: 14px; }

/* login */
.login { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.login .card { padding: 24px; display: grid; gap: 12px; }
.login h1 { margin: 0; font-size: 22px; }
.linkbtn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 14px; }

/* team */
.team-row { display: grid; grid-template-columns: 1.3fr 1.5fr 120px 90px auto; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.team-row:last-child { border-bottom: 0; }
@media (max-width: 760px) { .team-row { grid-template-columns: 1fr 1fr; } }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; z-index: 100; font-size: 14px; max-width: calc(100vw - 32px); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 18px; }