/* Water Station: touch-first styles. Loaded after Bootstrap, so these rules win. */
:root {
  --ink: #0f2a3a;
  --muted: #3b5565;
  --soft: #4a6372;
  --bg: #f2f6f8;
  --line: #dce6eb;
  --line2: #e3ecf0;
  --rail: #0b3c52;
  --primary: #0b6e8c;
  --primary-d: #08516a;
  --primary-l: #e4f3f8;
  --ok: #0b4a2f;
  --ok-bg: #d5f0e2;
  --warn: #6b3f00;
  --warn-bg: #ffe9bd;
  --bad: #7e160f;
  --bad-bg: #fcdad7;
  --err: #b3261e;
  --gray: #33444f;
  --gray-bg: #e3e8ec;
  --rail-w: 104px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); }
a, button, input, select, textarea { touch-action: manipulation; }
h1, h2, h3 { line-height: 1.2; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: #fff; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.icon { width: 1.4em; height: 1.4em; flex-shrink: 0; }
.muted { color: var(--soft); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ app shell */
.rail { display: none; }
.topbar {
  display: flex; position: sticky; top: 0; z-index: 20; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 16px; background: var(--rail); color: #fff;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: #fff; text-decoration: none; }
.topbar .brand .icon { color: #7fd6ee; }
.topbar form { margin: 0; display: flex; align-items: center; gap: 10px; font-size: .875rem; color: #cfe6ef; }
.topbar .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); min-height: 44px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(78px, 1fr); overflow-x: auto;
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 64px; color: var(--muted); text-decoration: none; font-size: .6875rem; font-weight: 500;
}
.tabbar a .icon { width: 24px; height: 24px; }
.tabbar a.active { color: var(--primary-d); background: var(--primary-l); font-weight: 700; }

.content { padding: 16px 16px 24px; max-width: 1320px; }
body.has-nav .content { padding-bottom: 96px; }
body.no-nav .content { max-width: 480px; margin: 5vh auto 0; padding: 20px; }

@media (min-width: 768px) {
  body.has-nav .rail {
    display: flex; position: fixed; inset: 0 auto 0 0; width: var(--rail-w); z-index: 20;
    flex-direction: column; gap: 6px; padding: 16px 10px; background: var(--rail); overflow-y: auto;
  }
  body.has-nav .content { margin-left: var(--rail-w); padding: 22px 26px 32px; }
  .topbar, .tabbar { display: none !important; }
}
.rail-brand { display: flex; justify-content: center; padding: 6px 0 14px; color: #7fd6ee; }
.rail-brand .icon { width: 34px; height: 34px; }
.rail-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 100%;
  min-height: 76px; border: 0; border-radius: 14px; background: transparent; color: #cfe6ef;
  font: inherit; font-size: .75rem; font-weight: 500; text-decoration: none; cursor: pointer;
}
.rail-link .icon { width: 26px; height: 26px; }
.rail-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.rail-link.active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 700; }
.rail-foot { margin: auto 0 0; }

@media (max-width: 767.98px) { .hide-sm { display: none !important; } }
@media (min-width: 768px) { .show-sm { display: none !important; } }

/* ------------------------------------------------------------- page bits */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-title { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
.page-sub { margin-top: 2px; color: var(--soft); font-size: .95rem; }
@media (min-width: 768px) { .page-title { font-size: 1.75rem; } }
.back-link { display: inline-flex; align-items: center; min-height: 48px; margin-top: 12px; font-weight: 600; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.panel-title { margin: 0; font-size: 1rem; font-weight: 700; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.panel-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; font-size: .9rem; }
.stack { display: grid; gap: 14px; }

/* -------------------------------------------------------------- messages */
.flash {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 16px; margin-bottom: 12px; border-radius: 12px; font-weight: 500;
}
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-danger { background: var(--bad-bg); color: var(--bad); }
.flash-warning { background: var(--warn-bg); color: var(--warn); }
.flash-info { background: #d8eef5; color: var(--primary-d); }
.flash .close { min-width: 44px; min-height: 44px; margin: -10px -12px -10px 0; border: 0; background: transparent; color: inherit; font-size: 1.5rem; line-height: 1; cursor: pointer; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px;
  padding: 0 1.1rem; border: 2px solid transparent; border-radius: 12px; font: inherit; font-weight: 600;
  line-height: 1.2; text-decoration: none; cursor: pointer; background: transparent; color: var(--ink);
}
.btn:focus-visible, a:focus-visible, .form-control:focus-visible, .form-select:focus-visible { outline: 3px solid #12a0c7; outline-offset: 2px; }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn .icon { width: 1.25em; height: 1.25em; }
.btn-lg { min-height: 56px; padding: 0 1.5rem; font-size: 1.05rem; border-radius: 14px; }
.btn-sm { min-height: 44px; padding: 0 .9rem; font-size: .95rem; }
.btn-icon { width: 48px; padding: 0; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); color: #fff; }
.btn-outline-primary { background: #fff; border-color: var(--primary); color: var(--primary-d); }
.btn-outline-primary:hover { background: var(--primary-l); }
.btn-outline-secondary { background: #fff; border-color: #b9cbd4; color: var(--ink); }
.btn-outline-secondary:hover { background: #f2f6f8; }
.btn-outline-danger { background: #fff; border-color: #e6b8b3; color: var(--bad); }
.btn-outline-danger:hover { background: #fdf0ef; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #8c1d18; border-color: #8c1d18; color: #fff; }
.btn-success { background: #0b7a4b; border-color: #0b7a4b; color: #fff; }
.btn-success:hover { background: #086039; border-color: #086039; color: #fff; }
.btn-link { color: var(--primary-d); border-color: transparent; }
.btn-link:hover { text-decoration: underline; }
.inline-form { display: inline; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ----------------------------------------------------------------- forms */
.field { margin-bottom: 16px; }
.field-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: .95rem; }
.req { color: var(--err); }
.form-control, .form-select {
  display: block; width: 100%; min-height: 52px; padding: .65rem .9rem; font: inherit; font-size: 1rem;
  color: var(--ink); background-color: #fff; border: 1px solid #b9cbd4; border-radius: 12px;
}
.form-select { padding-right: 2.4rem; }
textarea.form-control { min-height: 96px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(18, 160, 199, .25); outline: 0; }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--err); border-width: 2px; }
.field-error { margin-top: 6px; color: var(--err); font-size: .9rem; font-weight: 600; }
.field-help { margin-top: 6px; color: var(--soft); font-size: .875rem; }
.field-help ul { margin: 4px 0 0; padding-left: 1.2rem; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 600; cursor: pointer; }
.check input { width: 1.5rem; height: 1.5rem; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 991.98px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .form-grid { grid-template-columns: 1fr; } }
.form-narrow { max-width: 620px; }
.form-note { color: var(--soft); font-size: .875rem; margin: 0 0 16px; }

.search-box { position: relative; }
.search-box .icon { position: absolute; left: 14px; top: 15px; width: 22px; height: 22px; color: var(--soft); pointer-events: none; }
.search-box .form-control { padding-left: 46px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 260px; }
.toolbar .field { margin: 0; }

/* ----------------------------------------------------------------- pills */
.pill { display: inline-block; padding: 6px 12px; border-radius: 999px; font-size: .8125rem; font-weight: 600; white-space: nowrap; }
.pill-pending { background: var(--warn-bg); color: var(--warn); }
.pill-completed, .pill-paid, .pill-active { background: var(--ok-bg); color: var(--ok); }
.pill-cancelled, .pill-inactive { background: var(--gray-bg); color: var(--gray); }
.pill-unpaid { background: var(--bad-bg); color: var(--bad); }

/* --------------------------------------------------------------- segments */
.seg { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; background: #e1eaef; border-radius: 14px; overflow-x: auto; }
.seg a {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px;
  border-radius: 11px; color: var(--muted); text-decoration: none; font-weight: 500;
}
.seg a.active { background: #fff; color: var(--primary-d); font-weight: 700; box-shadow: 0 1px 3px rgba(11, 60, 82, .18); }
.count { padding: 2px 8px; border-radius: 999px; background: #cfdce3; color: #2b4352; font-size: .75rem; font-weight: 600; }
.seg a.active .count { background: #d8eef5; color: var(--primary-d); }

/* ----------------------------------------------------------------- tables */
.table-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th {
  padding: 14px 16px; background: #eaf1f4; color: var(--muted); font-size: .75rem; font-weight: 600;
  letter-spacing: .05em; text-align: left; text-transform: uppercase;
}
.tbl td { padding: 10px 16px; border-top: 1px solid var(--line2); vertical-align: middle; }
.tbl tbody tr { height: 72px; }
.tbl .r { text-align: right; }
.tbl .strong { font-weight: 700; }
.tbl-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); background: #f8fbfc; font-size: .875rem; color: var(--soft); }
.empty { padding: 40px 16px; text-align: center; color: var(--soft); }

.item-list { display: grid; gap: 12px; }
.item-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.item-card .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.item-card .title { font-size: 1.05rem; font-weight: 700; }
.item-card .meta { color: var(--soft); font-size: .875rem; }
.item-card .bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.price { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ------------------------------------------------------------- dashboard */
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
@media (max-width: 991.98px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-split { grid-template-columns: 1fr; } }
.tile { display: block; min-height: 100px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: #fff; color: inherit; text-decoration: none; }
a.tile:hover { border-color: var(--primary); }
.tile-label { color: var(--muted); font-size: .8125rem; font-weight: 500; }
.tile-value { margin-top: 4px; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile-sub { margin-top: 2px; font-size: .8125rem; color: var(--muted); }
.tile-sub.link-primary { color: var(--primary-d); font-weight: 600; }
.tile-sub.link-bad { color: var(--bad); font-weight: 600; }
@media (min-width: 768px) { .tile-value { font-size: 1.75rem; } }

.meter-row { margin-bottom: 16px; }
.meter-row .head { display: flex; justify-content: space-between; align-items: baseline; font-size: .95rem; }
.meter-row .head span:first-child { color: var(--muted); font-weight: 500; }
.meter-row .head span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.meter { height: 18px; margin-top: 6px; border-radius: 9px; background: #e1eaef; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 9px; background: var(--primary); }
.meter.done > span { background: #0b7a4b; }
.meter-note { margin-top: 5px; color: var(--muted); font-size: .8125rem; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding-top: 8px; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bar { width: 100%; max-width: 56px; border-radius: 8px 8px 0 0; background: #8dbfd0; }
.bar-today { background: var(--primary); }
.bar-val { margin-bottom: 4px; color: #1f4155; font-size: .6875rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-day { margin-top: 6px; color: var(--muted); font-size: .75rem; }
.bar-day.today { font-weight: 700; }

.row-link { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 6px 0; border-top: 1px solid var(--line2); color: inherit; text-decoration: none; }
.row-link .grow { flex: 1; min-width: 0; }
.row-link .grow strong { display: block; }

/* ------------------------------------------------------------- detail */
.kv .k { color: var(--soft); font-size: .8125rem; }
.kv .v { margin-bottom: 14px; }
.cols { display: grid; gap: 14px; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); align-items: start; }
@media (max-width: 991.98px) { .cols { grid-template-columns: 1fr; } }
.cols-form { max-width: 880px; }

/* --------------------------------------------------------- order editor */
.item-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 14px 0; border-top: 1px solid var(--line2); }
.item-row[hidden] { display: none; }
.item-row .field { margin: 0; }
.item-product { flex: 1 1 240px; min-width: 0; }
.qty-stepper { display: flex; align-items: center; gap: 6px; }
.qty-stepper .form-control { width: 76px; text-align: center; padding-left: 4px; padding-right: 4px; }
.qty-stepper .btn { width: 52px; min-height: 52px; padding: 0; font-size: 1.5rem; }
.line-total { min-width: 110px; margin-left: auto; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; align-self: center; }
.order-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; padding-top: 12px; border-top: 2px solid var(--line); }
.order-total strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }

.error-page { text-align: center; padding: 8vh 0; }
.error-page h1 { font-size: 2rem; }

/* ------------------------------------------------- employees, refills, loans */
.pill-bad, .pill-overdue { background: var(--bad-bg); color: var(--bad); }
.pill-soon, .pill-today { background: var(--warn-bg); color: var(--warn); }
.pill-later { background: var(--gray-bg); color: var(--gray); }
.pill-rider { background: #d8eef5; color: var(--primary-d); }
.pill-cleaner { background: var(--gray-bg); color: var(--gray); }
.grid-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.staff-card { display: flex; flex-direction: column; gap: 10px; }
.staff-card .name { font-size: 1.1rem; font-weight: 700; }
.staff-card .status { font-size: .95rem; }
.staff-card .earn { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 10px 12px; border-radius: 12px; background: #f3f8fa; }
.staff-card .earn strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.clock-form { display: grid; gap: 8px; }
.alert-line { padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-size: .9rem; }
.month-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-nav .label { min-width: 150px; text-align: center; font-weight: 700; }
.note-cell { max-width: 260px; white-space: normal; color: var(--muted); font-size: .875rem; }
.loan-row { padding: 12px 0; border-top: 1px solid var(--line2); }
.loan-row .inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.loan-row .form-control.qty { width: 84px; text-align: center; }
.stat-line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line2); }
.stat-line:first-of-type { border-top: 0; }
.stat-line span:first-child { color: var(--soft); }
.stat-line span:last-child { font-weight: 600; text-align: right; }
