:root {
  color-scheme: light dark;

  /* Small brand theme — ported from mahamall-web-ui/src/app/globals.css */
  --background: #ffffff;
  --foreground: #1c1b1b;
  --card: #ffffff;
  --muted: #fdf8f7;
  --muted-foreground: #6b6b63;
  --accent: #f7f3f1;
  --accent-foreground: #1c1b1b;
  --primary: #1c1b19;
  --primary-foreground: #ffffff;
  --destructive: #ba1a1a;
  --success: #2e7d32;
  --border: #c7c7be;
  --input: #c7c7be;
  --ring: #1c1b19;

  --sidebar: #1c1b19;
  --sidebar-foreground: #ffffff;
  --sidebar-accent: #2a2a28;
  --sidebar-border: #2a2a28;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  --sidebar-width: 208px;
  --header-height: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #141313;
    --foreground: #e5e2e0;
    --card: #1c1b1b;
    --muted: #201f1f;
    --muted-foreground: #a9a6a1;
    --accent: #2b2a29;
    --accent-foreground: #e5e2e0;
    --primary: #e5e2e0;
    --primary-foreground: #1c1b19;
    --destructive: #ffb4ab;
    --success: #81c784;
    --border: #464740;
    --input: #464740;
    --ring: #e5e2e0;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--foreground);
  font: 15px/1.45 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* --- header (logo only) --- */

header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 clamp(1rem, 3vw, 1.75rem);
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-bottom: 1px solid var(--sidebar-border);
}

.brand {
  display: flex;
  align-items: center;
  line-height: 0;
}

.brand img {
  height: 24px;
  width: auto;
  display: block;
}

#logout {
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255, 255, 255, 0.68);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

#logout:hover { color: #ffffff; background: rgba(255, 255, 255, 0.08); }

/* --- shell: left nav panel + content --- */

.shell {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - var(--header-height));
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
  padding: 1.25rem 0.75rem;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar nav a {
  position: relative;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #ffffff; }

.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-weight: 700;
}

.sidebar nav a.active::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -0.75rem;
  width: 3px;
  height: 1.1rem;
  transform: translateY(-50%);
  border-radius: var(--radius-pill);
  background: #ffffff;
}

#appView {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 74rem;
  background: var(--background);
  padding: 1.75rem clamp(1rem, 3vw, 2.5rem) 4rem;
}

h3 { margin: 0.9rem 0 0.3rem; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); }

/* --- auth screen (login.html) --- */

.auth-body { background: var(--background); }

.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 22rem;
  padding: 2rem 1.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.auth-card-head { text-align: center; margin-bottom: 1.5rem; }

.auth-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-xl);
  background: var(--primary);
  color: var(--primary-foreground);
}

.auth-card-head h1 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.auth-card-head p { margin: 0.25rem 0 0; font-size: 0.85rem; color: var(--muted-foreground); }

#loginForm {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#loginForm label {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
}

#loginForm input { flex: 0 0 auto; }

.password-field { position: relative; display: flex; }
.password-field input { flex: 1 1 auto; padding-right: 2.3rem; }

.icon-btn {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
}

.icon-btn:hover { background: var(--accent); opacity: 1; color: var(--foreground); }

.auth-error { min-height: 0; margin: 0; }
.auth-error:not(:empty) {
  margin: 0.6rem 0 0;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--destructive) 12%, transparent);
  color: var(--destructive);
  font-size: 0.82rem;
}

#loginForm button[type="submit"] { margin-top: 1rem; }

/* --- forms & controls --- */

form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

input[type="text"], input[type="password"], input[type="number"], input:not([type]) {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--card);
  color: inherit;
  font: inherit;
}

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

button {
  padding: 0.55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

button:hover { opacity: 0.88; }

button.secondary {
  background: var(--background);
  border-color: var(--border);
  color: var(--foreground);
  font-weight: 500;
}

button.secondary:hover { background: var(--accent); opacity: 1; }

button:disabled { opacity: 0.45; cursor: default; }

select {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--card);
  color: inherit;
  font: inherit;
}

/* filter-style controls (toolbar/search inputs & selects) — flat muted fill, like
   mahamall's DataTableFilters, so they read as filters rather than form fields */
input.filter, select.filter {
  background: var(--muted);
  border-color: var(--border);
  height: 2.15rem;
  padding-top: 0;
  padding-bottom: 0;
}

.search-field { position: relative; flex: 1 1 14rem; display: flex; }
.search-field input.filter { flex: 1 1 auto; padding-left: 2rem; }
.search-icon {
  position: absolute;
  top: 50%;
  left: 0.65rem;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}

.msg {
  min-height: 1.2rem;
  margin: 0.6rem 0;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

/* --- result rows --- */

#results {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  overflow-x: hidden;
  /* Cap the list itself rather than the whole page, so the toolbar and pager stay in view and
     reviewing a full page of rows never turns into scrolling past the browser's own scrollbar. */
  max-height: 65vh;
  overflow-y: auto;
}

#results:empty { border: none; background: none; }

.row { border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }

/* A grid, not flex: each field gets its own column regardless of how long the field before it
   is, so every row's address (and rating, and controls) lines up at the same x position instead
   of drifting based on that one row's name length. */
.row summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) repeat(4, auto) auto;
  align-items: center;
  column-gap: 0.9rem;
  padding: 0.8rem 1rem;
  cursor: pointer;
  list-style: none;
}

.row summary::-webkit-details-marker { display: none; }

.row summary:hover { background: var(--accent); }

/* The address still truncates with an ellipsis rather than pushing later columns out of line;
   min-width: 0 is required on a grid item for text-overflow to actually kick in. The name is left
   to wrap instead — full, never cut off — which only grows that one row's own height and cannot
   move any other row's columns, since each column's width is shared across the whole list. */
.title {
  min-width: 0;
  overflow-wrap: break-word;
}

.addr {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Explicit column numbers, not DOM order: a row missing e.g. .ptype must not shift .score, the
   Maps link and the controls one column left and out of line with every other row that has it. */
.title { grid-column: 1; font-weight: 600; }
.addr { grid-column: 2; color: var(--muted-foreground); font-size: 0.88rem; }
.rate { grid-column: 3; white-space: nowrap; font-size: 0.88rem; }
.ptype { grid-column: 4; }
.score { grid-column: 5; white-space: nowrap; font-size: 0.82rem; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.maps-link { grid-column: 6; white-space: nowrap; }

#limit { flex: 0 0 6rem; }
.boxes { grid-column: 7; display: flex; gap: 0.9rem; font-size: 0.88rem; white-space: nowrap; justify-self: end; }
.boxes label { cursor: pointer; }

.detail {
  padding: 0.3rem 1rem 1.3rem;
  font-size: 0.9rem;
}

.detail ul { margin: 0; padding-left: 1.2rem; }

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0.6rem 0 0;
}

.facts dt { color: var(--muted-foreground); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.chip {
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--accent);
  font-size: 0.82rem;
  white-space: nowrap;
}

.chip.no { color: var(--muted-foreground); background: transparent; }

.review {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  margin: 0.5rem 0;
  padding-left: 0.7rem;
  border-left: 2px solid var(--border);
}

.review .who { color: var(--muted-foreground); }
.review .text { flex: 1 1 100%; }

.photos { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.photos img { height: 120px; border-radius: var(--radius); display: block; }

#submitBar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 1.2rem;
}

#showAllLabel {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  cursor: pointer;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin-bottom: 0.8rem;
}

.toolbar label { font-size: 0.85rem; color: var(--muted-foreground); }

.counts { font-size: 0.85rem; color: var(--muted-foreground); }

.decided {
  font-size: 0.8rem;
  color: var(--muted-foreground);
  text-transform: capitalize;
}

#pager {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 1rem;
}

/* per-row decisions: small, quiet until hovered, so 50 rows do not read as a wall of buttons */
.actions {
  grid-column: 7;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  justify-self: end;
}

.actions button {
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 500;
  background: transparent;
  border-color: var(--border);
  color: var(--foreground);
}

.actions button.approve {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
}

.actions button.approve:hover:not(:disabled) {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  opacity: 1;
}

.actions button.reject, .actions button.requeue { color: var(--muted-foreground); }

.actions button.reject:hover:not(:disabled) {
  color: var(--destructive);
  border-color: color-mix(in srgb, var(--destructive) 45%, transparent);
  background: color-mix(in srgb, var(--destructive) 12%, transparent);
  opacity: 1;
}

/* a decided row stays put so the admin keeps their place, but stops competing for attention */
.row.done { opacity: 0.45; }
.row.done summary { cursor: default; }

.actions label.pick { margin-right: 0.15rem; }

/* what Google thinks the place is, and which query found it */
.ptype {
  font-size: 0.78rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}

@media (max-width: 720px) {
  .shell { flex-direction: column; min-height: 0; }

  .sidebar {
    flex: 0 0 auto;
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
    padding: 0.6rem 0.75rem;
  }

  .sidebar nav { flex-direction: row; gap: 0.35rem; overflow-x: auto; }
  .sidebar nav a.active::before { display: none; }

  #appView { max-width: none; padding: 1.25rem 1rem 3rem; }

  /* the grid columns exist to keep a wide row aligned; on a narrow screen there is no "aligned
     with the row above" to preserve, so stack each field on its own line and let text wrap. */
  .row summary {
    grid-template-columns: 1fr;
    row-gap: 0.3rem;
  }

  .title, .addr, .rate, .ptype, .score, .maps-link, .boxes, .actions {
    grid-column: 1;
    justify-self: start;
  }

  .title, .addr {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
}
