@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap");

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #718096;
  --line: #e5eaf1;
  --nav: #172033;
  --accent: #f27a38;
  --accent-dark: #d85d1d;
  --accent-soft: #fff1e8;
  --danger: #d64d5b;
  --success: #278b68;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(31, 45, 70, 0.07);
  --font-main: "DM Sans", sans-serif;
  --font-display: "Space Grotesk", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0f1726;
  --surface: #182235;
  --surface-soft: #202d42;
  --ink: #f3f6fb;
  --muted: #a8b4c7;
  --line: #304057;
  --nav: #0a1120;
  --accent-soft: #3a2c27;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
}

[hidden] { display: none !important; }

html,
body {
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

header {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 82px;
  padding: 16px clamp(18px, 4vw, 52px);
  background: var(--nav);
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: max-content;
}

.brand .logo,
.auth-brand .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 5px 14px rgba(242, 122, 56, 0.28);
}

.auth-brand .logo {
  width: 50px;
  height: 50px;
  border-radius: 15px;
  font-size: 17px;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand .muted {
  margin-top: 2px;
  color: #aab4c6;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.account-controls { display: flex; align-items: center; gap: 8px; color: #dce4f1; }
.account-identity { max-width: 180px; overflow: hidden; color: #dce4f1; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.account-signout { padding: 8px 10px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.07); color: #dce4f1; }
.account-signout:hover { background: rgba(255,255,255,.14); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  color: #dce4f1;
  white-space: nowrap;
}

.theme-toggle:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.13);
}

.theme-icon {
  color: #ffd47a;
  font-size: 16px;
  line-height: 1;
}

:root[data-theme="dark"] .brand .muted {
  color: #b8c2d2;
}

:root[data-theme="dark"] .tab.active {
  background: var(--accent);
  color: #fff;
}

:root[data-theme="dark"] .btn-muted {
  color: #d2dbea;
}

:root[data-theme="dark"] input::placeholder {
  color: #93a1b7;
}

:root[data-theme="dark"] .modal-content,
:root[data-theme="dark"] #receipt-print {
  background: var(--surface);
  color: var(--ink);
}

.tab {
  padding: 9px 16px;
  border-radius: 9px;
  background: transparent;
  color: #aab4c6;
  font-size: 13px;
  font-weight: 600;
  transition: 0.2s ease;
}

.tab:hover,
.tab.active {
  background: #fff;
  color: var(--nav);
}

main {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  width: min(1440px, 100%);
  min-height: calc(100vh - 132px);
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 52px);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.left-grid {
  flex: 1 1 auto;
  min-width: 0;
  padding: 24px;
}

.side-panel {
  flex: 0 0 390px;
  padding: 24px;
}

.content-section {
  display: none;
  flex-direction: column;
  gap: 22px;
}

.content-section.active {
  display: flex;
}

/* Store dashboard */
main.dashboard-mode .side-panel { display: none; }
main.dashboard-mode .left-grid { width: 100%; }
.dashboard-section { gap: 22px; }
.dashboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 2px 2px 4px; }
.dashboard-heading h2 { margin-top: 5px; font-family: var(--font-display); font-size: clamp(25px, 3vw, 32px); letter-spacing: -.045em; }
.dashboard-heading .muted { margin-top: 5px; }
.eyebrow { color: var(--accent-dark); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.dashboard-action { display: inline-flex; align-items: center; gap: 12px; padding: 12px 17px; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.metric-card { display: flex; min-height: 145px; flex-direction: column; justify-content: center; gap: 10px; padding: 19px 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 5px 18px rgba(31,45,70,.035); }
.metric-top { display: flex; align-items: center; gap: 10px; }
.metric-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 11px; background: var(--accent-soft); color: var(--accent-dark); font-size: 17px; font-weight: 700; }
.metric-orders .metric-icon { background: #eaf3ff; color: #4676bf; }
.metric-products .metric-icon { background: #e9f7f0; color: #278b68; }
:root[data-theme="dark"] .metric-orders .metric-icon { background: #253b59; color: #9bc2ff; }
:root[data-theme="dark"] .metric-products .metric-icon { background: #1d4038; color: #83d3ad; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.metric-card > strong { font-family: var(--font-display); font-size: clamp(24px, 2.5vw, 30px); letter-spacing: -.04em; line-height: 1.1; }
.metric-note { color: var(--muted); font-size: 11px; }
.dashboard-panel { min-width: 0; padding: 19px 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 5px 18px rgba(31,45,70,.035); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h3 { font-size: 16px; }
.section-heading .muted { margin-top: 3px; }
.chart-period { padding: 6px 9px; border-radius: 8px; background: var(--surface-soft); color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .08em; white-space: nowrap; }
.sales-chart { width: 100%; min-height: 205px; margin-top: 16px; }
.sales-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-gridline { stroke: var(--line); stroke-dasharray: 4 6; stroke-width: 1; }
.chart-area { fill: rgba(242,122,56,.12); }
.chart-line { fill: none; stroke: var(--accent); stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.chart-point { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.chart-y-label, .chart-x-label { fill: var(--muted); font-family: var(--font-main); font-size: 10px; }
.dashboard-bottom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.text-action { padding: 5px 0; background: transparent; color: var(--accent-dark); font-size: 11px; white-space: nowrap; }
.text-action:hover { color: var(--accent); }
.dashboard-list { margin-top: 13px; }
.dashboard-empty { padding: 18px 4px 8px; color: var(--muted); font-size: 12px; }
.stock-row, .transaction-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.stock-row:first-child, .transaction-row:first-child { border-top: 0; }
.row-primary { overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.row-secondary { margin-top: 3px; color: var(--muted); font-size: 10px; }
.stock-count { flex: 0 0 auto; padding: 5px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-dark); font-size: 10px; font-weight: 700; }
.transaction-amount { flex: 0 0 auto; font-size: 12px; font-weight: 700; }
.transaction-payment { color: var(--muted); font-size: 10px; font-weight: 500; }

.top-row,
.history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.top-row input {
  flex: 1;
}

.top-actions,
.history-actions {
  display: flex;
  gap: 8px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--surface-soft);
  color: var(--ink);
  transition: 0.2s ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(242, 122, 56, 0.13);
}

input::placeholder {
  color: #a1adbd;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 32px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 13px;
}

.group-header {
  grid-column: 1 / -1;
  padding: 8px 2px 2px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.product-card {
  display: flex;
  min-height: 138px;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  transition: 0.2s ease;
}

.product-card:hover {
  border-color: #f5b18b;
  box-shadow: 0 8px 18px rgba(31, 45, 70, 0.09);
  transform: translateY(-2px);
}

.product-card h4 {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card .actions {
  display: flex;
  gap: 7px;
}

.product-card .actions button {
  flex: 1;
}

button {
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  transition: 0.2s ease;
}

.btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 10px rgba(242, 122, 56, 0.2);
}

.btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.btn-muted {
  border: 1px solid var(--line);
  background: var(--surface);
  color: #56647a;
}

.btn-muted:hover {
  border-color: #f1a476;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.danger {
  background: var(--danger);
  color: #fff;
}

.danger:hover {
  background: #b83d4b;
}

h3 {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: -0.03em;
}

.product-manager {
  display: flex;
  gap: 28px;
}

.pm-list-wrap,
.pm-editor {
  flex: 1;
  min-width: 0;
}

.pm-list-wrap h3,
.pm-editor h3 {
  margin-bottom: 14px;
}

.pm-list {
  display: flex;
  max-height: 520px;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}

.pm-row {
  border: 1px solid var(--line) !important;
  background: var(--surface-soft) !important;
}

.pm-editor .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pm-editor .form-grid button {
  grid-column: span 2;
}

.stock-warning { color: var(--accent-dark); font-weight: 700; }
.inventory-log-wrap { margin-top: 22px; }
.inventory-log-wrap h3 { margin-bottom: 10px; }
.inventory-log { max-height: 190px; overflow: auto; border: 1px dashed var(--line); border-radius: 10px; padding: 8px; }
.store-settings { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.store-settings h3 { margin-bottom: 10px; }
.import-mode { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.import-mode select { min-height: 38px; max-width: 190px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); }
.movement-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.movement-row:last-child { border-bottom: 0; }
.movement-row small { grid-column: 1 / -1; color: var(--muted); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; }
.report-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.report-card span { display: block; color: var(--muted); font-size: 12px; }
.report-card strong { display: block; margin-top: 6px; font-family: var(--font-display); font-size: 20px; }
.report-details { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.report-details h4 { margin: 14px 0 7px; font-family: var(--font-display); }
.report-details h4:first-child { margin-top: 0; }
.report-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.report-line:last-child { border-bottom: 0; }
.reports-section { display: flex; flex-direction: column; gap: 12px; }
.reports-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reports-section-heading h3 { font-size: 16px; }
.reports-section-heading .muted { margin-top: 3px; }
.reports-lower-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.reports-lower-grid .reports-section { min-width: 0; }
.reports-lower-grid .report-details { flex: 1; }
.report-card { min-height: 90px; padding: 17px 18px; background: var(--surface); }
.report-card strong { font-size: 21px; }
.report-card.profit-highlight { border-color: rgba(39,139,104,.24); background: rgba(39,139,104,.06); }
.profit-highlight strong { color: var(--success); }
.report-note { line-height: 1.5; }
.report-list { min-height: 170px; padding: 11px 16px; }
.report-list .report-line { align-items: center; min-height: 39px; gap: 12px; }
.report-list .report-line > strong { flex: 0 0 auto; font-size: 12px; }
.bestseller-name { display: flex; min-width: 0; align-items: center; gap: 10px; overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.bestseller-rank { display: grid; width: 23px; height: 23px; flex: 0 0 auto; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent-dark); font-size: 10px; font-weight: 700; }
.report-empty { padding: 15px 0; color: var(--muted); font-size: 12px; }

.auth-gate { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; overflow: auto; padding: 24px; background: var(--bg); }
.auth-card { width: min(430px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand h1 { font-family: var(--font-display); font-size: 20px; }
.auth-brand .muted { margin-top: 2px; }
.auth-local-note { margin-bottom: 19px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); color: var(--muted); font-size: 11px; line-height: 1.5; }
.auth-form { display: grid; gap: 10px; }
.auth-form h2 { font-family: var(--font-display); font-size: 20px; letter-spacing: -.03em; }
.auth-form > .muted { margin: -5px 0 5px; }
.auth-form label { margin-top: 2px; color: var(--ink); font-size: 12px; font-weight: 600; }
.auth-form button { margin-top: 8px; }
.auth-message { min-height: 18px; margin-top: 12px; color: var(--danger); font-size: 12px; }
.auth-toast { position: fixed; right: 20px; bottom: 20px; z-index: 2100; max-width: min(380px, calc(100% - 40px)); padding: 12px 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s ease; }
.auth-toast.is-visible { opacity: 1; transform: translateY(0); }
.user-manager { display: grid; grid-template-columns: minmax(240px, .8fr) minmax(0, 1.2fr); gap: 20px; }
.user-create-form, .user-list-panel { display: flex; flex-direction: column; gap: 11px; min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.user-create-form h3, .user-list-panel h3 { font-size: 15px; }
.user-create-form button { margin-top: 4px; }
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.user-row > div:first-child { min-width: 0; }
.user-row-name { font-size: 12px; font-weight: 700; }
.user-row-meta { margin-top: 3px; color: var(--muted); font-size: 10px; }
.user-row button { flex: 0 0 auto; }
.user-reset-form { display: grid; gap: 10px; margin-top: 8px; padding-top: 15px; border-top: 1px solid var(--line); }
.user-reset-form h3 { font-size: 13px; }
.user-form-actions { display: flex; gap: 8px; }
main.cashier-mode .pm-editor { display: none !important; }
main.cashier-mode .pm-list-wrap { width: 100%; }

.return-modal .modal-content { width: min(620px, 94%); max-height: min(88vh, 800px); overflow-y: auto; }
.return-modal h3 { margin-bottom: 5px; }
.return-items { display: flex; flex-direction: column; max-height: 290px; gap: 8px; margin: 15px 0; overflow-y: auto; }
.return-item-row { display: grid; grid-template-columns: minmax(0, 1fr) 82px; align-items: center; gap: 14px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.return-item-name { overflow: hidden; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.return-item-meta { margin-top: 4px; color: var(--muted); font-size: 10px; }
.return-qty { padding: 8px !important; text-align: center; }
.return-label { display: block; margin: 10px 0 6px; color: var(--ink); font-size: 12px; font-weight: 600; }
.return-total { display: flex; align-items: center; justify-content: space-between; margin-top: 15px; padding: 14px 0; border-top: 1px solid var(--line); font-size: 13px; }
.return-total strong { color: var(--accent-dark); font-family: var(--font-display); font-size: 21px; }
.return-submit { width: 100%; }
.return-submit:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.history-return-summary { margin-top: 8px; color: var(--danger); font-size: 11px; font-weight: 700; }
.history-return-record { margin-top: 5px; color: var(--muted); font-size: 10px; }
.activity-log { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.activity-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.activity-row:last-child { border-bottom: 0; }
.activity-row time { color: var(--accent-dark); font-family: var(--font-display); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.activity-row p { min-width: 0; margin: 0; color: var(--ink); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.activity-empty { padding: 24px 16px; color: var(--muted); font-size: 12px; text-align: center; }

.cart {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.cart h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.items {
  min-height: 145px;
  max-height: 360px;
  padding: 4px;
  overflow: auto;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.cart-item > :nth-child(3) {
  grid-column: 1;
  grid-row: 2;
}

.cart-item > :nth-child(4) {
  grid-column: 2;
  grid-row: 2;
}

.qty {
  display: flex;
  align-items: center;
  gap: 5px !important;
}

.qty button {
  width: 28px;
  padding: 5px;
}

.summary {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}

.summary .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
  color: #58667b;
}

.large-total {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.summary .row:last-of-type {
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.summary .row:last-of-type .large-total:last-child {
  color: var(--accent-dark);
}

.payment-row {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 18px;
}

.pay-buttons {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 8px;
}

.pay-buttons button {
  width: 100%;
}

.history-list {
  display: flex;
  max-height: 480px;
  flex-direction: column;
  gap: 9px;
  overflow: auto;
}

.history-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}

footer.small {
  padding: 12px;
  color: #98a4b6;
  font-size: 12px;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 32, 51, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  position: relative;
  width: min(420px, 92%);
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(23, 32, 51, 0.2);
}

.modal-content h3 {
  margin-bottom: 7px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 4px 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.modal-close:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

#receipt-print {
  color: #111;
}

@media print {
  @page { size: 80mm auto; margin: 4mm; }
  body * { visibility: hidden !important; }
  #receipt-print.receipt-ready,
  #receipt-print.receipt-ready * { visibility: visible !important; }
  #receipt-print.receipt-ready {
    display: block !important;
    position: absolute !important;
    inset: 0 auto auto 0 !important;
    width: 72mm !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: #111 !important;
    background: #fff !important;
    font: 10pt/1.35 Arial, sans-serif !important;
  }
  #receipt-print .muted { color: #444 !important; }
}

@media (max-width: 950px) {
  header {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .header-actions {
    width: 100%;
    margin-left: 0;
  }

  .tabs {
    width: 100%;
    margin-left: 0;
  }

  .tab {
    flex: 1;
  }

  main {
    flex-direction: column;
  }

  .left-grid,
  .side-panel {
    width: 100%;
    flex-basis: auto;
  }
}

@media (max-width: 620px) {
  main {
    gap: 14px;
    padding: 14px;
  }

  .left-grid,
  .side-panel {
    padding: 16px;
  }

  .top-row,
  .history-top,
  .product-manager {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .account-controls { justify-content: center; }
  .account-identity { max-width: 68%; }
  .user-manager { grid-template-columns: 1fr; }

  .tabs { overflow-x: auto; }
  .tab { flex: 0 0 auto; white-space: nowrap; }

  .theme-toggle {
    justify-content: center;
  }

  .top-actions,
  .history-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .history-actions {
    grid-template-columns: 1fr 1fr;
  }

  .history-actions button:last-of-type {
    grid-column: 1 / -1;
  }

  .dashboard-heading { align-items: flex-start; flex-direction: column; }
  .dashboard-action { width: 100%; justify-content: center; }
  .dashboard-metrics { grid-template-columns: 1fr; gap: 10px; }
  .metric-card { min-height: 116px; padding: 15px 17px; }
  .dashboard-bottom { grid-template-columns: 1fr; }
  .reports-lower-grid { grid-template-columns: 1fr; }
  .dashboard-panel { padding: 16px; }
  .reports-section-heading { align-items: flex-start; }
  .sales-chart { min-height: 170px; }
  .section-heading { align-items: flex-start; }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pm-editor .form-grid {
    grid-template-columns: 1fr;
  }

  .pm-editor .form-grid button {
    grid-column: auto;
  }
}

@media (max-width: 390px) {
  .product-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    white-space: nowrap;
  }
}

/* Compact icon-only primary navigation */
.tabs { justify-content: flex-start; }
.tabs .tab {
  display: inline-flex;
  width: 42px;
  height: 40px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.tabs .tab svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Consistent email and password fields for owner and cashier forms */
.auth-input {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background-color: var(--surface-soft);
  color: var(--ink);
  font-size: 13px;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.auth-input::placeholder { color: #8b97a9; font-size: 12px; font-weight: 500; opacity: 1; }
.auth-input:focus { border-color: var(--accent); background-color: var(--surface); box-shadow: 0 0 0 3px rgba(242, 122, 56, .13); }
:root[data-theme="dark"] .auth-input::placeholder { color: #a8b4c7; }
