/* Car-Wash admin. One stylesheet, no external fonts or CDNs (the CSP allows
   only this origin). Light by default, dark when the device asks for it.
   Phone first: tables turn into stacked cards under 720px. */

:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #18202f;
  --muted: #5d6880;
  --line: #e1e6f0;
  --brand: #1f6feb;
  --brand-ink: #ffffff;
  --side: #101828;
  --side-ink: #c9d3e6;
  --side-active: #1f6feb;
  --good-bg: #e3f6ea; --good-ink: #116034;
  --wait-bg: #fff4d6; --wait-ink: #7a5300;
  --bad-bg:  #fde7e7; --bad-ink:  #9b1c1c;
  --plain-bg:#edf0f6; --plain-ink:#3b4558;
  --danger: #c62828;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1220;
    --panel: #151c2e;
    --ink: #e6ebf5;
    --muted: #9aa6bf;
    --line: #26304a;
    --brand: #4c8dff;
    --side: #0a0f1b;
    --side-ink: #aab6cf;
    --good-bg: #123522; --good-ink: #7ee2a8;
    --wait-bg: #3a2e0b; --wait-ink: #ffd36b;
    --bad-bg:  #3d1416; --bad-ink:  #ff9c9c;
    --plain-bg:#232c43; --plain-ink:#c4cee3;
    --danger: #ff6b6b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Armenian", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 28px 0 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---- shell: sidebar on wide screens, top bar on phones ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  min-width: 0;
  background: var(--side);
  color: var(--side-ink);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { color: #fff; font-weight: 700; font-size: 18px; padding: 0 10px; }
.brand span { color: var(--side-active); margin-left: 4px; font-weight: 600; }
.brand:hover { text-decoration: none; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  color: var(--side-ink);
  padding: 9px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
}
.side nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.side nav a[aria-current="page"] { background: var(--side-active); color: #fff; font-weight: 600; }
.badge {
  background: #f59e0b;
  color: #1b1300;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 0 8px;
  line-height: 20px;
}
.me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 13px; }
.me strong { color: #fff; display: block; }
.me form { margin-top: 8px; }

.main { padding: 28px 32px 48px; min-width: 0; max-width: 1240px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  /* minmax(0, 1fr): a plain 1fr column grows to its content's min width,
     and the scrolling nav would then push the page wider than the phone. */
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: sticky;
    height: auto;
    padding: 10px 12px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    z-index: 10;
    flex-wrap: wrap;
  }
  .side nav {
    flex-direction: row;
    overflow-x: auto;
    order: 3;
    width: 100%;
    gap: 4px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .side nav a { padding: 7px 10px; font-size: 14px; }
  .me { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: 10px; }
  .me .who { display: none; }
  .me form { margin: 0; }
  .main { padding: 18px 16px 40px; }
}

/* ---- cards, panels ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  color: var(--ink);
  display: block;
}
a.card:hover { text-decoration: none; border-color: var(--brand); }
.card .v { font-size: 28px; font-weight: 700; line-height: 1.2; }
.card .l { color: var(--muted); font-size: 13px; }
.card.attention { border-color: #f59e0b; background: var(--wait-bg); }
.card.attention .v, .card.attention .l { color: var(--wait-ink); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---- tables (cards on phones) ---- */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; background: var(--plain-bg); }
.table tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 720px) {
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table { background: transparent; border: 0; box-shadow: none; }
  .table thead { display: none; }
  .table tr { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 0; box-shadow: var(--shadow); }
  /* Label floats left, the value (text, pills, links together) flows right. */
  .table td { border: 0; padding: 6px 14px; text-align: right; overflow-wrap: anywhere; }
  .table td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--muted); font-size: 13px; text-align: left; }
  .table td::after { content: ""; display: table; clear: both; }
  .row-actions { justify-content: flex-end; }
}

/* ---- pills ---- */
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.good  { background: var(--good-bg);  color: var(--good-ink); }
.pill.wait  { background: var(--wait-bg);  color: var(--wait-ink); }
.pill.bad   { background: var(--bad-bg);   color: var(--bad-ink); }
.pill.plain { background: var(--plain-bg); color: var(--plain-ink); }

/* ---- buttons, forms ---- */
.btn, button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 7px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
  white-space: nowrap;
}
.btn:hover, button:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary, button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.good, button.good { background: var(--good-bg); color: var(--good-ink); border-color: transparent; }
.btn.danger, button.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost, button.ghost { background: transparent; }
.btn.small, button.small { padding: 4px 10px; font-size: 13px; }
.side button.link { background: transparent; border: 1px solid rgba(255, 255, 255, .18); color: var(--side-ink); padding: 4px 10px; font-size: 13px; }
form.inline { display: inline; margin: 0; }

.form { display: grid; gap: 16px; max-width: 560px; }
.field label, .field .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.field .err { color: var(--danger); font-size: 13px; margin-top: 4px; font-weight: 600; }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--danger); }
textarea { min-height: 110px; resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters .btn[aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.filters input[type=search] { max-width: 260px; flex: 1 1 180px; }

/* ---- messages ---- */
.flash { border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; font-weight: 500; }
.flash-ok { background: var(--good-bg); color: var(--good-ink); }
.flash-error, .alert { background: var(--bad-bg); color: var(--bad-ink); }
.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.note { background: var(--plain-bg); color: var(--plain-ink); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---- chat ---- */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 14px; background: var(--plain-bg); }
.msg.mine { align-self: flex-end; background: var(--brand); color: #fff; }
.msg .meta { font-size: 12px; opacity: .75; margin-bottom: 2px; }
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- issues ---- */
.issue-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.issue-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.issue .form { margin-top: 12px; }

/* ---- sign-in ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login .brand-big { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login .brand-big span { color: var(--brand); }
.login .form { max-width: none; }
.login button { width: 100%; justify-content: center; padding: 10px; }

/* ---- confirm ---- */
.confirm { max-width: 560px; }
.confirm .danger-zone { border-left: 4px solid var(--danger); }
.flush { margin-top: 0; }
.filters select { width: auto; max-width: 260px; }
