/* Grand Uday operations dashboard — light is the default, dark via toggle. */

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --border: #eaecf0;
  --chip: #f2f4f7;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --grid: #eef0f3;
  --axis: #d0d5dd;
  --accent: #0f766e;
  --accent-text: #0f766e;
  --accent-soft: #ccfbf1;
  --nav-active: #e6f6f3;
  --on-accent: #ffffff;
  --s1: #2a78d6;            /* series 1: raised, per-hour, departments */
  --s2: #eb6834;            /* series 2: closed */
  --good: #0ca30c;
  --warn: #fab219;
  --critical: #d03b3b;
  --good-soft: #ddf3dd;
  --warn-soft: #fef0c7;
  --blue-soft: #dceafb;
  --none: #c3c9d2;
  --none-soft: #f2f4f7;
  --tip-bg: #101828;
  --tip-text: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --p-immediate-bg: #fee4e2; --p-immediate-fg: #b42318;
  --p-urgent-bg: #fef0c7;    --p-urgent-fg: #93370d;
  --p-normal-bg: #d1e9ff;    --p-normal-fg: #175cd3;
  --p-low-bg: #f2f4f7;       --p-low-fg: #344054;
  --warn-text: #93370d;
  --danger-text: #b42318;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --surface: #1a2129;
  --border: #2a3440;
  --chip: #232c36;
  --text: #e8edf2;
  --text-2: #c0cad4;
  --muted: #9aa7b4;
  --grid: #242d37;
  --axis: #3a4652;
  --accent: #f5b544;
  --accent-text: #f5b544;
  --accent-soft: #3a2e17;
  --nav-active: #3a2e17;
  --on-accent: #1a1206;
  --s1: #3987e5;
  --s2: #d95926;
  --good-soft: #16301a;
  --warn-soft: #3a2e12;
  --blue-soft: #172a40;
  --none: #4a5663;
  --none-soft: #232c36;
  --tip-bg: #e8edf2;
  --tip-text: #101828;
  --shadow: none;
  --p-immediate-bg: #ff8a80; --p-immediate-fg: #1a0a0a;
  --p-urgent-bg: #f5b544;    --p-urgent-fg: #1a1206;
  --p-normal-bg: #7cc4ff;    --p-normal-fg: #06182b;
  --p-low-bg: #a7c4a0;       --p-low-fg: #0e1a12;
  --warn-text: #f5b544;
  --danger-text: #ff8a80;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; }

/* Line icons. Charts draw their own strokes (.chart). */
svg:not(.chart) { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

h1, h2, h3 { margin: 0; }

.muted { color: var(--muted); }

.num { font-variant-numeric: tabular-nums; }

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}

.login-logo {
  align-self: center;
  width: 96px;
  height: 96px;
  border-radius: 24px;
  background: #0f1419;
  object-fit: contain;
  padding: 6px;
}

.login-card h1 { text-align: center; font-size: 24px; letter-spacing: -0.3px; }
.login-card > .muted { text-align: center; margin: -8px 0 8px; }

.login-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 13px; color: var(--text-2); }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--axis);
  border-radius: 12px;
  height: 46px;
  padding: 0 14px;
}

input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.form-error { color: var(--danger-text); min-height: 18px; margin: 0; font-size: 13px; font-weight: 600; }

.btn-primary {
  height: 48px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
  font-size: 15px;
}

.btn-primary:disabled { opacity: 0.6; cursor: default; }

/* ---------- Shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-logo { width: 44px; height: 44px; border-radius: 12px; background: #0f1419; display: grid; place-items: center; overflow: hidden; }
.brand-logo img { width: 40px; height: 40px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; }
.brand-text b { font-size: 16px; letter-spacing: -0.2px; }
.brand-text small { color: var(--muted); font-size: 12px; }

#nav { display: flex; flex-direction: column; gap: 4px; }

#nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-2);
  font-weight: 600;
}

#nav a:hover { background: var(--chip); }
#nav a[aria-current="page"] { background: var(--nav-active); color: var(--accent-text); font-weight: 800; }
#nav a em { margin-left: auto; font-style: normal; font-size: 12px; font-weight: 800; background: var(--chip); color: var(--text); padding: 2px 8px; border-radius: 99px; }
#nav a em:empty { display: none; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  background: var(--chip);
  padding: 4px;
  border-radius: 12px;
}

.segmented button {
  height: 36px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.segmented button svg { width: 16px; height: 16px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 800; box-shadow: var(--shadow); }

.me { display: flex; align-items: center; gap: 10px; padding: 4px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.me-text { display: flex; flex-direction: column; min-width: 0; flex-grow: 1; }
.me-text b, .me-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); font-size: 12px; }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  position: relative;
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--chip); }

.main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.title { display: flex; flex-direction: column; }
.title h1 { font-size: 22px; letter-spacing: -0.3px; }
.title .muted { font-size: 13px; }

.live {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  background: var(--chip);
  padding: 6px 12px;
  border-radius: 99px;
}

.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--none); }
.live.on { background: var(--good-soft); }
.live.on .dot { background: var(--good); animation: pulse 2s infinite; }

@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .live.on .dot { animation: none; } }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--critical);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.bell-wrap { position: relative; }

.bell-panel {
  position: absolute;
  right: 0;
  top: 52px;
  width: 360px;
  max-height: 460px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.16);
  z-index: 20;
}

.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.link-btn { border: none; background: none; color: var(--accent-text); font-weight: 700; font-size: 13px; padding: 4px; }

.bell-item { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.bell-item.unread { background: var(--nav-active); }
.bell-item b { font-size: 13px; }
.bell-item span { font-size: 12px; color: var(--muted); }

.content { padding: 24px 28px 32px; display: flex; flex-direction: column; gap: 20px; outline: none; }

/* ---------- Cards & grids ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-head h2 { font-size: 16px; font-weight: 800; }
.card-head .muted { font-size: 13px; }
.card-head > div { display: flex; flex-direction: column; gap: 2px; }

.row-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.kpi { gap: 10px; padding: 18px 20px; }
.kpi-head { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text-2); }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.kpi-icon svg { width: 18px; height: 18px; stroke-width: 2.2; }
.kpi-value { display: flex; align-items: baseline; gap: 8px; }
.kpi-value b { font-size: 38px; letter-spacing: -1px; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-value span { color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; }
.kpi small { color: var(--muted); font-size: 13px; }

.stat-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; margin-top: auto; }
.stat { background: var(--chip); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-size: 20px; font-variant-numeric: tabular-nums; }

/* Room board */

.state-bar { display: flex; height: 14px; gap: 2px; }
.state-bar i { border-radius: 4px; min-width: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.legend span { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--text); }

.board { display: flex; flex-direction: column; gap: 7px; }
.floor { display: flex; align-items: flex-start; gap: 8px; }
.floor-label { width: 62px; flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--muted); padding-top: 11px; }
.floor-rooms { display: flex; flex-wrap: wrap; gap: 4px; }

.room {
  min-width: 44px;
  height: 40px;
  padding: 0 6px;
  border-radius: 8px;
  border: none;
  position: relative;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.room::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--dot); }
.room:hover { outline: 2px solid var(--dot); outline-offset: 1px; }

.st-ready { background: var(--good-soft); --dot: var(--good); }
.st-check { background: var(--warn-soft); --dot: var(--warn); }
.st-cleaning { background: var(--blue-soft); --dot: var(--s1); }
.st-none { background: var(--none-soft); --dot: var(--none); }

.board-big .room { min-width: 88px; height: 64px; padding: 6px 10px; place-items: start; text-align: left; }
.board-big .room small { display: block; font-size: 11px; font-weight: 600; color: var(--text-2); margin-top: 2px; }

/* Charts */

.hour-bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; border-bottom: 1px solid var(--axis); padding-top: 8px; }
.hour-bars > div { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.hour-bars span { font-size: 11px; font-weight: 700; color: var(--text-2); }
.hour-bars i { width: min(18px, 70%); background: var(--s1); border-radius: 4px 4px 0 0; }
.hour-bars .now i { opacity: 0.55; }
.hour-labels { display: flex; gap: 6px; margin-top: 6px; }
.hour-labels span { flex: 1 1 0; text-align: center; font-size: 11px; color: var(--muted); }

.line-wrap { position: relative; }
.line-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.line-wrap text { font-size: 11px; fill: var(--muted); font-family: inherit; }

.series-legend { display: flex; gap: 18px; }
.series-legend span { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.series-legend i { width: 16px; height: 2px; border-radius: 2px; display: inline-block; }

.dept { display: flex; flex-direction: column; gap: 14px; }
.dept-row { display: flex; flex-direction: column; gap: 6px; }
.dept-row div:first-child { display: flex; justify-content: space-between; font-size: 13px; }
.dept-row div:first-child span { color: var(--text-2); font-weight: 600; }
.dept-track { height: 10px; border-radius: 4px; background: var(--chip); }
.dept-track i { display: block; height: 10px; border-radius: 4px; background: var(--s1); }

.chart-tip {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  background: var(--tip-bg);
  color: var(--tip-text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip .tip-row b { margin-left: auto; padding-left: 14px; }
.chart-tip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Tables */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 8px; border-bottom: 1px solid var(--border); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--chip); }
td.room-cell { font-weight: 800; }
td.right, th.right { text-align: right; }

.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; display: inline-block; }
.p-Immediate { background: var(--p-immediate-bg); color: var(--p-immediate-fg); }
.p-Urgent { background: var(--p-urgent-bg); color: var(--p-urgent-fg); }
.p-Normal { background: var(--p-normal-bg); color: var(--p-normal-fg); }
.p-Low { background: var(--p-low-bg); color: var(--p-low-fg); }
.s-ready { background: var(--good-soft); color: var(--text); }
.s-check { background: var(--warn-soft); color: var(--text); }
.s-cleaning { background: var(--blue-soft); color: var(--text); }

.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* Activity */

.activity { display: flex; flex-direction: column; gap: 14px; }
.act { display: flex; gap: 12px; align-items: flex-start; }
.act-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.act-icon svg { width: 16px; height: 16px; stroke-width: 2.2; }
.act div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.act b { font-size: 13px; }
.act span { font-size: 12px; color: var(--muted); }

.ic-ready { background: var(--good-soft); color: var(--good); }
.ic-check { background: var(--warn-soft); color: var(--warn-text); }
.ic-cleaning { background: var(--blue-soft); color: var(--s1); }
.ic-complaint { background: var(--p-immediate-bg); color: var(--danger-text); }
:root[data-theme="dark"] .ic-complaint { background: #3b1e1e; color: #ff8a80; }

/* Filters */

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input[type="search"] { min-width: 240px; height: 40px; }
.filters select { height: 40px; }
.filters .segmented button { padding: 0 14px; }

/* Drawer */

.drawer-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, 0.4); z-index: 30; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 31;
  display: flex;
  flex-direction: column;
}

.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 18px; }
.drawer-body { padding: 20px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }

.facts { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

.photos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.photos button { padding: 0; border: none; border-radius: 10px; overflow: hidden; aspect-ratio: 1; background: var(--chip); }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-big { width: 100%; border-radius: 12px; display: block; }

.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.88); z-index: 40; display: grid; place-items: center; padding: 24px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox .icon-btn { position: absolute; top: 16px; right: 16px; }

/* ---------- Smaller screens ---------- */

@media (max-width: 1180px) {
  .row-2-1 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; }
  #nav { flex-direction: row; overflow-x: auto; order: 3; width: 100%; }
  #nav a { flex-shrink: 0; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .me-text { display: none; }
  .topbar { position: static; height: auto; padding: 14px 16px; flex-wrap: wrap; }
  .content { padding: 16px; }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .bell-panel { width: min(360px, calc(100vw - 32px)); }
  .filters input[type="search"] { min-width: 0; flex-grow: 1; }
}
