/* ------------------------------------------------------------------ *
 * Diksha OS — monochrome theme
 *
 * Pure white / pure black surfaces, inverted solid buttons, dividers
 * instead of boxes. Colour is reserved for status tags, which carry
 * meaning. The sidebar and the content area scroll independently.
 * ------------------------------------------------------------------ */

:root {
  color-scheme: light;
  --text: #000000;
  --text-soft: rgba(0, 0, 0, 0.64);
  --text-faint: rgba(0, 0, 0, 0.45);
  --bg: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-subtle: rgba(0, 0, 0, 0.035);
  --hover: rgba(0, 0, 0, 0.05);
  --hover-strong: rgba(0, 0, 0, 0.09);
  --divider: rgba(0, 0, 0, 0.1);

  /* Solid buttons and markers invert against the page. */
  --accent: #000000;
  --accent-hover: #262626;
  --accent-fg: #ffffff;
  --accent-soft: rgba(0, 0, 0, 0.06);

  --danger: #c0392f;
  --danger-soft: rgba(192, 57, 47, 0.1);
  --success: #1f7a4d;

  --scrollbar: rgba(0, 0, 0, 0.22);

  --tag-gray-bg: #ececec;    --tag-gray-fg: #2e2e2e;
  --tag-blue-bg: #d9e8f3;    --tag-blue-fg: #14324a;
  --tag-green-bg: #dcecdf;   --tag-green-fg: #17381f;
  --tag-yellow-bg: #f8e9c4;  --tag-yellow-fg: #3d2c11;
  --tag-purple-bg: #e5dcef;  --tag-purple-fg: #35204d;
  --tag-red-bg: #f6dcd8;     --tag-red-fg: #4d1512;

  --shadow-menu:
    0 0 0 1px rgba(0, 0, 0, 0.08),
    0 4px 10px rgba(0, 0, 0, 0.1),
    0 12px 32px rgba(0, 0, 0, 0.18);

  --radius: 4px;
  --radius-lg: 6px;
}

/* A tiny inline script in index.html resolves "system" into an explicit
   data-theme before first paint, so this attribute is always present and no
   prefers-color-scheme query is needed here. */
:root[data-theme='dark'] {
  color-scheme: dark;
  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.66);
  --text-faint: rgba(255, 255, 255, 0.45);
  --bg: #000000;
  --bg-sidebar: #000000;
  --bg-subtle: rgba(255, 255, 255, 0.05);
  --hover: rgba(255, 255, 255, 0.07);
  --hover-strong: rgba(255, 255, 255, 0.12);
  --divider: rgba(255, 255, 255, 0.14);

  --accent: #ffffff;
  --accent-hover: #d9d9d9;
  --accent-fg: #000000;
  --accent-soft: rgba(255, 255, 255, 0.1);

  --danger: #ff6b60;
  --danger-soft: rgba(255, 107, 96, 0.16);
  --success: #4cc38a;

  --scrollbar: rgba(255, 255, 255, 0.26);

  --tag-gray-bg: #2e2e2e;    --tag-gray-fg: #d6d6d6;
  --tag-blue-bg: #17324b;    --tag-blue-fg: #cfe3f5;
  --tag-green-bg: #16382a;   --tag-green-fg: #cfe9d8;
  --tag-yellow-bg: #40300f;  --tag-yellow-fg: #f6e2b6;
  --tag-purple-bg: #2f2145;  --tag-purple-fg: #dfd0f0;
  --tag-red-bg: #451714;     --tag-red-fg: #f7cfc9;

  --shadow-menu:
    0 0 0 1px rgba(255, 255, 255, 0.14),
    0 4px 10px rgba(0, 0, 0, 0.5),
    0 12px 32px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

/* Layout rules set `display` on several of these, which would otherwise
   defeat the `hidden` attribute used to switch views. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Helvetica, "Apple Color Emoji", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* The page itself never scrolls — the sidebar and the content each own
     their own scroll region. */
  overflow: hidden;
}

.layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- Scrollbars ---------- */

.content, #nav, .table-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
  overscroll-behavior: contain;
}

.content::-webkit-scrollbar,
#nav::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }

.content::-webkit-scrollbar-track,
#nav::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track { background: transparent; }

.content::-webkit-scrollbar-thumb,
#nav::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 6px;
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ---------- Sidebar ---------- */

/* Full height, with the nav scrolling inside it so the footer stays put. */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--divider);
  padding: 12px 8px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-footer {
  flex-shrink: 0;
  padding-top: 16px;
}

.theme-switch {
  display: flex;
  gap: 2px;
  background: var(--hover);
  border-radius: var(--radius-lg);
  padding: 2px;
}

.theme-switch button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  background: none;
  border-radius: var(--radius);
  padding: 5px 4px;
  font: inherit;
  font-size: 12px;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 20ms ease-in, color 20ms ease-in;
}

.theme-switch button:hover { color: var(--text-soft); }

.theme-switch button.active {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 500;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 10px;
}

.sidebar h1 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

#sidebar-close { display: none; }

#nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.nav-section {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  margin: 14px 0 2px;
  padding: 0 8px;
}

#nav button {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 5px 8px;
  border: none;
  background: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 20ms ease-in;
}

#nav button:hover { background: var(--hover); }

#nav button.active {
  background: var(--hover-strong);
  color: var(--text);
  font-weight: 500;
}

.nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-backdrop { display: none; }

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

.content {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  padding: 40px 60px 80px;
}

/* Keeps the reading width comfortable without capping the scroll region. */
.content > * { max-width: 1120px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

.topbar h2 {
  flex: 1;
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-icon { font-size: 30px; }

.icon-btn {
  border: none;
  background: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-soft);
  padding: 5px 7px;
  border-radius: var(--radius);
}
.icon-btn:hover { background: var(--hover); }

.menu-toggle { display: none; }

/* Panels are mostly invisible; separation comes from space and dividers. */
.panel { margin-bottom: 30px; }

.panel h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-faint);
}

.hint { font-size: 13px; color: var(--text-faint); margin: 10px 0 0; }

.empty { color: var(--text-faint); font-size: 14px; padding: 10px 0; }

/* ---------- Buttons ---------- */

.btn-primary, .btn-secondary {
  border: none;
  border-radius: var(--radius);
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 20ms ease-in;
}

.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.45; cursor: default; }

.btn-secondary {
  background: transparent;
  color: var(--text-soft);
  box-shadow: inset 0 0 0 1px var(--divider);
}
.btn-secondary:hover { background: var(--hover); }

.link-btn {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 3px 7px;
  border-radius: var(--radius);
  color: var(--text-faint);
  transition: opacity 60ms ease-in, background 20ms ease-in;
}
.link-btn:hover { background: var(--hover); color: var(--text); }
.link-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* Notion reveals row actions on hover — but only do that where a pointer can
   actually hover, otherwise they'd be unreachable on touch screens. */
@media (hover: hover) {
  .link-btn { opacity: 0; }
  tr:hover .link-btn,
  .link-btn:focus-visible { opacity: 1; }
}

/* ---------- Dashboard ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 8px;
  margin-bottom: 34px;
}

.stat {
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.stat .label {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.stat .value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.stat .value.pos { color: var(--success); }
.stat .value.neg { color: var(--danger); }

.stat .sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.split .panel { margin-bottom: 0; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 9px;
  font-size: 14px;
}
.bar-row .name { width: 100px; flex-shrink: 0; color: var(--text-soft); }
.bar-row .track {
  flex: 1;
  height: 6px;
  background: var(--hover);
  border-radius: 3px;
  overflow: hidden;
}
.bar-row .fill { height: 100%; background: var(--accent); border-radius: 3px; }
.bar-row .num { width: 28px; text-align: right; color: var(--text-faint); font-size: 13px; }

.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
}
.mini-row:last-child { border-bottom: none; }
.mini-row .meta { color: var(--text-faint); font-size: 13px; }

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.toolbar input[type='search'], .toolbar select {
  padding: 5px 9px;
  border: none;
  box-shadow: inset 0 0 0 1px var(--divider);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

.toolbar input[type='search'] { flex: 1; min-width: 200px; max-width: 340px; }
.toolbar input[type='search']:focus, .toolbar select:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.record-count { font-size: 13px; color: var(--text-faint); margin-left: auto; }

.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; }

.filter-bar select {
  padding: 5px 8px;
  border: none;
  box-shadow: inset 0 0 0 1px var(--divider);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  max-width: 170px;
}
.filter-bar select:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent); }

/* Toolbar buttons are always visible, unlike the hover-revealed row actions. */
.link-btn.always { opacity: 1 !important; }

/* ---------- Table ---------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Full grid borders, like a Notion database table. */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--divider);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

th {
  color: var(--text-faint);
  font-weight: 400;
  font-size: 13px;
  background: var(--bg-subtle);
}

tbody tr { transition: background 20ms ease-in; }
tbody tr:hover { background: var(--hover); }

td:first-child { font-weight: 500; }

.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

.card-list { display: none; }

/* ---------- Tags & progress ---------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  line-height: 18px;
  background: var(--tag-gray-bg);
  color: var(--tag-gray-fg);
  white-space: nowrap;
}
.badge.tag-gray { background: var(--tag-gray-bg); color: var(--tag-gray-fg); }
.badge.tag-blue { background: var(--tag-blue-bg); color: var(--tag-blue-fg); }
.badge.tag-yellow { background: var(--tag-yellow-bg); color: var(--tag-yellow-fg); }
.badge.tag-green { background: var(--tag-green-bg); color: var(--tag-green-fg); }
.badge.tag-purple { background: var(--tag-purple-bg); color: var(--tag-purple-fg); }
.badge.tag-red { background: var(--tag-red-bg); color: var(--tag-red-fg); }

/* ---------- Inline editing ---------- */

td.editable { cursor: text; }
td.editable:hover { box-shadow: inset 0 0 0 1px var(--divider); border-radius: var(--radius); }

.badge.editable { cursor: pointer; }
.card-field .v.editable {
  cursor: text;
  border-radius: var(--radius);
  padding: 1px 5px;
  margin: -1px -5px;
  box-shadow: inset 0 0 0 1px var(--divider);
}

.inline-editor {
  width: 100%;
  min-width: 90px;
  border: none;
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: var(--radius);
  padding: 4px 7px;
  font: inherit;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}
.inline-editor:focus { outline: none; }

td.cell-open { box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- Combobox (select + create) ---------- */

.combo-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 34px;
  padding: 5px 10px;
  border: none;
  box-shadow: inset 0 0 0 1px var(--divider);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.combo-trigger:hover { background: var(--hover); }
.combo-placeholder { color: var(--text-faint); font-size: 14px; }

.combo-popup {
  position: fixed;
  z-index: 300;
  width: 260px;
  max-width: calc(100vw - 24px);
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-menu);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.combo-search {
  border: none;
  box-shadow: inset 0 0 0 1px var(--divider);
  border-radius: var(--radius);
  padding: 6px 9px;
  font: inherit;
  font-size: 14px;
  background: var(--bg-subtle);
  color: var(--text);
}
.combo-search:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent); }

.combo-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }

.combo-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  border-radius: var(--radius);
  padding: 5px 6px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.combo-option:hover { background: var(--hover); }

.combo-create { color: var(--text-soft); font-size: 13px; }
.combo-clear { color: var(--text-faint); font-size: 13px; }
.combo-tick { color: var(--text-faint); font-size: 12px; }
.combo-none { color: var(--text-faint); font-size: 13px; padding: 6px; }

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-soft);
  flex-wrap: wrap;
}

.pagination .spacer { flex: 1; }

.pagination button {
  border: none;
  box-shadow: inset 0 0 0 1px var(--divider);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  padding: 5px 11px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.pagination button:hover:not(:disabled) { background: var(--hover); }
.pagination button:disabled { opacity: 0.4; cursor: default; }

.pagination select {
  border: none;
  box-shadow: inset 0 0 0 1px var(--divider);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  padding: 4px 6px;
  font: inherit;
  font-size: 13px;
}

/* ---------- New-row entry ---------- */

tr.new-row td {
  color: var(--text-faint);
  cursor: pointer;
}
tr.new-row:hover td { background: var(--hover); color: var(--text-soft); }

.card-new {
  border: 1px dashed var(--divider);
  border-radius: var(--radius-lg);
  padding: 12px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  cursor: pointer;
  background: none;
  width: 100%;
  font-family: inherit;
}
.card-new:hover { background: var(--hover); color: var(--text-soft); }

.progress { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.progress .track {
  flex: 1;
  height: 5px;
  background: var(--hover-strong);
  border-radius: 3px;
  overflow: hidden;
}
.progress .fill { height: 100%; background: var(--success); }
.progress .txt { font-size: 12px; color: var(--text-faint); white-space: nowrap; }

/* ---------- Calendar ---------- */

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 600;
}
#cal-title { min-width: 150px; }

.calendar-header button {
  border: none;
  background: transparent;
  color: var(--text-soft);
  border-radius: var(--radius);
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.calendar-header button:hover { background: var(--hover); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--divider);
  border-left: 1px solid var(--divider);
}

.calendar-grid .dow {
  text-align: left;
  font-size: 12px;
  color: var(--text-faint);
  padding: 6px 8px;
  border-right: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
}

.calendar-grid .day {
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 6px 8px;
  border-right: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
  background: var(--bg);
  cursor: pointer;
  font-size: 13px;
  transition: background 20ms ease-in;
}
.calendar-grid .day:hover { background: var(--hover); }
.calendar-grid .day.empty-cell { cursor: default; background: var(--bg-subtle); }
.calendar-grid .day.empty-cell:hover { background: var(--bg-subtle); }

.calendar-grid .day.today > span:first-child {
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.calendar-grid .day.selected { background: var(--accent-soft); }
.calendar-grid .day.selected:hover { background: var(--accent-soft); }

.calendar-grid .day .dot {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  max-width: 34px;
}
.calendar-grid .day.full .dot { background: var(--success); }

.attendance-row-actions { display: flex; align-items: center; gap: 6px; }

.generate-btn {
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--radius);
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 10px;
}
.generate-btn:hover { background: var(--accent-hover); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.field label { color: var(--text-faint); }

.field input, .field select {
  padding: 7px 10px;
  border: none;
  box-shadow: inset 0 0 0 1px var(--divider);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  background: var(--bg-subtle);
  color: var(--text);
}
.field input:focus, .field select:focus {
  outline: none;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.field.checkbox { flex-direction: row; align-items: center; gap: 7px; }
.field.checkbox input { width: auto; box-shadow: none; }

td input[type='time'], .card-field input[type='time'] {
  padding: 4px 7px;
  border: none;
  box-shadow: inset 0 0 0 1px var(--divider);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

input[type='checkbox'] { accent-color: var(--accent); }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 24px;
  z-index: 100;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 20px 22px 22px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-menu);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

#record-form { display: flex; flex-direction: column; gap: 14px; }
#record-form .field input, #record-form .field select { width: 100%; }
#record-form button[type='submit'] { width: 100%; margin-top: 4px; padding: 8px; }

.note {
  font-size: 13px;
  color: var(--text-soft);
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 16px;
}

.error { color: var(--danger); font-size: 13px; min-height: 16px; margin: 10px 0 0; }

/* ---------- Reports ---------- */

.report-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  max-width: 620px;
}
.report-form .field input, .report-form .field select { width: 100%; }

.report-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  z-index: 200;
  box-shadow: var(--shadow-menu);
}
.toast[hidden] { display: none; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Sign-in ---------- */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.login-mark { font-size: 40px; line-height: 1; margin-bottom: 14px; }

.login-card h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.login-card p {
  color: var(--text-faint);
  font-size: 14px;
  margin: 0 0 22px;
}

#google-button { display: flex; justify-content: center; min-height: 44px; }

#login-error { text-align: center; margin-top: 14px; }

/* Signed-in identity above the theme switch. */
.session-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  font-size: 13px;
  min-width: 0;
}
.session-row .who {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-soft);
}
.session-row .avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--hover-strong);
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
  .content { padding: 32px 34px 60px; }
  .split { grid-template-columns: 1fr; gap: 26px; }
}

@media (max-width: 768px) {
  .menu-toggle { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    width: 258px;
    max-width: 84vw;
    transform: translateX(-100%);
    transition: transform 160ms ease;
    box-shadow: var(--shadow-menu);
  }
  .sidebar.open { transform: translateX(0); }

  #sidebar-close { display: inline-flex; }

  .sidebar-backdrop.visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 15, 0.4);
    z-index: 40;
  }

  .content { padding: 0 16px 60px; }

  /* The menu toggle and Add button must stay reachable while the list
     scrolls, so the header sticks to the top of the content scroll area. */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    padding: 14px 0 12px;
    margin-bottom: 12px;
  }
  .topbar h2 { font-size: 24px; }
  .title-icon { font-size: 22px; }

  .panel { margin-bottom: 24px; }

  /* Cards replace the table entirely; each carries its own frame. */
  .table-scroll { display: none; }
  .card-list { display: flex; flex-direction: column; gap: 8px; }

  .record-card {
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    background: var(--bg-subtle);
  }

  .record-card .card-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 9px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .record-card .card-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    padding: 3px 0;
  }
  .record-card .card-field .k { color: var(--text-faint); }
  .record-card .card-field .v { text-align: right; word-break: break-word; }

  .record-card .card-actions {
    display: flex;
    gap: 8px;
    margin-top: 11px;
    border-top: 1px solid var(--divider);
    padding-top: 11px;
  }
  .record-card .card-actions button { flex: 1; padding: 7px; opacity: 1; }

  /* 16px inputs stop iOS zooming on focus. */
  .field input, .field select, .toolbar input, .toolbar select { font-size: 16px; }

  .calendar-grid .day { min-height: 52px; padding: 4px; align-items: center; }
  .calendar-grid .day .dot { max-width: 20px; }
  .calendar-grid .dow { text-align: center; padding: 5px 2px; }

  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stat .value { font-size: 21px; }

  .toolbar input[type='search'] { max-width: none; }
  .report-actions button { flex: 1; }

  .toast { left: 14px; right: 14px; transform: none; text-align: center; }
}

@media (min-width: 769px) {
  .sidebar-backdrop { display: none !important; }
}
