/* DIAB House of Textile store system. Brand: charcoal + copper + cream (from the DIAB logo). */
:root {
  --ink: #1b1a19;
  --ink-2: #2b2926;
  --ink-3: #3a3733;
  --copper: #c8915c;
  --copper-strong: #a86f3a;
  --copper-soft: #f3e4d3;
  --cream: #f6f1ea;
  --paper: #fffdf9;
  --line: #e7ddd0;
  --text: #24211e;
  --muted: #7a6f64;
  --ok: #2f7a55;
  --ok-soft: #e3f2ea;
  --warn: #a8660b;
  --warn-soft: #fbefd9;
  --bad: #b1402d;
  --bad-soft: #f9e3de;
  --info: #2f5f8a;
  --info-soft: #e3edf7;
  --wa: #1f9d55;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(27, 26, 25, .06), 0 4px 16px rgba(27, 26, 25, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--text);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--copper-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; margin-top: 1.2em; }
code { background: var(--copper-soft); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.site-header {
  background: var(--ink);
  background-image: radial-gradient(circle at 50% -20%, #34302b 0%, var(--ink) 60%);
  color: var(--cream);
  text-align: center;
  padding: 0 0 4px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: .85rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar .who small { color: var(--copper); margin-left: 4px; }
.topbar form { margin: 0; }
.chip { background: rgba(200, 145, 92, .18); color: var(--copper); padding: 3px 10px; border-radius: 99px; }
.branch-switch select {
  background: var(--ink-2); color: var(--cream); border: 1px solid var(--ink-3);
  padding: 5px 8px; border-radius: 8px; font-size: .85rem; max-width: 46vw;
}
.link-btn { background: none; border: 0; color: var(--copper); cursor: pointer; font: inherit; padding: 4px; }
.link-btn:hover { text-decoration: underline; }

.brand { display: inline-flex; flex-direction: column; align-items: center; padding: 18px 16px 12px; color: var(--cream); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 120px; height: 120px; object-fit: contain; }
.brand-name {
  font-family: var(--serif); font-size: 2.1rem; letter-spacing: .32em; margin: 6px 0 0 .32em; color: #fff;
}
.brand-tag { font-size: .72rem; letter-spacing: .28em; text-transform: uppercase; color: var(--copper); }

.mainnav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 12px 10px;
  justify-content: flex-start;
  scrollbar-width: none;
}
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  flex: 0 0 auto;
  color: #d9cfc4;
  padding: 7px 14px;
  border-radius: 99px;
  font-size: .9rem;
  font-weight: 500;
}
.mainnav a:hover { background: var(--ink-3); text-decoration: none; color: #fff; }
.mainnav a.active { background: var(--copper); color: var(--ink); }
@media (min-width: 900px) { .mainnav { justify-content: center; } .brand-logo { width: 140px; height: 140px; } }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; flex: 1; }
.container.narrow { max-width: 760px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin-bottom: 2px; }
.page-head p { margin: 0; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.subcard { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary h2, details > summary h3 { display: inline-block; margin: 0; }
details > summary::after { content: " ▾"; color: var(--muted); }
details[open] > summary { margin-bottom: 12px; }
.center { text-align: center; }
.danger-zone { border-color: var(--bad-soft); }

.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .g2, .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
}
@media (min-width: 980px) {
  .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.span-full { grid-column: 1 / -1; }
.grid > * { min-width: 0; } /* wide tables scroll inside their card instead of stretching the column */
.grid > .card { margin-bottom: 0; }
.grid + .card, .grid + .grid, .card + .grid { margin-top: 16px; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--ink);
  color: #b9ada0;
  text-align: center;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  font-size: .82rem;
  line-height: 1.8;
}
.site-footer a { color: var(--copper); font-weight: 600; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > .label { font-size: .82rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid #d9cdbf;
  border-radius: 9px;
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--copper); outline-offset: 0; border-color: var(--copper); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--copper-strong); }
.check { display: flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--text) !important; cursor: pointer; margin: 6px 0; }
.input-sm { min-height: 34px; padding: 5px 8px; width: 110px; font-size: .85rem; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 2px 0; }
.actions, .btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.page-head .btn-row { margin-top: 0; }
.filters .btn-row { margin-top: 12px; }

.phone-input { display: flex; gap: 6px; }
.phone-input select { flex: 0 0 auto; width: 132px; }
.phone-input .cc-other { flex: 0 0 76px; }
.phone-input input[type="tel"] { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px;
  border-radius: 9px; border: 1px solid #d3c5b5;
  background: #fff; color: var(--text);
  font: 600 .92rem var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--copper-soft); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-3); }
.btn-outline { border-style: dashed; border-color: var(--copper); color: var(--copper-strong); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #8f3323; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: #17834a; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .82rem; }
.btn-lg { min-height: 50px; padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon {
  background: none; border: 1px solid transparent; border-radius: 8px; width: 34px; height: 34px;
  cursor: pointer; color: var(--bad); font-size: 1rem;
}
.btn-icon:hover { background: var(--bad-soft); }

/* ---------- Big search ---------- */
.hero-search { max-width: 760px; margin: 6px auto 22px; }
.hint { text-align: center; color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
.bigsearch { position: relative; margin-bottom: 16px; }
.bigsearch-row { display: flex; gap: 8px; }
.bigsearch input[type="search"] {
  font-size: 1.1rem; min-height: 56px; padding: 12px 18px; border-radius: 14px;
  border: 2px solid var(--copper); box-shadow: var(--shadow);
}
.bigsearch .btn { min-height: 56px; border-radius: 14px; padding: 0 22px; }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(27, 26, 25, .18); overflow: hidden; max-height: 70vh; overflow-y: auto;
}
.sr-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.sr-main { flex: 1; display: flex; flex-direction: column; color: var(--text); min-width: 0; }
.sr-main:hover { text-decoration: none; }
.sr-main strong { font-size: 1rem; }
.sr-phone { color: var(--copper-strong); font-weight: 600; font-size: .9rem; }
.sr-main small { color: var(--muted); }
.sr-item:hover { background: var(--cream); }
.sr-add, .sr-more { display: block; padding: 14px; font-weight: 700; text-align: center; }
.sr-add { background: var(--copper-soft); color: var(--ink); }
.sr-more { border-bottom: 1px solid var(--line); }

/* ---------- Stats ---------- */
.stats { margin-bottom: 16px; }
.stat {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
  border-top: 3px solid var(--copper);
}
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.55rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-value.small-value { font-size: 1.05rem; }
.stat-sub { font-size: .82rem; color: var(--muted); }
.stat-warn { border-top-color: var(--warn); }
.stat-warn .stat-value { color: var(--warn); }
.stat-ok { border-top-color: var(--ok); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: #fbf7f1; }
.table tfoot td { border-bottom: 0; padding: 6px 10px; }
.table tr.voided td { opacity: .5; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.small { font-size: .82rem; }
.pre { white-space: pre-line; }
.break { word-break: break-word; max-width: 360px; }
.muted { color: var(--muted); }
.text-bad { color: var(--bad); }
.text-ok { color: var(--ok); }
.empty { color: var(--muted); text-align: center; padding: 18px; margin: 0; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: .85rem; font-weight: 600; }
.dl dd { margin: 0; }

/* ---------- Badges & alerts ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700;
  vertical-align: middle; white-space: nowrap; background: #eee; color: #444;
}
.st-new { background: var(--info-soft); color: var(--info); }
.st-in_production { background: var(--warn-soft); color: var(--warn); }
.st-ready { background: var(--copper-soft); color: var(--copper-strong); }
.st-installed, .st-delivered { background: var(--ok-soft); color: var(--ok); }
.st-cancelled { background: var(--bad-soft); color: var(--bad); }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); color: #1d5a3c; border-color: #bfe0cd; }
.alert-error { background: var(--bad-soft); color: #7d2a1b; border-color: #efc2b8; }
.alert-warning { background: var(--warn-soft); color: #6d4306; border-color: #efd5a6; }
.alert-info { background: var(--info-soft); color: #1f4466; border-color: #c4d6e8; }
.alert ul { margin: 6px 0; padding-left: 20px; }

.checklist { list-style: none; padding: 0; }
.checklist li { padding: 4px 0; }
.checklist .ok { color: var(--ok); }
.checklist .bad { color: var(--bad); font-weight: 600; }

/* ---------- Login ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 10px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .field { margin-bottom: 14px; }

/* ---------- Order builder ---------- */
.items-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; }
.item-row {
  background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--copper);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.item-row-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.item-row-head .item-type { max-width: 260px; }
.item-row-head .item-num { flex: 0 0 auto; }
.item-row-head .btn-icon { margin-left: auto; }
.item-row[data-type="product"] .custom-only,
.item-row[data-type="product"] .not-product,
.item-row[data-type="service"] .custom-only,
.item-row[data-type="service"] .product-field { display: none; }
.item-row[data-type="product"] .product-field .custom-only { display: none; }
.item-total { text-align: right; margin-top: 10px; color: var(--muted); }
.item-total strong { color: var(--ink); font-size: 1.05rem; }
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); max-height: 300px; overflow-y: auto;
}
.ac-item {
  display: block; width: 100%; text-align: left; padding: 9px 12px; background: none; border: 0;
  border-bottom: 1px solid var(--line); cursor: pointer; font: inherit; color: var(--text);
}
.ac-item:hover, .ac-item:focus { background: var(--cream); }
.ac-item small { display: block; color: var(--muted); }
.ac-empty { padding: 10px 12px; color: var(--muted); }

.totals-card { margin-top: 16px; }
.totals { margin: 18px 0; border-top: 1px solid var(--line); padding-top: 12px; }
.totals > div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .t-big { font-size: 1.3rem; border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; }
.totals .t-rest strong { color: var(--bad); font-size: 1.15rem; }
.pay-form { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 4px; }

/* ---------- Expenses "Pay" ---------- */
.pay-box > summary { display: inline-flex; }
.pay-box > summary::after { content: none; }
.pay-box[open] > summary { margin-bottom: 16px; }
.pay-form-inner .btn-lg { margin-top: 6px; }

/* ---------- WhatsApp ---------- */
.wa-composer { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Tabs, filters ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 14px; cursor: pointer;
  font: 600 .9rem var(--font); color: var(--muted);
}
.tab.active { color: var(--ink); border-bottom-color: var(--copper); }
.filters-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters-row input[type="date"] { width: auto; min-height: 40px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.seg a { padding: 6px 12px; border-radius: 7px; color: var(--text); font-size: .88rem; font-weight: 500; }
.seg a:hover { background: var(--cream); text-decoration: none; }
.seg a.active { background: var(--ink); color: #fff; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; color: var(--muted); font-size: .88rem; }

/* ---------- Chart: one series, thin rounded bars, recessive axis ---------- */
.barchart { position: relative; padding-top: 22px; }
.barchart-max { position: absolute; top: 0; left: 0; font-size: .75rem; color: var(--muted); }
.barchart-bars {
  height: 200px; display: flex; align-items: flex-end; gap: 2px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, var(--line) 1px, transparent 1px) 0 0 / 100% 50%;
}
.bar-col { position: relative; flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline: none; cursor: default; }
.bar { width: 100%; max-width: 22px; background: var(--copper-strong); border-radius: 4px 4px 0 0; min-height: 0; }
.bar-col:hover .bar, .bar-col:focus .bar { background: var(--ink); }
.bar-tip {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 6px 10px; border-radius: 8px; font-size: .78rem;
  white-space: nowrap; z-index: 5; pointer-events: none; text-align: center;
}
.bar-col:hover .bar-tip, .bar-col:focus .bar-tip { display: block; bottom: auto; top: -8px; transform: translate(-50%, -100%); }
.barchart-axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: 4px; }
.table-view { margin-top: 12px; }
.table-view summary { color: var(--copper-strong); font-weight: 600; font-size: .88rem; }

.meter { height: 5px; background: var(--line); border-radius: 3px; margin-top: 4px; max-width: 140px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--copper); }
.logo-preview { background: var(--ink); border-radius: var(--radius); padding: 16px; display: inline-block; margin-bottom: 10px; }
.logo-preview img { width: 110px; height: 110px; object-fit: contain; }

/* ---------- Small screens ---------- */
@media (max-width: 639px) {
  h1 { font-size: 1.35rem; }
  .card { padding: 14px; }
  .brand { padding-top: 12px; }
  .brand-logo { width: 96px; height: 96px; }
  .brand-name { font-size: 1.7rem; }
  .stat-value { font-size: 1.3rem; }
  .bigsearch .btn { padding: 0 14px; }
  .topbar .who small { display: none; }
  .dl { grid-template-columns: 1fr; gap: 0; }
  .dl dd { margin-bottom: 8px; }
}

/* ---------- Print (receipts, closings) ---------- */
.print-only { display: none; }
@media print {
  body { background: #fff; font-size: 12px; }
  .topbar, .mainnav, .no-print, .site-footer, .alert, .btn, .bigsearch { display: none !important; }
  .print-only { display: block; }
  .site-header { background: #fff !important; color: #000; padding: 0; }
  .brand { color: #000; padding: 0 0 6px; }
  .brand-logo { width: 70px; height: 70px; }
  .brand-name { color: #000; font-size: 1.4rem; }
  .card, .stat { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .container { padding: 0; max-width: none; }
  a { color: #000; }
  .receipt-foot { text-align: center; margin-top: 20px; font-style: italic; }
}
