/* ============================================================
   Seema Jewellers web app v1.1.5 — Dark theme (the fixed look
   Subham picked) + phone-app shell + haptics + logo.
   Loaded AFTER styles.css and overrides it. This is the ONLY
   theme — there is no theme switcher in the live app.
   The invoice print view (.inv) is deliberately left
   black-on-white — the approved bill format.
   ============================================================ */

/* ---------- Smooth, fluid feel ----------
   Transitions + press feedback, on every control, all themes. */
button, input, select, textarea, .card, .view section, .inv {
  transition: box-shadow .2s ease, border-color .2s ease, background .2s ease;
}
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, .linklike:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Clean, premium, minimal ----------
   Cards flush to the page edges, one consistent radius, soft
   shadows instead of heavy borders. */
.card, .view section, .inv { border: 0; border-radius: 8px; }

/* ---------- Seema Jewellers logo ----------
   Real SJ logo (assets/seema-logo.png, transparent). Its deep-maroon
   parts sit on a light ivory chip (#f6f1e7) so the monogram stays
   crisp on the dark background. */
header.top .shop { display: flex; align-items: center; gap: 11px; }
.hdr-logo {
  width: 30px; height: 30px; object-fit: contain;
  flex-grow: 0; flex-shrink: 0; flex-basis: auto;
  border-radius: 9px; background: #f6f1e7; padding: 2px;
}
.shop-txt { display: block; }
.login-logo { text-align: center; margin-bottom: 12px; }
.login-logo img {
  width: 68px; height: 68px; object-fit: contain;
  border-radius: 16px; background: #f6f1e7; padding: 5px;
}

/* ============================================================
   DARK THEME
   ------------------------------------------------------------
   Warm charcoal ink on a soft near-black background — the dark
   theme Subham picked, after the edge polish: consistent 1px
   #333842 card borders, a crisp gold focus border with no glow,
   one consistent pill button radius, a header bottom line, a
   tab-bar top edge and visible dividers.
   ============================================================ */
html[data-theme="dark"] {
  color-scheme: dark;
  --backdrop: #050607;
  --ivory: #101216;
  --ink: #f5f3ef;
  --title: #f2f4f8;
  --accent: #c9a227;
  --line: #333842;
  --maroon: #2b2f38;
  --maroon-ink: #f5f3ef;
  --mut: #9aa1b1;
  --card: #151920;
  --card-2: #1c212a;
  --field: #1b2029;
  --gold: #e0b62e;
  --ok-bg: #1f4031;
  --ok-fg: #a8d5a2;
  --bad-bg: #4a1f1f;
  --bad-fg: #f0a0a0;
  --badge-pending-bg: #4a3f13;
  --badge-pending-fg: #f0c94c;
  --badge-approved-bg: #1f4031;
  --badge-approved-fg: #a8d5a2;
  --badge-cancelled-bg: #4a1f1f;
  --badge-cancelled-fg: #f0a0a0;
  --badge-low-bg: #4a1f1f;
  --badge-low-fg: #f0a0a0;
  --tab-inactive-bg: #1a1e27;
  --tab-inactive-fg: #9aa1b1;
  --btn-bg: #3f444e;
  --btn-fg: #e8eaf0;
  --btn-border: #3f444e;
  --input-border: #2e3442;
  --print-header-bg: #151920;
  --print-header-border: #2e3442;
  --print-th-bg: #1c212a;
  --print-th-border: #2e3442;
  --print-table-border: #2e3442;
  --print-totals-border: #2e3442;
  --focus: #c9a227;
  --focus-shadow: none;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  --shadow-soft: 0 1px 5px rgba(0, 0, 0, .25);
  --accent-on-white: #c9a227;
  --accent-on-white-hover: #e0b62e;
  --btn-primary-bg: #c9a227;
  --btn-primary-fg: #111;
  --btn-primary-hover: #e0b62e;
  --btn-logout-bg: transparent;
  --btn-logout-fg: #e8eaf0;
  --btn-logout-border: #3f444e;
  --btn-logout-hover-bg: rgba(255, 255, 255, .06);
  --btn-danger-bg: #6e1b1b;
  --btn-danger-fg: #ffd8d8;
  --btn-danger-hover-bg: #8c2222;
  --btn-primary-ghost-bg: transparent;
  --btn-primary-ghost-fg: #e0b62e;
  --btn-primary-ghost-border: #c9a227;
  --btn-primary-ghost-hover-bg: rgba(201, 162, 39, .14);
  --divider: rgba(255, 255, 255, .09);
  --itemrow-bg: #1c212a;
  --itemrow-border: #2e3442;
  --hover-row-bg: #1c212a;
  --tabbar-bg: #12151b;
  --tabbar-border: #333842;
}
html[data-theme="dark"] header.top {
  background: linear-gradient(135deg, #0a0f18 0%, #14253f 55%, #1d3a63 100%);
  border-bottom: 1px solid #333842;
  box-shadow: 0 2px 12px rgba(0,0,0,.55);
}
html[data-theme="dark"] .card {
  background: var(--card); border: 1px solid var(--line);
}
html[data-theme="dark"] .view section { border: 1px solid var(--line); }
html[data-theme="dark"] .view section:hover { border-color: var(--line); }
html[data-theme="dark"] .card h3, html[data-theme="dark"] .view section h3 {
  border-bottom: 1px solid var(--divider);
}
html[data-theme="dark"] nav.tabs button { border: 1px solid var(--line); }
html[data-theme="dark"] nav.tabs button.on { background: #c9a227; color: #111; }
html[data-theme="dark"] .role-badge {
  background: var(--card-2); color: var(--ink); border: 1px solid var(--line);
}
html[data-theme="dark"] .stat {
  background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .25);
}
html[data-theme="dark"] .ghost {
  border-color: var(--btn-border); background: var(--btn-bg); color: var(--btn-fg);
}
html[data-theme="dark"] .ghost:hover { background: #4b515d; border-color: #4b515d; }
html[data-theme="dark"] button { border-radius: 999px; }
html[data-theme="dark"] .sticky-action button { border-radius: 999px; }
html[data-theme="dark"] button:focus-visible, html[data-theme="dark"] input:focus-visible,
html[data-theme="dark"] select:focus-visible, html[data-theme="dark"] textarea:focus-visible {
  outline: 1px solid var(--focus); outline-offset: 0; box-shadow: none;
}
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea {
  border-color: var(--input-border); background: var(--field);
}
html[data-theme="dark"] .itemrow { background: var(--itemrow-bg); border-color: var(--itemrow-border); }
html[data-theme="dark"] .clickable:hover { background: var(--hover-row-bg); }
html[data-theme="dark"] .login-box .card {
  background: var(--card); border: 1px solid var(--line);
}
/* Login title: near-white with a short gold accent bar underneath
   (the preview's SEEMA/Jewellers treatment) — never dark red on dark. */
html[data-theme="dark"] .login-box h1 {
  color: var(--title); font-size: 26px; letter-spacing: .5px;
}
html[data-theme="dark"] .login-box h1::after {
  content: ""; display: block; width: 44px; height: 3px;
  margin: 10px auto 0; background: var(--accent); border-radius: 2px;
}
html[data-theme="dark"] #msg {
  border-bottom: 1px solid var(--line); border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
html[data-theme="dark"] #tabbar { background: var(--tabbar-bg); border-top: 1px solid var(--tabbar-border); }

/* ============================================================
   PHONE-APP SHELL
   The whole app lives in a centred phone-width column (max 430px),
   full-bleed on real phones. Bottom tab bar replaces the top tab
   row; big touch targets; views fade/slide in; wide tables become
   labelled stacked rows. Shell/visual only — no flow changes.
   ============================================================ */
body { background: var(--backdrop, #050607); display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
header.top, #msg, main, #login-view {
  /* width:100% — without it, a column-flex item with auto side margins
     shrink-wraps to its content instead of stretching, leaving black
     --backdrop gaps on both sides of the header (Gemini + Muse, v1.1.7:
     header was ~378px wide on a 412px phone, ~17px gap each side). */
  width: 100%;
  max-width: 430px; margin-left: auto; margin-right: auto;
}
/* Safe-area buffer at the very top: keeps the navy header flush to the
   screen edge while pushing the logo/text clear of the status bar and
   camera cutout when the app runs edge-to-edge (viewport-fit=cover). */
header.top {
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
main, #login-view { background: var(--ivory); }
main {
  min-height: 72vh;
  padding: 14px 12px calc(92px + env(safe-area-inset-bottom));
}
#login-view {
  margin-top: 0; margin-bottom: 0; padding: 24px 12px 32px;
  /* Fill the space below the header exactly (body is a flex column)
     and vertically centre the card in it — the old min-height: 72vh
     with top-aligned content left ~280px of dead black space below
     the card on a phone. */
  flex: 1 0 auto;
  display: flex; flex-direction: column; justify-content: center;
}
#login-view .card { margin-bottom: 0; }
/* The role step's last paragraph carries the browser's default ~13px
   bottom margin, which showed as dead space inside the card. */
#login-step-role > p:last-child { margin-bottom: 0; }
@media (min-width: 431px) {
  header.top, main, #login-view, #tabbar {
    border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  }
}

/* top tab row is replaced by the bottom tab bar */
nav.tabs { display: none; }

/* single-column app layout inside the phone column */
.grid2, .grid3 { grid-template-columns: 1fr; }
.form-row { grid-template-columns: 1fr 1fr; }
.form-row3, .form-row4 { grid-template-columns: 1fr 1fr; }
.stat .v { font-size: 24px; }

/* large touch targets (~44px minimum) */
button, .btn { min-height: 44px; }
button.small { min-height: 44px; padding: 6px 12px; }
input, select { min-height: 44px; }
textarea { min-height: 44px; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; vertical-align: -4px; }
.linklike { min-height: 0; }

/* gentle fade/slide when switching screens */
section.view.on { animation: sj-view-in .28s ease both; }
@keyframes sj-view-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  section.view.on { animation: none; }
}

/* ---- bottom tab bar ---- */
#tabbar {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: 0; width: min(100%, 430px);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--tabbar-bg, #12151b);
  border-top: 1px solid var(--tabbar-border, #333842);
  z-index: 120;
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar button {
  flex: 1; border: 0; background: none; border-radius: 12px;
  color: var(--tab-inactive-fg, #9aa1b1); cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px;
  padding: 8px 2px 6px; min-height: 0;
  font-size: 10.5px; font-weight: 700; font-family: inherit;
}
#tabbar button svg { width: 21px; height: 21px; }
#tabbar button.on { color: var(--accent); }
#tabbar button:active { background: rgba(255, 255, 255, .07); }
#tabbar button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---- sticky primary actions ---- */
.sticky-action {
  position: sticky; bottom: calc(64px + env(safe-area-inset-bottom));
  z-index: 10; margin-top: 14px; margin-left: -4px; margin-right: -4px;
  padding: 6px 4px 8px;
  background: linear-gradient(to bottom, transparent, var(--ivory) 28%);
}
.sticky-action button { width: 100%; border-radius: 999px; }

/* floating "+ New Bill" action (overrides the old static #btn-new-bill) */
#btn-new-bill {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom));
  right: max(16px, calc(50vw - 215px + 16px)); z-index: 110;
  background: var(--btn-primary-bg, #c9a227); color: var(--btn-primary-fg, #111);
  border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 800;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  min-height: 0; width: auto; margin: 0;
}
#btn-new-bill:hover { background: var(--btn-primary-hover, #e0b62e); }

/* ---- wide tables become labelled stacked rows ---- */
@media (max-width: 430px) {
  table.cardtable, table.cardtable thead, table.cardtable tbody,
  table.cardtable th, table.cardtable td, table.cardtable tr { display: block; }
  table.cardtable thead { display: none; }
  table.cardtable tr {
    border: 1px solid var(--line); border-radius: 8px;
    padding: 10px 12px; margin-bottom: 10px; background: var(--card);
  }
  table.cardtable tr:last-child { margin-bottom: 0; }
  table.cardtable td {
    border: 0; padding: 3px 0; text-align: left !important;
    display: flex; justify-content: space-between; gap: 12px;
  }
  table.cardtable td::before {
    content: attr(data-label); font-weight: 700; color: var(--mut);
    flex-shrink: 0;
  }
  table.cardtable td.acts { display: flex; justify-content: flex-end; }
  table.cardtable td.acts::before { content: none; }
  /* v1.2.0: empty-state rows are centred text, not a label/value pair. */
  table.cardtable td.empty-row { display: block; text-align: center !important; }
  table.cardtable td.empty-row::before { content: none; }
  table.cardtable td.r { text-align: left; }
  table.cardtable td.num { text-align: left; font-family: inherit; }
}

/* ---- print: hide the app chrome, keep the invoice clean ---- */
@media print {
  #tabbar, #btn-new-bill { display: none !important; }
  .sticky-action { position: static; }
  body { background: #fff; }
  main, #login-view { background: #fff; max-width: none; }
}
