:root {
  --bg0: #0f1410;
  --bg1: #1a221c;
  --bg2: #243028;
  --ink: #e8efe6;
  --muted: #9aab9c;
  --accent: #c4a35a;
  --accent-2: #6f9e7a;
  --danger: #d9786a;
  --line: rgba(232, 239, 230, 0.12);
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #2a3d30 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #3a3220 0%, transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 40%, #121810);
}

.shell { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.brand { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.brand span { color: var(--accent); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 0.75rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.as-of { margin: 0.5rem 0 0; }

.sync-banner {
  margin: 0 0 1rem; padding: 0.65rem 0.9rem; border-radius: 10px; font-size: 0.9rem;
  border: 1px solid var(--line);
}
.sync-banner.ok { background: rgba(111, 158, 122, 0.15); border-color: var(--accent-2); }
.sync-banner.warn { background: rgba(196, 163, 90, 0.12); border-color: var(--accent); color: var(--ink); }
.sync-banner.danger { background: rgba(217, 120, 106, 0.12); border-color: var(--danger); color: var(--ink); }
.hidden { display: none !important; }

.period-switch { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem; }
.period-switch button {
  border: 0; background: transparent; color: var(--muted); font: inherit; padding: 0.45rem 0.9rem;
  border-radius: 999px; cursor: pointer;
}
.period-switch button.active { background: var(--accent); color: #1a1508; font-weight: 600; }

.totals {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.85rem; margin: 1.25rem 0 1.75rem;
}
.totals article, .site-grid article {
  background: rgba(26, 34, 28, 0.72); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem;
  backdrop-filter: blur(8px);
}
.totals h2, .site-grid h3 { margin: 0; font-size: 0.85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.money { font-family: var(--mono); font-size: 1.55rem; margin: 0.35rem 0 0; font-weight: 600; }
.section-title { font-size: 1.05rem; margin: 0 0 0.75rem; }
.section-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; margin-bottom: 1.75rem; }
.site-grid article { cursor: pointer; transition: transform 0.18s ease, border-color 0.18s ease; }
.site-grid article:hover { transform: translateY(-2px); border-color: var(--accent-2); }
.site-grid article.active { border-color: var(--accent); }

.ticket-list { display: flex; flex-direction: column; gap: 0.45rem; }
.ticket {
  display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 1rem; align-items: center;
  padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(15, 20, 16, 0.55);
  cursor: pointer; transition: background 0.15s ease;
}
.ticket:hover { background: rgba(36, 48, 40, 0.85); }
.ticket .meta { font-size: 0.85rem; color: var(--muted); }
.ticket .amt { font-family: var(--mono); font-weight: 600; }
.pager { display: flex; align-items: center; gap: 0.5rem; }

button, .ghost {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line);
  background: var(--accent-2); color: #0f1410; padding: 0.55rem 0.9rem; font-weight: 600;
}
.ghost { background: transparent; color: var(--ink); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }

.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card {
  width: min(420px, 100%); padding: 1.75rem; border-radius: 18px; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(36,48,40,0.9), rgba(15,20,16,0.92));
}
.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
.auth-card form { display: grid; gap: 0.85rem; margin-top: 1.25rem; }
.auth-card label { display: grid; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }
.auth-card input {
  font: inherit; padding: 0.65rem 0.75rem; border-radius: 8px; border: 1px solid var(--line);
  background: #0f1410; color: var(--ink);
}
.error { color: var(--danger); min-height: 1.2em; margin: 0; }

dialog {
  border: 1px solid var(--line); border-radius: 16px; background: var(--bg1); color: var(--ink);
  width: min(560px, calc(100vw - 2rem)); padding: 0;
}
dialog::backdrop { background: rgba(0,0,0,0.55); }
.detail { padding: 1rem 1.1rem 1.2rem; }
.detail header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.preview-wrap { margin-top: 0.85rem; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.preview-wrap img { display: block; width: 100%; max-height: 320px; object-fit: contain; background: #000; }
.hidden { display: none !important; }

@media (max-width: 860px) {
  .totals { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .totals { grid-template-columns: 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
}
