/* ==========================================================================
   B2B Optimum Solutions — Admin panel
   One self-contained stylesheet. Layout: sidebar (desktop) -> icon rail
   (tablet) -> top bar + bottom tabs + drawer (phone). Tables become cards on
   phones using each cell's data-label.
   ========================================================================== */

:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --ink: #0c1433;
  --ink-2: #2a3454;
  --muted: #5a6585;
  --line: #e2e7f2;
  --line-strong: #cfd6e8;

  --brand: #0616b8;
  --brand-hover: #0a1fd6;
  --brand-ink: #050f8f;
  --brand-50: #eef1ff;
  --brand-100: #dde3ff;

  --accent: #f26322;
  --accent-ink: #b8430b;
  --accent-50: #fff1e8;

  --ok: #12703a;
  --ok-50: #e6f6ec;
  --warn: #a15c00;
  --warn-50: #fff4dc;
  --danger: #b4231a;
  --danger-50: #fdecea;

  --sb-w: 268px;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(12, 20, 51, .05), 0 4px 14px rgba(12, 20, 51, .04);
  --shadow-2: 0 10px 40px rgba(12, 20, 51, .16);
  --ease: cubic-bezier(.2, .8, .2, 1);

  --font: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.012em; }
a { color: var(--brand); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden], .hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted-text { color: var(--muted); }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; transition: top .15s; }
.skip-link:focus { top: 12px; }

/* ---------- Buttons ---------- */
.button, button.danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 999px;
  font-weight: 700; font-size: .95rem; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .12s var(--ease), color .15s;
}
.button.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(6, 22, 184, .22); }
.button.primary:hover { background: var(--brand-hover); }
.button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.button.secondary:hover { background: var(--surface-2); border-color: var(--brand); color: var(--brand-ink); }
.button.block { width: 100%; }
.button:active, button.danger:active { transform: scale(.97); }
button.danger { background: var(--danger-50); color: var(--danger); border-color: #f3c3be; }
button.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.compact-button { min-height: 36px; padding: 0 14px; font-size: .85rem; }
.button:disabled, button:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.button.is-busy { position: relative; }
.button.is-busy::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form controls ---------- */
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  font-size: 1rem; /* 16px stops iOS zooming on focus */
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
select {
  appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%232a3454' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 15px center;
}
input:hover, select:hover, textarea:hover { border-color: #9fabcd; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(6, 22, 184, .14); }
input[type="file"] { padding: 9px 12px; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
input::placeholder, textarea::placeholder { color: #8a94b1; }
label { display: grid; gap: 6px; font-weight: 700; font-size: .88rem; color: var(--ink-2); }
label > input, label > select, label > textarea { font-weight: 400; }
.stack-form { display: grid; gap: 16px; }

.admin-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px 18px; align-items: end;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(16px, 2.4vw, 26px); box-shadow: var(--shadow-1); margin-bottom: 20px;
}
.admin-form .wide { grid-column: 1 / -1; }
.admin-form > .button { justify-self: start; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.search-field { position: relative; }
.search-field svg { position: absolute; left: 13px; top: 50%; width: 17px; height: 17px; margin-top: -8.5px; fill: var(--muted); pointer-events: none; }
.search-field input { padding-left: 40px; min-height: 40px; border-radius: 999px; }
.search-field.compact { min-width: min(260px, 100%); }

/* ---------- Login ---------- */
.admin-shell { min-height: 100dvh; }
.login-panel {
  min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  background: var(--surface);
}
.login-brand {
  position: relative; overflow: hidden; display: flex; align-items: flex-end;
  padding: clamp(32px, 5vw, 72px);
  color: #fff;
  background:
    linear-gradient(160deg, rgba(5, 15, 143, .94), rgba(6, 22, 184, .86) 55%, rgba(7, 18, 58, .96)),
    url("/images/hero-business-management.jpg") center / cover no-repeat;
}
.login-brand::after {
  content: ""; position: absolute; right: -90px; top: -90px; width: 300px; height: 300px;
  border-radius: 50%; background: var(--accent); opacity: .92;
}
.login-brand-inner { position: relative; z-index: 1; max-width: 460px; }
.login-brand h2 { font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.12; font-weight: 800; letter-spacing: -.02em; }
.login-brand ul { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 12px; }
.login-brand li { position: relative; padding-left: 26px; color: rgba(255, 255, 255, .88); font-size: 1.02rem; }
.login-brand li::before { content: ""; position: absolute; left: 0; top: .5em; width: 12px; height: 12px; border-radius: 3px; background: var(--accent); }

.login-card {
  align-self: center; justify-self: center; width: min(440px, 100%);
  padding: clamp(28px, 5vw, 48px) clamp(20px, 4vw, 40px);
  display: grid; gap: 6px;
}
.login-logo { width: 150px; height: auto; margin-bottom: 18px; }
.login-card h1 { font-size: clamp(1.9rem, 4vw, 2.3rem); font-weight: 800; letter-spacing: -.025em; }
.login-lead { color: var(--muted); margin-bottom: 18px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 78px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  min-height: 34px; padding: 0 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--brand); font-weight: 700; font-size: .85rem;
}
.password-toggle:hover { background: var(--brand-50); }
.login-message {
  min-height: 0; margin-top: 14px; font-weight: 600; font-size: .92rem; color: var(--danger);
}
.login-message:not(:empty) {
  padding: 12px 14px; border-radius: 12px; background: var(--danger-50); border: 1px solid #f3c3be;
}
.login-message.ok:not(:empty) { color: var(--ok); background: var(--ok-50); border-color: #bfe3cc; }
.auth-back { margin-top: 18px; justify-self: start; font-weight: 600; font-size: .92rem; color: var(--muted); text-decoration: none; }
.auth-back:hover { color: var(--brand); }

/* ---------- Shell ---------- */
.dashboard {
  display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100dvh;
  transition: grid-template-columns .25s var(--ease);
}
.dashboard.sb-collapsed { --sb-w: 80px; }

.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 14px;
  padding: 18px 14px 14px; background: var(--surface); border-right: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain; z-index: 30;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 6px 10px; }
.sidebar-logo { width: 118px; height: auto; transition: width .25s var(--ease); }

.admin-nav { display: grid; gap: 3px; align-content: start; flex: 1; }
.admin-nav button {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px;
  background: transparent; color: var(--ink-2); font-weight: 600; font-size: .95rem; text-align: left;
  transition: background-color .15s, color .15s;
}
.admin-nav button svg { width: 20px; height: 20px; flex: none; fill: currentColor; opacity: .8; }
.admin-nav button[data-tab="sales"] svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.admin-nav button:hover { background: var(--surface-2); color: var(--ink); }
.admin-nav button.active { background: var(--brand-50); color: var(--brand-ink); }
.admin-nav button.active svg { opacity: 1; }
.admin-nav button.active::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand);
}
.nav-label { white-space: nowrap; }
.nav-badge {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: .75rem; font-weight: 800; font-style: normal;
}

.sidebar-foot { display: grid; gap: 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.sidebar-user, .sidebar-signout, .sidebar-collapse-toggle {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 10px;
  border: 0; border-radius: 12px; background: transparent; text-align: left; color: var(--ink-2); font-weight: 600;
}
.sidebar-user { min-height: 54px; }
.sidebar-user:hover, .sidebar-signout:hover, .sidebar-collapse-toggle:hover { background: var(--surface-2); }
.sidebar-signout svg, .sidebar-collapse-toggle svg { width: 20px; height: 20px; flex: none; fill: currentColor; opacity: .8; }
.sidebar-collapse-toggle svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s var(--ease); }
.dashboard.sb-collapsed .sidebar-collapse-toggle svg { transform: rotate(180deg); }
.sidebar-signout:hover { color: var(--danger); }
.avatar {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 800; font-size: .95rem;
}
.sidebar-user-text { display: grid; line-height: 1.2; min-width: 0; }
.sidebar-user-text strong { font-size: .93rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-text small { font-size: .78rem; color: var(--muted); font-weight: 500; }

.bell-button {
  position: relative; width: 42px; height: 42px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink-2);
}
.bell-button:hover { background: var(--surface-2); border-color: var(--line-strong); }
.bell-button svg { width: 19px; height: 19px; fill: currentColor; }
.bell-badge {
  position: absolute; top: -3px; right: -3px; min-width: 19px; height: 19px; padding: 0 5px; display: grid; place-items: center;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: .7rem; font-weight: 800; border: 2px solid var(--surface);
}

/* Collapsed rail */
.dashboard.sb-collapsed .sidebar { padding-inline: 10px; }
.dashboard.sb-collapsed .sidebar-head { flex-direction: column; padding-inline: 0; }
.dashboard.sb-collapsed .sidebar-logo { width: 48px; }
.dashboard.sb-collapsed .nav-label,
.dashboard.sb-collapsed .nav-badge { display: none; }
.dashboard.sb-collapsed .admin-nav button,
.dashboard.sb-collapsed .sidebar-user,
.dashboard.sb-collapsed .sidebar-signout,
.dashboard.sb-collapsed .sidebar-collapse-toggle { justify-content: center; padding: 0; }
.dashboard.sb-collapsed .admin-nav button.active::before { left: -10px; }

.admin-topbar-mobile, .bottom-nav, .sidebar-overlay { display: none; }

.admin-content { width: 100%; max-width: 1320px; margin-inline: auto; padding: clamp(18px, 3vw, 40px); outline: none; min-width: 0; }

/* ---------- Sections ---------- */
.admin-section { display: none; }
.admin-section.active { display: block; animation: sectionIn .28s var(--ease) both; }
@keyframes sectionIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.admin-section > * + * { margin-top: 20px; }
.admin-section > .admin-form + datalist, .admin-section > datalist { margin: 0; }

.admin-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px 24px; flex-wrap: wrap; }
.admin-heading h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; letter-spacing: -.025em; }
.eyebrow { margin-bottom: 4px; font-size: .84rem; font-weight: 700; color: var(--accent-ink); letter-spacing: 0; text-transform: none; }
#todayStamp { color: var(--muted); font-weight: 600; font-size: .95rem; }

/* ---------- Cards & KPI strips ---------- */
.panel-card, .table-wrap, .invite-result {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-1); padding: clamp(16px, 2.2vw, 26px);
}
.panel-card-head, .table-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-card-head h2, .table-title-row h2, .table-wrap > h2, .invite-result h2 { font-size: 1.15rem; font-weight: 800; }
.table-wrap > h2 { margin-bottom: 14px; }
.table-title-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.metric-card {
  position: relative; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 2px 12px;
  padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-1);
  overflow: hidden;
}
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--brand); }
.metric-card.accent-1::before { background: var(--accent); }
.metric-card.accent-5::before { background: var(--ok); }
.metric-card > span:not(.metric-icon) { grid-column: 1; grid-row: 2; font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric-card > p { grid-column: 1; grid-row: 1; color: var(--muted); font-weight: 600; font-size: .92rem; }
.metric-icon { grid-column: 2; grid-row: 1 / span 2; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--brand-50); }
.metric-icon svg { width: 22px; height: 22px; fill: var(--brand); }
.metric-card.accent-1 .metric-icon { background: var(--accent-50); }
.metric-card.accent-1 .metric-icon svg { fill: var(--accent-ink); }
.metric-card.accent-5 .metric-icon { background: var(--ok-50); }
.metric-card.accent-5 .metric-icon svg { fill: var(--ok); }

.month-summary-grid, .daily-summary, .closing-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.month-summary-grid article, .daily-summary article, .closing-summary article {
  display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 2px; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2);
}
.month-summary-grid article > span, .daily-summary article > span, .closing-summary article > span {
  font-size: clamp(1.15rem, 2vw, 1.45rem); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.015em;
}
.month-summary-grid article > p, .daily-summary article > p, .closing-summary article > p { color: var(--muted); font-size: .85rem; font-weight: 600; }
.daily-summary, .closing-summary { margin-bottom: 4px; }
.month-summary-grid article.highlight { background: var(--brand); border-color: var(--brand); color: #fff; }
.month-summary-grid article.highlight > p { color: rgba(255, 255, 255, .8); }
.deduction-summary-card > span { color: var(--danger); }

.month-select-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.month-filter-inputs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-filter-inputs input { width: auto; min-width: 160px; min-height: 40px; }
.range-arrow { color: var(--muted); }
.month-filter-mode { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.mode-pill { min-height: 34px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 700; font-size: .85rem; transition: background-color .15s, color .15s; }
.mode-pill.active { background: var(--ink); color: #fff; }
.closing-filter-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.closing-filter-controls select, .closing-filter-controls input { width: auto; min-height: 40px; }

.count-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.hint-text { color: var(--muted); font-size: .88rem; margin-bottom: 12px; }
.closed-notice { padding: 14px 16px; border-radius: 12px; background: var(--warn-50); border: 1px solid #f0d9a4; color: #6f4300; font-weight: 600; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; margin-inline: calc(clamp(16px, 2.2vw, 26px) * -1); padding-inline: clamp(16px, 2.2vw, 26px); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; padding: 10px 14px; text-align: left; font-size: .78rem; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line-strong); background: var(--surface); white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .12s; }
.daily-row-clickable, .sale-row-clickable { cursor: pointer; }
.daily-row-clickable:hover, .sale-row-clickable:hover, .closing-row:hover { background: var(--brand-50); }
.amount-cell { font-weight: 700; white-space: nowrap; }
td[data-label="Date"] { white-space: nowrap; }
.empty-row td { padding: 28px 14px; text-align: center; color: var(--muted); }
td a { font-weight: 600; }
.muted-name { color: var(--ink-2); font-weight: 600; }
.deduction-row td:nth-child(2) { color: var(--danger); font-weight: 700; }
.notes-cell { max-width: 320px; }
.notes-highlight { display: inline-block; padding: 2px 8px; border-radius: 8px; background: var(--warn-50); color: #6f4300; font-weight: 600; }
.notes-empty { color: #9aa4c0; }

.status-pill, .pill-tag, .request-status, .request-tag {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 11px; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap; text-transform: capitalize;
}
.status-pill.open { background: var(--accent-50); color: var(--accent-ink); }
.status-pill.closed { background: var(--ok-50); color: var(--ok); }
.pill-tag, .request-tag { background: var(--brand-50); color: var(--brand-ink); text-transform: none; }
.request-status.new { background: var(--accent-50); color: var(--accent-ink); }
.request-status.reviewed { background: var(--brand-50); color: var(--brand-ink); }
.request-status.handled { background: var(--ok-50); color: var(--ok); }

.expand-closing-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink-2); }
.expand-closing-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s var(--ease); }
tr.closing-row.open .expand-closing-btn svg { transform: rotate(90deg); }
.closing-detail-row { display: none; }
.closing-detail-row.open { display: table-row; }
.closing-detail-row > td { padding: 0 0 14px; background: var(--surface-2); }
.closing-detail-row table { background: var(--surface-2); }
.closing-detail-row th { background: var(--surface-2); }
.closing-note-inline { margin-top: 6px; font-size: .85rem; color: var(--muted); }

/* ---------- Requests / gallery / export / invites ---------- */
.requests-grid, .promo-admin-grid, .export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.request-card, .promo-admin-card {
  display: flex; flex-direction: column; gap: 10px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-1);
}
.request-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.request-card-top h3 { font-size: 1.05rem; }
.request-card-top time { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.request-tag { align-self: flex-start; }
.request-message { color: var(--ink-2); overflow-wrap: anywhere; white-space: pre-wrap; }
.request-card-contact { display: flex; flex-wrap: wrap; gap: 6px 16px; font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; }
.request-status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.request-status-row select { width: auto; min-height: 38px; font-size: .92rem; }

.promo-art { aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; border-radius: 12px; background: var(--brand-50); color: var(--brand-ink); font-weight: 700; text-align: center; padding: 8px; }
.promo-art img { width: 100%; height: 100%; object-fit: cover; }
.promo-admin-card h3 { font-size: 1.02rem; }
.promo-admin-card p { color: var(--muted); font-size: .92rem; }
.promo-admin-card .danger { margin-top: auto; align-self: flex-start; min-height: 38px; }

.export-grid { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.export-card { display: flex; flex-direction: column; gap: 10px; }
.export-card .button { margin-top: auto; align-self: flex-start; }
.export-card p { color: var(--muted); font-size: .92rem; }
.export-card h3 { font-size: 1.05rem; }
.export-card-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--brand); }
.export-card-icon svg { width: 21px; height: 21px; fill: #fff; }
.date-range-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.date-range-row input { flex: 1 1 140px; min-width: 0; }
.date-range-row span { color: var(--muted); }

.invite-result { display: grid; gap: 12px; border-color: #bfe3cc; background: var(--ok-50); }
.invite-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Notifications ---------- */
.notif-panel {
  position: fixed; z-index: 60; top: 14px; left: calc(var(--sb-w) + 10px); width: min(380px, calc(100vw - 24px));
  max-height: min(560px, calc(100dvh - 28px)); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); overflow: hidden;
  animation: pop .2s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.notif-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.notif-panel-head h3 { font-size: 1rem; }
.notif-panel-head button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; font-size: 1.5rem; line-height: 1; color: var(--muted); }
.notif-panel-head button:hover { background: var(--surface-2); }
.notif-panel-body { overflow-y: auto; }
.notif-item { display: grid; gap: 2px; padding: 13px 18px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.notif-item:hover { background: var(--brand-50); }
.notif-item strong { font-size: .92rem; }
.notif-item span { font-size: .85rem; color: var(--ink-2); overflow-wrap: anywhere; }
.notif-item .notif-time { font-size: .75rem; color: var(--muted); }
.notif-empty { padding: 28px 18px; text-align: center; color: var(--muted); grid-column: 1 / -1; }
.notif-panel-viewall { min-height: 46px; border: 0; border-top: 1px solid var(--line); background: var(--surface-2); color: var(--brand); font-weight: 700; }

/* ---------- Modal ---------- */
.sale-modal-overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(8, 14, 40, .55); backdrop-filter: blur(3px); animation: fade .18s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sale-modal { width: min(520px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-2); overflow: hidden; animation: pop .22s var(--ease) both; }
.sale-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.sale-modal-head h3 { font-size: 1.1rem; }
.sale-modal-head button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--surface-2); font-size: 1.5rem; line-height: 1; color: var(--ink-2); }
.sale-modal-body { padding: 20px 22px; overflow-y: auto; display: grid; gap: 16px; }
.sale-modal-notes { padding: 14px 16px; border-radius: 12px; background: var(--warn-50); }
.sale-modal-label { font-size: .78rem; font-weight: 700; color: #6f4300; margin-bottom: 4px; }
.sale-modal-notes-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.sale-modal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; margin: 0; }
.sale-modal-grid dt { font-size: .78rem; font-weight: 700; color: var(--muted); }
.sale-modal-grid dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.sale-modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; }
.account-modal .sale-modal-actions { padding: 6px 0 0; }
.account-who { display: grid; gap: 2px; }
.account-who span { font-size: .85rem; }
.account-modal h4 { font-size: 1rem; }

/* ---------- Toast ---------- */
.toast-region { position: fixed; z-index: 90; left: 50%; bottom: 22px; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); pointer-events: none; }
.message { display: none; margin: 0; padding: 13px 18px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: var(--shadow-2); pointer-events: auto; }
.message.show { display: block; animation: toastIn .25s var(--ease) both; }
.message.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Loading skeleton ---------- */
.dashboard[aria-busy="true"] .metric-card > span:not(.metric-icon),
.dashboard[aria-busy="true"] .month-summary-grid article > span,
.dashboard[aria-busy="true"] .daily-summary article > span,
.dashboard[aria-busy="true"] .closing-summary article > span {
  color: transparent; border-radius: 8px; width: fit-content;
  background: linear-gradient(90deg, #e9edf7 25%, #f5f7fc 50%, #e9edf7 75%) 0 0 / 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   Tablet: sidebar becomes an icon rail
   ========================================================================== */
@media (min-width: 720px) and (max-width: 1099px) {
  .dashboard { --sb-w: 80px; }
  .sidebar { padding-inline: 10px; }
  .sidebar-head { flex-direction: column; padding-inline: 0; }
  .sidebar-logo { width: 48px; }
  .nav-label, .sidebar .nav-badge, .sidebar-collapse-toggle { display: none; }
  .admin-nav button, .sidebar-user, .sidebar-signout { justify-content: center; padding: 0; }
  .admin-nav button.active::before { left: -10px; }
}

/* ==========================================================================
   Phone
   ========================================================================== */
@media (max-width: 719px) {
  body { font-size: 15px; }
  .login-panel { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-card { align-self: start; padding-top: max(36px, env(safe-area-inset-top)); }

  .dashboard { display: block; min-height: 100dvh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .admin-topbar-mobile {
    position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: max(10px, env(safe-area-inset-top)) 14px 10px; background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  }
  .admin-topbar-mobile img { height: 38px; width: auto; }
  .admin-sidebar-toggle { width: 44px; height: 44px; display: grid; align-content: center; justify-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
  .admin-sidebar-toggle span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--ink); transition: transform .2s var(--ease), opacity .2s; }
  .admin-sidebar-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .admin-sidebar-toggle.open span:nth-child(2) { opacity: 0; }
  .admin-sidebar-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); height: 100dvh; z-index: 70;
    transform: translateX(-102%); transition: transform .28s var(--ease); box-shadow: var(--shadow-2);
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .sidebar.open { transform: none; }
  .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(8, 14, 40, .5); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }
  .sidebar-head .bell-button { display: none; }
  .sidebar-collapse-toggle { display: none; }
  .admin-nav button { min-height: 48px; }
  .admin-nav button.active::before { left: -14px; }

  .bottom-nav {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    padding: 6px 6px max(6px, env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  }
  .bottom-nav button { position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 56px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 700; }
  .bottom-nav svg { width: 22px; height: 22px; fill: currentColor; }
  .bottom-nav button[data-tab="sales"] svg, #bottomMore svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .bottom-nav button.active { color: var(--brand-ink); background: var(--brand-50); }
  .bottom-nav .nav-badge { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 18px; height: 18px; font-size: .68rem; }

  .admin-content { padding: 18px 16px 24px; }
  .admin-section > * + * { margin-top: 16px; }
  .admin-heading { align-items: flex-start; }
  .admin-heading .button { width: 100%; }
  .panel-card, .table-wrap, .invite-result { padding: 16px; border-radius: 14px; }
  .table-scroll { margin-inline: 0; padding-inline: 0; overflow: visible; }

  .metric-grid { grid-template-columns: 1fr; gap: 12px; }
  .month-summary-grid, .daily-summary, .closing-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .month-summary-grid article:last-child:nth-child(odd), .daily-summary article:last-child:nth-child(odd), .closing-summary article:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .month-select-controls, .month-filter-inputs, .closing-filter-controls { width: 100%; }
  .month-filter-inputs input, .closing-filter-controls select, .closing-filter-controls input { flex: 1; min-width: 0; width: 100%; }
  .month-filter-mode { width: 100%; }
  .mode-pill { flex: 1; }
  .admin-form { grid-template-columns: 1fr; }
  .admin-form > .button { justify-self: stretch; }
  .form-actions .button { flex: 1; }
  .search-field.compact { width: 100%; }
  .table-title-meta { width: 100%; }
  .request-status-row select { flex: 1; }

  /* Tables turn into cards */
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody tr { margin-bottom: 10px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
  tbody tr:last-child { margin-bottom: 0; }
  td { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 9px 0; border-bottom: 1px dashed var(--line); text-align: right; overflow-wrap: anywhere; }
  td:last-child { border-bottom: 0; }
  td[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); font-size: .8rem; font-weight: 700; text-align: left; }
  td:not([data-label]) { justify-content: flex-start; text-align: left; }
  td:empty { display: none; }
  .empty-row { background: transparent; border: 1px dashed var(--line-strong); }
  .empty-row td { display: block; text-align: center; }
  .notes-cell { max-width: none; }
  .closing-row { display: block; }
  .closing-detail-row { display: none; }
  .closing-detail-row.open { display: block; }
  .closing-detail-row > td { display: block; padding: 0; background: transparent; }
  .closing-detail-row table { background: transparent; }
  .closing-detail-row tbody tr { background: var(--surface-2); }
  .expand-closing-btn { width: 40px; height: 40px; }

  .notif-panel { left: 8px; right: 8px; top: 8px; width: auto; }
  .toast-region { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .sale-modal-overlay { align-items: end; padding: 0; }
  .sale-modal { width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; animation: sheetUp .28s var(--ease) both; }
  .sale-modal-actions .button, .sale-modal-actions .danger { flex: 1; }
  .sale-modal-grid { grid-template-columns: 1fr 1fr; }
  .export-card .button { align-self: stretch; }
  .date-range-row { flex-wrap: wrap; }
  .date-range-row input { flex: 1; min-width: 130px; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Notification panel sits beside the sidebar on desktop; on the rail it needs a smaller offset */
@media (min-width: 720px) and (max-width: 1099px) { .notif-panel { left: 90px; } }
.dashboard.sb-collapsed .notif-panel { left: 90px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

@media print {
  .sidebar, .admin-topbar-mobile, .bottom-nav, .toast-region, .bell-button { display: none !important; }
  .dashboard { display: block; }
  .admin-section { display: block !important; }
}


/* ==========================================================================
   Expenses, payroll, invoices, receipts
   ========================================================================== */
.form-title { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; }
.table-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.table-head-row > h2 { margin: 0; }
.table-head-row select, .table-head-row input { min-height: 40px; }
.inline-filter { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); font-size: .88rem; }
.status-pill.paid { background: var(--ok-50); color: var(--ok); }
.status-pill.unpaid { background: var(--warn-50); color: var(--warn); }
.status-pill.cancelled { background: var(--danger-50); color: var(--danger); }
.cat-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--brand-50); color: var(--brand-ink); white-space: nowrap; }
.cat-pill.cat-raw { background: #eef1ff; color: #050f8f; }
.cat-pill.cat-prepaid { background: #fff1e8; color: #b8430b; }
.cat-pill.cat-water { background: #e3f6fb; color: #0b6781; }
.cat-pill.cat-disposable { background: #fff4dc; color: #a15c00; }
.cat-pill.cat-other { background: #eceef5; color: #3d4766; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions .button, .row-actions button.danger { min-height: 34px; padding: 0 12px; font-size: .82rem; }

.category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.category-card { position: relative; padding: 16px 16px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); display: grid; gap: 4px; }
.category-card strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.category-card span.cat-name { font-size: .85rem; font-weight: 700; color: var(--muted); }
.category-card small { color: var(--muted); font-weight: 600; }
.category-card .bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 6px; }
.category-card .bar i { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .4s var(--ease); }
.category-card.is-total { background: var(--brand-50); border-color: var(--brand-100); }
.category-card.is-top .bar i { background: var(--accent); }

.invoice-items { display: grid; gap: 8px; }
.invoice-items-head, .invoice-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 120px 110px 40px; gap: 8px; align-items: center; }
.invoice-items-head { font-size: .78rem; font-weight: 700; color: var(--muted); padding: 0 2px; }
.invoice-row input { min-width: 0; }
.invoice-row .line-amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.invoice-row button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--danger); font-size: 1.2rem; line-height: 1; }
.invoice-totals { display: grid; gap: 4px; justify-items: end; font-variant-numeric: tabular-nums; }
.invoice-totals div { display: flex; gap: 24px; justify-content: space-between; min-width: min(280px, 100%); }
.invoice-totals .grand { font-size: 1.15rem; font-weight: 800; padding-top: 6px; border-top: 1px solid var(--line-strong); }
@media (max-width: 680px) {
  .invoice-items-head { display: none; }
  .invoice-row { grid-template-columns: 1fr 1fr 40px; }
  .invoice-row .inv-desc { grid-column: 1 / -1; }
  .invoice-row .line-amount { grid-column: 1 / 3; text-align: left; }
}

/* ---------- Printable documents (receipt / invoice) ---------- */
.doc-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 14px; background: rgba(8, 14, 40, .6); backdrop-filter: blur(3px); }
.doc-shell { width: min(860px, 100%); max-height: calc(100dvh - 28px); display: flex; flex-direction: column; background: var(--surface-2); border-radius: 18px; box-shadow: var(--shadow-2); overflow: hidden; }
.doc-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.doc-actions-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.doc-scroll { overflow: auto; padding: 16px; }
.doc-paper { --doc-ink: #111827; --doc-muted: #5b6475; --doc-line: #d9dde7; position: relative; margin: 0 auto; max-width: 100%; background: #fff; color: var(--doc-ink); padding: clamp(18px, 4vw, 40px); border: 1px solid var(--doc-line); border-radius: 6px; font-size: 14px; line-height: 1.45; box-shadow: 0 1px 4px rgba(0,0,0,.06); overflow: hidden; }
.doc-paper.is-receipt { width: 560px; }
.doc-paper.is-invoice { width: 794px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 3px solid #0616b8; }
.doc-head img { height: 64px; width: auto; display: block; }
.doc-company { text-align: right; font-size: 12.5px; color: var(--doc-muted); }
.doc-company strong { display: block; font-size: 15px; color: var(--doc-ink); }
.doc-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 18px 0 12px; }
.doc-title h2 { font-size: 22px; letter-spacing: .08em; color: #0616b8; margin: 0; }
.doc-title .doc-no { font-weight: 800; font-size: 15px; }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px 18px; margin-bottom: 16px; }
.doc-meta div { display: grid; gap: 1px; }
.doc-meta dt, .doc-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--doc-muted); font-weight: 700; }
.doc-meta dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.doc-party { margin-bottom: 16px; padding: 10px 12px; background: #f6f7fb; border-radius: 6px; overflow-wrap: anywhere; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.doc-table th { position: static; background: #f0f2f8; color: var(--doc-ink); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--doc-line); }
.doc-table td { padding: 9px 10px; border-bottom: 1px solid var(--doc-line); }
.doc-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-sum { margin: 14px 0 0 auto; width: min(320px, 100%); display: grid; gap: 5px; font-variant-numeric: tabular-nums; }
.doc-sum div { display: flex; justify-content: space-between; gap: 16px; }
.doc-sum .grand { font-size: 17px; font-weight: 800; border-top: 2px solid var(--doc-ink); padding-top: 7px; margin-top: 3px; }
.doc-words { margin-top: 12px; font-size: 12.5px; color: var(--doc-muted); }
.doc-words strong { color: var(--doc-ink); }
.doc-note { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--doc-line); font-size: 12.5px; color: var(--doc-muted); white-space: pre-line; overflow-wrap: anywhere; }
.doc-note b { color: var(--doc-ink); }
.doc-foot { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--doc-line); text-align: center; font-size: 12px; color: var(--doc-muted); }
.doc-foot strong { color: var(--doc-ink); }
.doc-stamp { position: absolute; right: clamp(18px, 5vw, 44px); top: 46%; transform: rotate(-14deg); padding: 4px 18px; border: 3px solid #12703a; border-radius: 8px; color: #12703a; font-weight: 900; font-size: 26px; letter-spacing: .12em; opacity: .22; pointer-events: none; }
.doc-stamp.unpaid { border-color: #a15c00; color: #a15c00; }
.doc-stamp.cancelled { border-color: #b4231a; color: #b4231a; }
.doc-dup { display: inline-block; margin-left: 8px; padding: 1px 8px; border: 1px solid #a15c00; color: #a15c00; border-radius: 4px; font-size: 11px; font-weight: 800; letter-spacing: .05em; vertical-align: middle; }

@media print {
  @page { margin: 12mm; }
  body.printing-doc { background: #fff !important; }
  body.printing-doc > *:not(#docOverlay) { display: none !important; }
  body.printing-doc #docOverlay { position: static; display: block !important; padding: 0; background: none; backdrop-filter: none; }
  body.printing-doc .doc-shell { width: auto; max-height: none; background: none; box-shadow: none; border-radius: 0; overflow: visible; }
  body.printing-doc .doc-actions { display: none !important; }
  body.printing-doc .doc-scroll { overflow: visible; padding: 0; }
  body.printing-doc .doc-paper { border: 0; box-shadow: none; padding: 0; border-radius: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.printing-doc .doc-paper.is-receipt { width: 100%; max-width: 150mm; }
  body.printing-doc .doc-paper.is-invoice { width: 100%; }
}
