/* Resort Tracker — mobile-first ops console. Brand: deep indigo #191443. */

:root {
  --brand: #191443;
  --brand-2: #2b2560;
  --brand-hover: #39316f;
  --fill: #edecf3;       /* subtle indigo-tinted fill */
  --fill-2: #f7f7fb;
  --bg: #f4f4f7;
  --card: #ffffff;
  --ink: #1c1830;        /* near-brand ink for text */
  --ink-soft: #625d78;
  --line: #e3e1ec;
  --line-strong: #cfccdd;

  /* Functional status colors — kept clearly distinct from the indigo brand. */
  --fresh: #1f9d55;
  --fresh-fill: #e7f5ec;
  --stale: #c67c00;
  --stale-fill: #fbf1dd;
  --missing: #cf2f34;
  --missing-fill: #fbe6e6;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(25, 20, 67, 0.06), 0 2px 8px rgba(25, 20, 67, 0.05);
}

* { box-sizing: border-box; }

/* Enforce the hidden attribute globally */
[hidden] { 
  display: none !important; 
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

/* ---------- Login ---------- */
.login-overlay {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #191443, #2b2560);
  padding: 20px;
  z-index: 1000;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  display: flex; flex-direction: column; gap: 10px;
}
.login-brand { font-size: 22px; font-weight: 700; color: var(--brand); margin-bottom: 8px; }
.login-card label { font-size: 13px; color: var(--ink-soft); }
.login-card input {
  padding: 12px; font-size: 16px;
  border: 1px solid var(--line-strong); border-radius: 10px;
}
.login-card input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.login-card button {
  margin-top: 6px; padding: 12px; font-size: 16px; font-weight: 600;
  background: var(--brand); color: #fff; border: none; border-radius: 10px; cursor: pointer;
}
.login-card button:hover { background: var(--brand-hover); }
.login-error { color: var(--missing); font-size: 14px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 500;
  display: flex; align-items: center; gap: 12px;
  background: var(--brand); color: #fff;
  padding: 0 14px; height: 54px;
  padding-top: env(safe-area-inset-top);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 5px;
  background: #fff;
  -webkit-mask: radial-gradient(circle at 50% 42%, transparent 5px, #000 6px 7px, transparent 8px), linear-gradient(#000,#000) 50% 70%/3px 12px no-repeat;
  mask: radial-gradient(circle at 50% 42%, transparent 5px, #000 6px 7px, transparent 8px);
  background: #b9b4dd;
  display: inline-block;
}
.nav {
  display: flex; gap: 2px; margin-left: 6px;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
  flex: 1;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: #c9c5e6; padding: 8px 12px; border-radius: 8px;
  font-size: 15px; white-space: nowrap; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,0.16); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--missing); box-shadow: 0 0 0 3px rgba(255,255,255,0.12);
}
.live-dot.on { background: var(--fresh); }
.link-btn {
  background: transparent; color: #c9c5e6; border: 1px solid rgba(255,255,255,0.25);
  padding: 6px 10px; border-radius: 8px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.link-btn:hover { color: #fff; border-color: rgba(255,255,255,0.5); }

/* ---------- Layout ---------- */
main { padding: 14px; max-width: 1100px; margin: 0 auto; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.view-head h1 { font-size: 20px; margin: 0; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 0.86em; }

.search {
  width: 100%; padding: 11px 12px; font-size: 16px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card);
  margin-bottom: 12px;
}
.search:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

/* Cards */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--fill-2);
}
.card-head h2 { font-size: 15px; margin: 0; }
.card-body { padding: 6px 6px; }
.count-badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Item rows */
.item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px; border-radius: 8px;
}
.item + .item { border-top: 1px solid var(--line); }
.item .name { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* Freshness dot + pill */
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.fresh { background: var(--fresh); }
.dot.stale { background: var(--stale); }
.dot.missing { background: var(--missing); }
.pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 999px;
}
.pill.fresh { color: var(--fresh); background: var(--fresh-fill); }
.pill.stale { color: var(--stale); background: var(--stale-fill); }
.pill.missing { color: var(--missing); background: var(--missing-fill); }

/* Missing banner section */
.missing-section {
  border: 1px solid var(--missing); background: var(--missing-fill);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px;
}
.missing-section h2 { margin: 0 0 8px; font-size: 15px; color: var(--missing); }
.missing-list { display: flex; flex-wrap: wrap; gap: 8px; }
.missing-chip {
  background: #fff; border: 1px solid var(--missing); color: var(--missing);
  padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.missing-chip .when { color: var(--ink-soft); font-weight: 400; margin-left: 6px; }

/* Buttons / forms */
.btn {
  background: var(--brand); color: #fff; border: none; border-radius: 9px;
  padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--brand-hover); }
.btn.ghost { background: var(--fill); color: var(--brand); }
.btn.ghost:hover { background: var(--line); }
.btn.danger { background: var(--missing); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], textarea, select {
  font-family: inherit; font-size: 15px; padding: 9px 10px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: var(--card); color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
textarea { width: 100%; min-height: 120px; font-family: var(--mono); font-size: 13px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--fill-2); color: var(--ink-soft); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
td.actions { display: flex; gap: 6px; }

/* Sub-panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.panel h2 { font-size: 15px; margin: 0 0 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* Inline "name & save" form */
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input { flex: 1; min-width: 120px; }

/* Map */
#map { height: 62vh; min-height: 340px; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.map-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.map-hint { font-size: 13px; color: var(--ink-soft); }
.room-pin {
  background: var(--brand); color: #fff; border: 2px solid #fff;
  border-radius: 50% 50% 50% 0; width: 30px; height: 30px;
  transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0,0,0,.4);
  display: grid; place-items: center;
}
.room-pin > span { transform: rotate(45deg); font-size: 12px; font-weight: 700; }
.room-pin.empty { background: var(--brand-2); opacity: .8; }
.leaflet-popup-content { margin: 10px 12px; font-size: 14px; }
.leaflet-popup-content .pop-title { font-weight: 700; margin-bottom: 6px; }
.leaflet-popup-content .pop-item { display: flex; align-items: center; gap: 7px; padding: 3px 0; }

.notice { padding: 12px; border-radius: 10px; background: var(--fill); color: var(--ink-soft); font-size: 14px; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 900; opacity: 0;
  transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--missing); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; }
.tag-on { color: var(--fresh); font-weight: 600; }
.tag-off { color: var(--ink-soft); }

@media (max-width: 560px) {
  .brand span, .brand { font-size: 15px; }
  main { padding: 10px; }
}
