:root {
  --bg: #0f1a14;
  --bg-2: #16251c;
  --card: #1c2e23;
  --text: #f1f5f0;
  --muted: #a8b8ae;
  --accent: #7bd389;
  --accent-2: #4fa864;
  --gold: #f0c05a;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Home page ---------- */

.hero {
  position: relative;
  width: 100%;
  height: 56vh;
  min-height: 320px;
  max-height: 640px;
  overflow: hidden;
  background: linear-gradient(135deg, #1d3a2a, #0f1a14);
}

.hero-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  display: block;
}

/* Tasos standing in the alley */
.tasos-wrap {
  position: absolute;
  left: 50%;
  bottom: 4%;
  height: 78%;
  transform: translateX(-50%);
  animation: sway 4s ease-in-out infinite;
  z-index: 2;
}

.tasos {
  height: 100%;
  width: auto;
  display: block;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35));
  animation: hop 0.7s cubic-bezier(.4,0,.2,1) infinite;
  transform-origin: 50% 100%;
}

.tasos-shadow {
  position: absolute;
  left: 50%;
  bottom: -2%;
  width: 55%;
  height: 6%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.45), rgba(0,0,0,0) 70%);
  animation: shadow 0.7s cubic-bezier(.4,0,.2,1) infinite;
  z-index: -1;
}

/* Mario-style hop: squash on landing, stretch at take-off */
@keyframes hop {
  0%   { transform: translateY(0) scale(1.04, 0.96); }
  25%  { transform: translateY(-10%) scale(0.98, 1.03); }
  50%  { transform: translateY(-14%) scale(1, 1); }
  75%  { transform: translateY(-6%) scale(0.99, 1.02); }
  100% { transform: translateY(0) scale(1.04, 0.96); }
}

@keyframes shadow {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: .9; }
  50%      { transform: translateX(-50%) scale(0.7); opacity: .45; }
}

/* gentle left-right drift */
@keyframes sway {
  0%, 100% { transform: translateX(calc(-50% - 6vw)); }
  50%      { transform: translateX(calc(-50% + 6vw)); }
}

@media (prefers-reduced-motion: reduce) {
  .tasos, .tasos-wrap, .tasos-shadow { animation: none; }
}

.hero::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 45%;
  background: linear-gradient(to bottom, rgba(15,26,20,0), var(--bg));
  pointer-events: none;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px 48px;
  text-align: center;
}

.brand {
  margin: 0 0 4px;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  letter-spacing: 0.5px;
}

.subtitle {
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 1.05rem;
}

.users {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 260px));
  gap: 20px;
  width: 100%;
  max-width: 560px;
  justify-content: center;
}

.user-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  font: inherit;
}

.user-card:hover, .user-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: #213628;
  outline: none;
}

.avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 700;
  color: #0f1a14;
  background: var(--accent);
}

.avatar.gold { background: var(--gold); }

.user-card .name { font-size: 1.25rem; font-weight: 600; }
.user-card .hint { color: var(--muted); font-size: 0.9rem; }
.user-card.picked { border-color: var(--accent); background: #213628; }

.login {
  margin-top: 24px;
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: left;
}
.login-title { margin: 0 0 12px; font-weight: 600; }
.login-row { display: flex; gap: 10px; flex-wrap: wrap; }
.login-row input {
  flex: 1 1 180px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
.login-row input:focus { outline: none; border-color: var(--accent); }
.login-err { margin: 10px 0 0; color: #f08a8a; min-height: 1.2em; font-size: 0.9rem; }
.login.busy { opacity: 0.6; pointer-events: none; }

.dialog {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(420px, calc(100vw - 32px));
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog h3 { margin: 0 0 16px; }
.dialog .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 0.9rem; color: var(--muted); }
.dialog .field input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
.dialog .field input:focus { outline: none; border-color: var(--accent); }
.dialog .actions { display: flex; gap: 10px; margin-top: 8px; }
.pw-ok { display: none; margin: 0 0 12px; color: var(--accent); font-weight: 600; }
.dialog .form.done .field, .dialog .form.done .login-err, .dialog .form.done #pw-save { display: none; }
.dialog .form.done .pw-ok { display: block; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 12px;
}

@media (max-width: 420px) {
  .users { grid-template-columns: 1fr; }
  .hero { height: 44vh; }
}

/* ---------- Inner page ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.topbar .who {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.topbar .who .avatar { width: 36px; height: 36px; font-size: 1rem; }

.topbar a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.topbar a:hover { color: var(--text); }

.tabs {
  display: flex;
  gap: 8px;
  padding: 16px 20px 0;
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font: inherit;
}
.tab.active { background: var(--accent); color: #0f1a14; border-color: var(--accent); font-weight: 600; }

.panel {
  margin: 20px;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 200px;
}

.panel h2 { margin: 0; font-size: 1.3rem; }
.panel h3 { margin: 0 0 12px; font-size: 1.05rem; }
.panel p { color: var(--muted); }
body.app .panel { margin: 16px 20px 40px; padding: 20px; }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 0.9em; }

/* buttons */
.btn {
  background: #243b2d;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #0f1a14; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: #8fe09c; }
.btn.danger { color: #ff9a9a; }
.btn.danger:hover { border-color: #ff6b6b; }
.btn.small { padding: 5px 10px; font-size: 0.85rem; }
.icon {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; padding: 4px 6px; border-radius: 6px; font-family: inherit;
}
.icon:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* toolbar */
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar h2 { margin-right: auto; }
.toolbar select, .form select, .form input, .form textarea {
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font: inherit; font-size: 0.95rem;
}
.toolbar select:focus, .form select:focus, .form input:focus, .form textarea:focus { outline: none; border-color: var(--accent); }
.form select option, .form select optgroup { background: var(--bg-2); color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 0.85rem; }
.chip.active { background: var(--accent); color: #0f1a14; border-color: var(--accent); font-weight: 600; }

/* tiles */
.tiles { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tile { background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; min-width: 130px; display: flex; flex-direction: column; gap: 2px; }
.tile .v { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.tile.small .v { font-size: 1.1rem; color: var(--text); }
.tile .l { font-size: 0.8rem; color: var(--muted); }

/* forms */
.form { background: var(--bg-2); border: 1px solid var(--accent-2); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.form .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.form .grid.one { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
.field.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.field.check input { width: auto; }
.form .actions, .note .actions { display: flex; gap: 8px; margin-top: 12px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: 9px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table th { background: var(--bg-2); color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.4px; position: sticky; top: 0; }
.table tbody tr:hover { background: rgba(255,255,255,0.03); }
.table tr.dim td { color: var(--muted); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--bg-2); }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }
.row-actions { white-space: nowrap; text-align: right; }
.table.raw td { font-size: 0.85rem; border-right: 1px solid var(--border); white-space: pre-wrap; min-width: 60px; }
.table.raw tr.hdr td { font-weight: 700; background: var(--bg-2); }

.badge { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 0.75rem; font-weight: 600; background: #2c3f33; color: var(--muted); }
.badge.confirmed { background: #1f4d2e; color: var(--accent); }
.badge.open { background: #4d3f1f; color: var(--gold); }
.badge.done { background: #26323a; color: #9ec5e8; }
.badge.cancelled { background: #4a2626; color: #ff9a9a; }

/* archive */
.archive { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
.archive-list { border: 1px solid var(--border); border-radius: 12px; padding: 8px; max-height: 70vh; overflow-y: auto; background: var(--bg-2); }
.archive-list details { margin-bottom: 4px; }
.archive-list summary { cursor: pointer; padding: 6px 8px; font-weight: 600; border-radius: 8px; }
.archive-list summary:hover { background: rgba(255,255,255,0.05); }
.archive-item { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--muted); padding: 6px 8px 6px 20px; cursor: pointer; font: inherit; font-size: 0.9rem; border-radius: 8px; }
.archive-item:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.archive-item.active { color: #0f1a14; background: var(--accent); font-weight: 600; }
.archive-view { min-width: 0; }
.archive-view .table-wrap { max-height: 70vh; overflow: auto; }
@media (max-width: 760px) { .archive { grid-template-columns: 1fr; } .archive-list { max-height: 30vh; } }

/* notes */
.notes { display: flex; flex-direction: column; gap: 10px; }
.note { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px 14px; }
.note.pinned { border-color: var(--accent-2); }
.note summary { cursor: pointer; padding: 10px 0; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-weight: 600; }
.note summary .muted { font-weight: 400; font-size: 0.82rem; }
.note pre { white-space: pre-wrap; font: inherit; line-height: 1.55; margin: 4px 0 8px; color: var(--text); }
.note .actions { margin: 0 0 10px; }
