/* AquaFlow control panel — single stylesheet, no build step. */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #0284c7;
  --brand-dark: #075985;
  --brand-light: #e0f2fe;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --sidebar: #0b2740;
  --sidebar-2: #103a5c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; font-size: .9em; }

/* ---------- auth / installer ---------- */

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #0b2740 0%, #0e7490 60%, #38bdf8 140%);
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(2, 20, 40, .35);
}
.install-card { max-width: 640px; }
.auth-brand { display: flex; align-items: center; gap: .5rem; font-size: 1.15rem; margin-bottom: .25rem; }
.auth-brand .drop { font-size: 1.5rem; }
.auth-foot { margin: 1.25rem 0 0; text-align: center; font-size: .9rem; }

/* ---------- app shell ---------- */

.app { display: block; }
.nav-toggle { display: none; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 30;
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.1rem .9rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand .drop { font-size: 1.6rem; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: #fff; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text small { color: #7dd3fc; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }

.nav { padding: .6rem 0; flex: 1; }
.nav-group {
  padding: .9rem 1.1rem .3rem;
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: #64748b;
}
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem 1.1rem;
  color: #cbd5e1; font-size: .9rem; text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(56, 189, 248, .14); color: #fff; border-left-color: #38bdf8; }
.nav-icon { width: 1.25rem; text-align: center; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding: .5rem 0 1rem; }
.version { padding: .6rem 1.1rem 0; font-size: .7rem; color: #475569; }

.content { margin-left: 250px; min-height: 100vh; display: flex; flex-direction: column; }
.content-inner { padding: 1.25rem; flex: 1; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.hamburger { display: none; font-size: 1.35rem; cursor: pointer; }
.page-title { font-size: 1.1rem; margin: 0; }
.topbar-stats { margin-left: auto; display: flex; gap: 1rem; font-size: .85rem; color: var(--muted); }
.topbar-stats strong { color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: .85rem; }
.who { display: flex; align-items: center; gap: .5rem; }
.who-text { display: flex; flex-direction: column; line-height: 1.15; }
.who-text strong { font-size: .85rem; }
.who-text small { font-size: .7rem; color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 600;
}

/* ---------- cards, grids ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.1rem;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 1rem; }
.card-body.tight { padding: .5rem 1rem; }

.grid { display: grid; gap: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.1rem; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.1rem; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 1.1rem; }

/* ---------- stats ---------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-value { font-size: 1.65rem; font-weight: 700; margin-top: .2rem; letter-spacing: -.02em; }
.stat-sub { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.stat-accent { border-top: 3px solid var(--brand); }
.trend-up { color: var(--ok); font-weight: 600; }
.trend-down { color: var(--danger); font-weight: 600; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th {
  font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2); white-space: nowrap;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 700; background: var(--surface-2); }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty-icon { font-size: 2rem; display: block; margin-bottom: .35rem; }

/* ---------- badges & alerts ---------- */

.badge {
  display: inline-block; padding: .16rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--border); color: var(--muted); }

.alert { padding: .7rem .9rem; border-radius: 10px; margin-bottom: .9rem; font-size: .9rem; border: 1px solid transparent; }
.alert p { margin: .35rem 0 0; }
.alert-success, .alert-ok { background: var(--ok-bg); color: #065f46; border-color: #a7f3d0; }
.alert-warn { background: var(--warn-bg); color: #92400e; border-color: #fde68a; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-info { background: var(--info-bg); color: #1e40af; border-color: #bfdbfe; }
.danger-text { color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .25rem; border-bottom: 1px solid var(--border); font-size: .88rem;
}
.alert-list li:last-child { border-bottom: 0; }
.dot { width: .55rem; height: .55rem; border-radius: 50%; flex: none; }
.dot-danger { background: var(--danger); }
.dot-warn { background: #f59e0b; }
.dot-info { background: var(--info); }

/* ---------- forms ---------- */

.stack { display: flex; flex-direction: column; gap: .75rem; }
label { display: block; font-size: .82rem; font-weight: 600; color: #334155; }
input, select, textarea {
  width: 100%; padding: .5rem .65rem; margin-top: .25rem;
  border: 1px solid #cbd5e1; border-radius: 8px;
  font: inherit; font-size: .9rem; color: var(--text); background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(2, 132, 199, .15);
}
input[readonly] { background: var(--surface-2); }
textarea { min-height: 76px; resize: vertical; }
label.check, label.inline { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
label.check input, label.inline input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: .9rem; margin: 0 0 1rem; }
legend { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 .35rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
  background: var(--surface); color: var(--text); border-color: #cbd5e1;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-dark { background: var(--sidebar); border-color: var(--sidebar); color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.filters {
  display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end;
}
.filters label { font-size: .75rem; }
.filters input, .filters select { min-width: 150px; }
.search-input { min-width: 220px; }

.code-block {
  background: #0f172a; color: #e2e8f0; padding: .9rem; border-radius: 8px;
  font-size: .8rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}

/* ---------- POS ---------- */

.pos { display: grid; grid-template-columns: 1fr 380px; gap: 1.1rem; align-items: start; }
.pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .7rem; }
.pos-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: .7rem; cursor: pointer; text-align: left; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .2rem; font: inherit;
}
.pos-tile:hover { border-color: var(--brand); background: var(--brand-light); }
.pos-tile .name { font-weight: 600; font-size: .87rem; }
.pos-tile .price { color: var(--brand-dark); font-weight: 700; }
.pos-tile .meta { font-size: .72rem; color: var(--muted); }
.pos-cart { position: sticky; top: 4.2rem; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: .3rem; padding: .5rem 0; border-bottom: 1px dashed var(--border); }
.cart-line .cl-name { font-size: .87rem; font-weight: 600; }
.cart-line .cl-controls { display: flex; align-items: center; gap: .3rem; }
.cart-line input.cl-qty { width: 58px; text-align: center; margin: 0; padding: .25rem; }
.cart-line input.cl-price { width: 76px; text-align: right; margin: 0; padding: .25rem; }
.totals { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; margin-top: .6rem; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-size: 1.25rem; font-weight: 800; border-top: 2px solid var(--border); padding-top: .5rem; margin-top: .25rem; }
.pill-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.pill {
  padding: .35rem .7rem; border-radius: 999px; border: 1px solid #cbd5e1;
  background: #fff; cursor: pointer; font-size: .82rem; font-weight: 600;
}
.pill.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- charts ---------- */

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }

/* ---------- receipt ---------- */

.receipt {
  max-width: 340px; margin: 1.5rem auto; padding: 1rem 1.25rem;
  background: #fff; font-family: "SFMono-Regular", Consolas, monospace; font-size: .8rem; color: #000;
}
.receipt h2 { text-align: center; font-size: 1rem; }
.receipt .center { text-align: center; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td { padding: .12rem 0; vertical-align: top; }
.receipt .rule { border-top: 1px dashed #000; margin: .5rem 0; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .receipt { margin: 0; max-width: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos { grid-template-columns: 1fr; }
  .pos-cart { position: static; }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .nav-toggle:checked ~ .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .content { margin-left: 0; }
  .hamburger { display: inline; }
  .topbar-stats { display: none; }
  .who-text { display: none; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content-inner { padding: .9rem; }
}
