/* Same dark theme as the ItzABot dashboard, with Moonlight Order's lavender accent */
:root {
  --bg: linear-gradient(to bottom right, #1f2937, #111827, #000000);
  --card-bg: #1f2937;
  --card-border: rgba(255, 255, 255, 0.06);
  --text: #f9fafb;
  --muted: #9ca3af;
  --faint: #6b7280;
  --accent: #c3bfff;
  --accent-strong: #8b83ff;
  --link: #60a5fa;
  --button-bg: #3b82f6;
  --button-text: #f9fafb;
  --input-bg: #374151;
  --input-border: #4b5563;
  --navbar-bg: rgba(31, 41, 55, 0.95);
  --hover: rgba(96, 165, 250, 0.12);

  --good: #4ade80;
  --warning: #facc15;
  --critical: #f87171;

  --header-h: 4rem;
  --radius: 0.75rem;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

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

h1 { font-size: 1.75rem; margin: 0; font-weight: 700; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; font-weight: 600; }
h3 { font-size: 0.95rem; margin: 0; font-weight: 600; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: var(--navbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
}
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand span { color: var(--accent); }
.navbar .spacer { flex: 1; }
.live-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: var(--muted);
  padding: 0.2rem 0.6rem; border-radius: 999px; background: rgba(255,255,255,0.05);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.good { background: var(--good); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15); }
.dot.warning { background: var(--warning); }
.dot.critical { background: var(--critical); }
.user-chip { display: flex; align-items: center; gap: 0.5rem; }
.user-chip img { width: 30px; height: 30px; border-radius: 50%; }
.navbar .menu-toggle { display: none; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  max-width: 1400px;
  margin: 0 auto;
}
.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  padding: 1.25rem 0.75rem;
  overflow-y: auto;
}
.sidebar a {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.8rem; margin-bottom: 2px;
  border-radius: 0.5rem; color: var(--muted); font-weight: 500;
}
.sidebar a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.sidebar a.active { background: rgba(195, 191, 255, 0.12); color: var(--accent); }
.sidebar .icon { width: 1.25rem; text-align: center; }
.sidebar .badge { margin-left: auto; }
.sidebar .section { margin: 1rem 0.8rem 0.4rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }

main { padding: 1.5rem; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head p { margin: 0.25rem 0 0; }

.grid { display: grid; gap: 1rem; }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

/* ---------- Cards & tiles ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.tile .label { font-size: 0.8rem; color: var(--muted); }
.tile .value { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 0.2rem; }
.tile .sub { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; display: flex; align-items: center; gap: 0.35rem; }
a.tile { color: inherit; display: block; }
a.tile:hover { text-decoration: none; border-color: rgba(195, 191, 255, 0.35); }

/* ---------- Buttons & inputs ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 500; font-size: 0.9rem;
  padding: 0.45rem 0.9rem; border-radius: 0.4rem; border: 0; cursor: pointer;
  background: var(--button-bg); color: var(--button-text);
  transition: opacity 0.2s ease, background-color 0.2s ease;
  white-space: nowrap;
}
.button:hover { opacity: 0.85; text-decoration: none; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button.ghost { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.button.success { background: #16a34a; }
.button.danger { background: #dc2626; }
.button.warn { background: #b45309; }
.button.small { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

.input, select.input, textarea.input {
  font: inherit; font-size: 0.9rem;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--input-border); border-radius: 0.4rem;
  padding: 0.45rem 0.7rem; width: 100%;
}
.input:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35); }
.input::placeholder { color: var(--muted); }
label.field { display: block; }
label.field > span { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.3rem; }
.form-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.switch { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--input-border); position: relative; cursor: pointer; transition: background 0.2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked { background: var(--button-bg); }
.switch input:checked::after { transform: translateX(16px); }

.tabs { display: inline-flex; gap: 0.25rem; background: rgba(255,255,255,0.04); padding: 0.25rem; border-radius: 0.55rem; }
.tabs button { font: inherit; font-size: 0.88rem; border: 0; background: none; color: var(--muted); padding: 0.35rem 0.85rem; border-radius: 0.4rem; cursor: pointer; }
.tabs button.active { background: var(--card-bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

/* ---------- Lists & tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--input-border); white-space: nowrap; }
td { padding: 0.55rem 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.person { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.person img { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--input-bg); }
.person .names { min-width: 0; }
.person .names div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }

.badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; font-weight: 500; padding: 0.1rem 0.5rem; border-radius: 999px; background: rgba(255,255,255,0.07); color: var(--text); white-space: nowrap; }
.badge.good { background: rgba(74, 222, 128, 0.12); color: #bbf7d0; }
.badge.warning { background: rgba(250, 204, 21, 0.12); color: #fef08a; }
.badge.critical { background: rgba(248, 113, 113, 0.14); color: #fecaca; }
.badge.accent { background: rgba(195, 191, 255, 0.14); color: var(--accent); }
.role-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.skeleton { background: rgba(255,255,255,0.06); border-radius: 0.4rem; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------- Feature bits ---------- */
.feed { max-height: 360px; overflow-y: auto; }
.feed .list-item { font-size: 0.88rem; }
.feed .when { color: var(--faint); font-size: 0.78rem; white-space: nowrap; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(195, 191, 255, 0.18); } to { background: transparent; } }

.boss-thumb { width: 64px; height: 36px; object-fit: cover; border-radius: 0.35rem; background: var(--input-bg); flex: none; }
.boss-row { display: grid; grid-template-columns: 130px 110px minmax(160px, 1fr) minmax(160px, 1fr) 64px auto; gap: 0.5rem; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.day-group h3 { margin: 1rem 0 0.25rem; color: var(--accent); }

.attendance { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 0.75rem; }
.attendance ul { list-style: none; margin: 0.35rem 0 0; padding: 0; font-size: 0.88rem; max-height: 220px; overflow-y: auto; }
.attendance li { padding: 0.15rem 0; }

.console {
  background: #0b1020; border-radius: var(--radius); border: 1px solid var(--card-border);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.8rem;
  height: calc(100vh - 16rem); min-height: 300px; overflow-y: auto; padding: 0.75rem 1rem;
}
.console .line { white-space: pre-wrap; word-break: break-word; padding: 1px 0; }
.console .line .t { color: var(--faint); margin-right: 0.6rem; }
.console .line.warn { color: #fde68a; }
.console .line.error { color: #fca5a5; }

.save-bar {
  position: sticky; bottom: 1rem; z-index: 10; margin-top: 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: rgba(17, 24, 39, 0.95); border: 1px solid rgba(195, 191, 255, 0.35);
  border-radius: var(--radius); padding: 0.75rem 1rem; backdrop-filter: blur(8px);
}

/* ---------- Dialog & toasts ---------- */
dialog {
  background: var(--card-bg); color: var(--text); border: 1px solid var(--input-border);
  border-radius: var(--radius); padding: 1.25rem; width: min(440px, calc(100vw - 2rem));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin-bottom: 0.4rem; }
dialog .actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

.toasts { position: fixed; bottom: 1rem; right: 1rem; z-index: 50; display: flex; flex-direction: column; gap: 0.5rem; max-width: calc(100vw - 2rem); }
.toast { background: #111827; border: 1px solid var(--input-border); border-left: 4px solid var(--good); border-radius: 0.5rem; padding: 0.65rem 0.9rem; box-shadow: 0 10px 25px rgba(0,0,0,0.4); animation: toast-in 0.3s ease both; font-size: 0.9rem; }
.toast.error { border-left-color: var(--critical); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Login / gate ---------- */
.gate { min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; padding: 1rem; }
.gate .card { max-width: 420px; text-align: center; padding: 2rem; }
.gate img { width: 72px; height: 72px; }

/* ---------- Phones ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .navbar { gap: 0.6rem; padding: 0 0.75rem; }
  .brand div { display: none; }
  #live-text { display: none; }
  .live-pill { padding: 0.4rem; }
  .page-head .input { max-width: none !important; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; width: 240px; height: auto; z-index: 25;
    background: #111827; border-right: 1px solid var(--card-border);
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  body.menu-open .sidebar { transform: none; }
  .navbar .menu-toggle { display: inline-flex; }
  main { padding: 1rem; }
  .user-chip .name { display: none; }
  .boss-row { grid-template-columns: 1fr 1fr; }
  .attendance { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px !important; }
}

[data-ago], [data-until] { white-space: nowrap; }
.tile .value .row { flex-wrap: nowrap; }
.role-checklist { display: flex; flex-wrap: wrap; gap: 0.4rem; max-height: 180px; overflow-y: auto; padding: 0.5rem; background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 0.4rem; }
.role-check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; padding: 0.2rem 0.55rem; border-radius: 999px; background: rgba(255,255,255,0.05); cursor: pointer; user-select: none; }
.role-check:has(input:checked) { background: rgba(195, 191, 255, 0.18); color: var(--accent); }
.role-check input { margin: 0; accent-color: var(--accent-strong); }
.field-hint { display: block; margin-top: 0.3rem; font-size: 0.78rem; color: var(--faint); line-height: 1.35; }
.item-icon { width: 28px; height: 28px; border-radius: 0.3rem; background: var(--input-bg); flex: none; }
