:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #2b1b14;
  background: #f7f2e9;
  --bg: #f7f2e9;
  --surface: #fffdf8;
  --surface-subtle: #f7efe2;
  --border: #dfd0b9;
  --border-strong: #c9b596;
  --text: #2b1b14;
  --text-muted: #756354;
  --text-soft: #a89278;
  --sidebar: #2b1b14;
  --sidebar-hover: #272727;
  --sidebar-text: #eadcc8;
  --primary: #b88a2a;
  --primary-hover: #9c7220;
  --danger: #9b3b2f;
  --danger-bg: #fff2ef;
  --success: #3f6b45;
  --success-bg: #edf6ee;
  --warning: #9a641b;
  --warning-bg: #fff7df;
  --info: #496d8f;
  --info-bg: #eef4f7;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(67, 45, 27, .07);
  --shadow-md: 0 10px 30px rgba(67, 45, 27, .11);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body, button, input, select, textarea { font: inherit; }

button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }

button, a { outline-offset: 3px; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(184, 138, 42, .28);
  outline-offset: 1px;
}

/* -------------------------------------------------------------------------- */
/* Shared typography                                                         */
/* -------------------------------------------------------------------------- */

h1, h2, h3, p { margin-top: 0; }

.topbar h1,
.module-shell h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -.025em;
}

.module-toolbar h2,
.module-header h2,
.modal-card h2,
.welcome-card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -.015em;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.muted {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
}

.optional-label,
.form-hint {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 400;
}

/* -------------------------------------------------------------------------- */
/* Authentication                                                            */
/* -------------------------------------------------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(circle at top, rgba(255,255,255,.9), transparent 45%),
    var(--bg);
}

.auth-card {
  width: min(430px, 100%);
  padding: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.auth-card picture {
  display: block;
}

.auth-logo {
  display: block;
  width: 150px;
  max-width: 70%;
  height: auto;
  margin: 0 auto 24px;
  object-fit: contain;
}

.auth-card h1 { margin: 0 0 5px; font-size: 25px; letter-spacing: -.025em; }
.auth-card > .muted { margin-bottom: 26px; }

.error,
.form-error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

/* -------------------------------------------------------------------------- */
/* Forms                                                                     */
/* -------------------------------------------------------------------------- */

label {
  display: block;
  margin: 18px 0 7px;
  color: #4b382b;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

input,
select {
  min-height: 42px;
  padding: 9px 12px;
}

textarea {
  min-height: 100px;
  padding: 10px 12px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder { color: #a89278; }

input:hover,
select:hover,
textarea:hover { border-color: #b9a17f; }

input:focus,
select:focus,
textarea:focus {
  border-color: #7a7a76;
  box-shadow: 0 0 0 3px rgba(184, 138, 42, .18);
  outline: none;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #f3eadb;
  color: #a89278;
  cursor: not-allowed;
}

/* -------------------------------------------------------------------------- */
/* Buttons / actions                                                         */
/* -------------------------------------------------------------------------- */

button,
.primary-button,
.secondary-button {
  display: inline-flex;
  width: auto;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .05s ease;
}

button:active,
.primary-button:active,
.secondary-button:active { transform: translateY(1px); }

.primary-button {
  background: var(--primary);
  color: #2b1b14;
  border-color: var(--primary);
  box-shadow: 0 2px 5px rgba(88, 57, 24, .14);
}

.primary-button:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.secondary-button {
  background: var(--surface);
  color: #3b291f;
  border-color: var(--border-strong);
}

.secondary-button:hover {
  background: #f4ecdf;
  border-color: #b9a17f;
}

.sidebar .secondary-button {
  width: 100%;
  background: #39251a;
  color: #e4e4e7;
  border-color: #523a28;
}

.sidebar .secondary-button:hover { background: #463020; border-color: #644832; }

.icon-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: #756354;
  font-size: 24px;
  font-weight: 400;
}

.icon-button:hover { background: #f3eadb; color: #2b1b14; }

.modal-actions,
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-actions { margin-top: 24px; }

.row-actions .primary-button,
.row-actions .secondary-button,
.row-actions button { min-height: 34px; padding: 7px 10px; font-size: 12px; }

/* -------------------------------------------------------------------------- */
/* Application shell                                                         */
/* -------------------------------------------------------------------------- */

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 252px;
  min-width: 252px;
  height: 100vh;
  overflow: hidden;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  border-right: 1px solid #242424;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 52px;
  padding: 4px 10px 20px;
  color: inherit;
  text-decoration: none;
}

.brand-block picture {
  display: block;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: block;
  object-fit: contain;
}

.brand-block strong,
.brand-block span { display: block; }
.brand-block strong { font-size: 15px; letter-spacing: -.01em; }
.brand-block span { margin-top: 1px; color: #a89278; font-size: 11px; }

.main-navigation {
  display: grid;
  gap: 3px;
  padding: 8px 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.main-navigation::-webkit-scrollbar,
.sidebar::-webkit-scrollbar { width: 0; height: 0; display: none; }

.nav-item {
  display: flex;
  min-height: 39px;
  align-items: center;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 550;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: #4a3120;
  color: #fff;
  border-color: #63472e;
  box-shadow: inset 3px 0 0 #d4aa4b;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 6px 2px;
  border-top: 1px solid #2b2b2b;
}

.app-main {
  min-width: 0;
  flex: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 82px;
  padding: 18px 34px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,253,248,.96);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.user-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  color: #665446;
  font-size: 12px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: #4b382b;
  font-size: 11px;
  font-weight: 650;
}

.movement-tag-cell { white-space: nowrap; }

.movement-tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border: 1px solid #d9c49a;
  border-radius: 999px;
  background: #f7eddc;
  color: #67491e;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
}

/* -------------------------------------------------------------------------- */
/* Page/module layout                                                        */
/* -------------------------------------------------------------------------- */

.module-content,
.dashboard-content {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 30px 34px 42px;
}

.module-toolbar,
.module-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.module-toolbar > div:first-child,
.module-header > div:first-child { min-width: 0; }

.module-toolbar .muted,
.module-header .muted { max-width: 760px; }

.module-header { padding-bottom: 2px; }

.toolbar,
.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(160px, 220px));
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar:has(> :only-child),
.filter-bar:has(> :only-child) {
  grid-template-columns: minmax(220px, 1fr);
}

.location-filter-bar { grid-template-columns: minmax(220px, 1fr) 220px; }

.catalog-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f3eadb;
}

.catalog-tab {
  min-height: 35px;
  padding: 7px 12px;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
}

.catalog-tab:hover { background: #eadcc8; color: var(--text); }
.catalog-tab.active { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }

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

.welcome-card,
.dashboard-card,
.table-card,
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.welcome-card { padding: 25px; }
.welcome-card h2 { margin-bottom: 4px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.dashboard-card {
  padding: 20px;
  min-height: 116px;
}

.dashboard-card strong { display: block; margin: 8px 0 4px; font-size: 20px; }
.card-label { color: var(--text-muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }

.table-card {
  overflow: hidden;
}

.table-card > table,
.catalog-table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: #fbf6ed;
  color: #756354;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .045em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

td, th { padding: 13px 15px; vertical-align: middle; }

tbody td {
  border-bottom: 1px solid #eee3d3;
  color: #4b382b;
  font-size: 13px;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfcfb; }

.description-cell {
  max-width: 360px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions-column,
td:last-child { white-space: nowrap; }

.empty-state,
.loading-cell {
  padding: 42px 20px;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f4ecdf;
  color: #665446;
  font-size: 11px;
  font-weight: 700;
}

.status-pill.active,
.status-pill.approved,
.status-pill.in { background: var(--success-bg); color: var(--success); }
.status-pill.inactive,
.status-pill.rejected { background: var(--danger-bg); color: var(--danger); }
.status-pill.pending { background: var(--warning-bg); color: var(--warning); }
.status-pill.out { background: var(--info-bg); color: var(--info); }

.catalog-message {
  margin-bottom: 18px;
  padding: 11px 14px;
  border: 1px solid #f4b4ae;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
}

/* -------------------------------------------------------------------------- */
/* Forms and modals                                                          */
/* -------------------------------------------------------------------------- */

.form-card {
  width: min(720px, 100%);
  padding: 26px;
}

.operation-form-card { margin: 0 auto; }

/* Native hidden elements must remain hidden even when component classes set display. */
[hidden] { display: none !important; }

/* Stock transfer form */
.transfer-form-card {
  width: min(900px, 100%);
  padding: 28px;
  margin-bottom: 28px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-field-wide { grid-column: 1 / -1; }

.form-field label {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.field-help {
  min-height: 17px;
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
}

@media (max-width: 680px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-field-wide { grid-column: auto; }
  .transfer-form-card { padding: 20px; }
}


.modal,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 15, 15, .52);
  backdrop-filter: blur(3px);
}

.modal[hidden],
.modal-backdrop[hidden] { display: none; }

.modal-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px rgba(0,0,0,.22);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  margin-bottom: 4px;
  border-bottom: 1px solid #eee3d3;
}

.modal-header h2 { margin-bottom: 0; }

.inventory-ledger-toolbar { margin-top: 34px; margin-bottom: 16px; }

.ledger-date-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.ledger-date-controls > div {
  min-width: 145px;
}

.ledger-date-controls label {
  margin-top: 0;
}

@media (max-width: 820px) {
  .ledger-date-controls {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .ledger-date-controls > div {
    min-width: 0;
  }

  .ledger-date-controls .secondary-button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

/* -------------------------------------------------------------------------- */
/* Responsive                                                                */
/* -------------------------------------------------------------------------- */

@media (max-width: 1050px) {
  .sidebar { width: 220px; min-width: 220px; }
  .module-content, .dashboard-content { padding-left: 24px; padding-right: 24px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .toolbar, .filter-bar { grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(130px, 180px)); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar {
    position: static;
    width: 100%;
    min-width: 0;
    height: auto;
    max-height: none;
    padding: 12px 14px;
  }
  .brand-block { padding-bottom: 10px; }
  .main-navigation {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 5px 0 9px;
  }
  .nav-item { flex: 0 0 auto; min-height: 36px; }
  .sidebar-footer { display: none; }
  .topbar { position: static; }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 18px;
  }
  .user-summary { justify-content: flex-start; }
  .module-content, .dashboard-content { padding: 22px 16px 32px; }
  .module-toolbar, .module-header { flex-direction: column; gap: 14px; }
  .module-toolbar > .primary-button,
  .module-toolbar > .secondary-button { align-self: stretch; }
  .toolbar, .filter-bar, .location-filter-bar { grid-template-columns: 1fr; }
  .catalog-tabs { width: 100%; }
  .catalog-tab { flex: 1; }
  .table-card { overflow-x: auto; }
  .table-card > table { min-width: 700px; }
  .form-card { padding: 20px; }
  .modal, .modal-backdrop { padding: 12px; }
  .modal-card { max-height: calc(100vh - 24px); padding: 20px; }
}

@media (max-width: 430px) {
  .auth-card { padding: 26px 20px; }
  .modal-actions { flex-direction: column-reverse; align-items: stretch; }
  .modal-actions > * { width: 100%; }
}


/* -------------------------------------------------------------------------- */
/* Suroor luxury palette refinements                                         */
/* -------------------------------------------------------------------------- */

.brand-block strong { color: #f5e5c8; }
.brand-block span { color: #c9ab7a; }

.eyebrow { color: #8b6a45; }

.role-badge {
  background: #f3e7d4;
  border-color: #d8c19c;
  color: #6d4c2d;
}

.sidebar .nav-item.active {
  background: #4a3020;
  color: #f8ead2;
  border-color: #62462e;
  box-shadow: inset 3px 0 0 #d4aa4b;
}

.sidebar-footer { border-top-color: #4a3222; }

.sidebar .secondary-button {
  background: #3a271b;
  color: #ead8bb;
  border-color: #5a3e29;
}

.sidebar .secondary-button:hover {
  background: #493020;
  border-color: #765535;
}

.topbar { border-bottom-color: #dfd0b9; }

thead th {
  background: #f8f0e4;
  color: #806346;
}

tbody td { border-bottom-color: #eee3d3; }

.catalog-tabs {
  background: #f0e4d2;
  border-color: #d9c4a3;
}

.catalog-tab:hover { background: #e6d5bc; }
.catalog-tab.active {
  background: #fffdf8;
  color: #3b291f;
  border-color: #d9c4a3;
}

.auth-shell {
  background:
    radial-gradient(circle at 50% 0%, rgba(214, 177, 100, .16), transparent 42%),
    #f7f2e9;
}

input, select, textarea { background: #fffdf8; }
input:disabled, select:disabled, textarea:disabled { background: #f1e8da; }

.status-badge.active, .status-active {
  background: #edf3e8;
  color: #456548;
  border-color: #c8d9c5;
}

@media (max-width: 760px) {
  .sidebar { width: 220px; min-width: 220px; }
  .topbar { padding-left: 20px; padding-right: 20px; }
  .module-content, .dashboard-content { padding-left: 20px; padding-right: 20px; }
}

/* -------------------------------------------------------------------------- */
/* Suppliers & Purchase Orders                                               */
/* -------------------------------------------------------------------------- */

.modal-card-wide { width: min(920px, 100%); }

.purchase-items {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.purchase-item-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.7fr) 110px 130px 110px 42px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.purchase-item-row input,
.purchase-item-row select { min-width: 0; }

.purchase-line-total {
  text-align: right;
  font-weight: 700;
  color: #5d4027;
  white-space: nowrap;
}

.purchase-total {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fbf4e8;
  text-align: right;
  color: var(--text-muted);
}

.purchase-total strong {
  margin-left: 8px;
  color: var(--text);
  font-size: 18px;
}

.status-draft { background: #f3e7d4; color: #6d4c2d; border-color: #dcc6a5; }
.status-ordered { background: #eef4f7; color: #496d8f; border-color: #cadbe5; }
.status-partially_received { background: #fff7df; color: #8a5b18; border-color: #ead6a1; }
.status-received { background: #edf3e8; color: #456548; border-color: #c8d9c5; }
.status-cancelled { background: #fff2ef; color: #9b3b2f; border-color: #e8c5bf; }

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.compact-button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.danger-button {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid #d9aaa2;
  border-radius: var(--radius-sm);
  background: #fff2ef;
  color: #8f342a;
  cursor: pointer;
  font-weight: 700;
}

.danger-button:hover { background: #fbe4df; }
.danger-button:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 820px) {
  .purchase-item-row {
    grid-template-columns: 1fr 100px 120px 100px 40px;
    overflow-x: auto;
  }
}

/* Conditional sales controls inside Stock Out */
.conditional-form-section { margin-top: 18px; padding: 18px; border: 1px solid var(--border, #d8c6a5); border-radius: 12px; background: rgba(180, 130, 40, 0.06); }
.conditional-form-heading { margin-bottom: 12px; }
.conditional-form-heading .eyebrow { margin-bottom: 4px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 700px) { .form-grid-2 { grid-template-columns: 1fr; } }

.table-action-button { white-space: nowrap; padding: 7px 11px; font-size: 12px; }

.invoice-result { margin-top: 12px; display: flex; justify-content: flex-end; }

/* Invoice registry / settings */
.settings-actions { display:flex; gap:10px; align-items:center; }
.settings-actions select { min-width:180px; }
.settings-stat-grid { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:16px; margin:18px 0; }
.stat-card { padding:18px 20px; border:1px solid var(--border, #d8c6a5); border-radius:14px; background:rgba(255,255,255,.52); }
.stat-card span { display:block; color:var(--muted, #6d5b4b); font-size:12px; text-transform:uppercase; letter-spacing:.08em; }
.stat-card strong { display:block; margin-top:6px; font-size:22px; color:var(--brown, #2d211a); }
@media (max-width: 700px) { .settings-actions { flex-direction:column; align-items:stretch; } .settings-stat-grid { grid-template-columns:1fr; } }


/* Settings danger zone */
.settings-danger-card { margin-top: 24px; padding: 22px; border: 1px solid #c98f82; border-radius: 14px; background: #fff8f6; display:flex; align-items:center; justify-content:space-between; gap:24px; }
.danger-eyebrow { color: #9f3f2f; }
.danger-button { border: 1px solid #8f2f22; background: #8f2f22; color: #fff; border-radius: 9px; padding: 11px 16px; font: inherit; font-weight: 700; cursor:pointer; }
.danger-button:hover { background:#74251b; }
.settings-reset-modal { max-width: 560px; }
.settings-reset-modal .modal-header { display:flex; justify-content:space-between; align-items:flex-start; }
.settings-reset-modal .field-label { display:block; margin-top:16px; margin-bottom:7px; font-weight:600; }
.settings-reset-modal .text-input { width:100%; box-sizing:border-box; }
.settings-reset-modal .form-error { margin-top:12px; }
.settings-reset-modal .modal-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:20px; }
@media (max-width:700px) { .settings-danger-card { flex-direction:column; align-items:stretch; } }

/* -------------------------------------------------------------------------- */
/* Responsive navigation rail + mobile-first shell                           */
/* -------------------------------------------------------------------------- */

:root { --rail-expanded:252px; --rail-collapsed:76px; --mobile-header:64px; }
body { overflow-x:hidden; }
.sidebar { scrollbar-width:none; -ms-overflow-style:none; }
.sidebar::-webkit-scrollbar { width:0; height:0; display:none; }
.sidebar { width:var(--rail-expanded); min-width:var(--rail-expanded); position:sticky; transition:width .2s ease,min-width .2s ease,transform .2s ease; z-index:30; }
.sidebar-toggle { position:absolute; top:20px; right:10px; width:32px; min-height:32px; padding:0; border:1px solid #62462e; border-radius:50%; background:#3a271b; color:#f1ddbb; font-size:22px; line-height:1; z-index:2; }
.sidebar-toggle:hover { background:#4a3020; }
.sidebar-toggle-icon { display:block; transform:translateY(-1px); }
.nav-item { position:relative; min-width:0; gap:8px; }
.nav-icon { display:inline-flex; width:30px; min-width:30px; height:30px; align-items:center; justify-content:center; border-radius:8px; background:rgba(255,255,255,.055); color:#d7b978; font-size:11px; font-weight:800; text-transform:uppercase; }
.nav-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sidebar-collapsed .sidebar { width:var(--rail-collapsed); min-width:var(--rail-collapsed); padding-left:10px; padding-right:10px; }
.sidebar-collapsed .brand-block { justify-content:center; padding-left:0; padding-right:0; padding-bottom:20px; }
.sidebar-collapsed .brand-block > div, .sidebar-collapsed .nav-label, .sidebar-collapsed .sidebar-footer { display:none; }
.sidebar-collapsed .nav-item { justify-content:center; padding:6px; }
.sidebar-collapsed .nav-icon { width:40px; min-width:40px; height:40px; }
.sidebar-collapsed .nav-item.active { box-shadow:inset 0 0 0 1px #62462e; }
.sidebar-collapsed .sidebar-toggle { right:6px; }
.mobile-menu-button { display:none; width:40px; min-width:40px; min-height:40px; padding:0; border:1px solid var(--border); border-radius:10px; background:var(--surface); color:var(--text); font-size:19px; }
.sidebar-overlay { display:none; }
.module-content,.dashboard-content { min-width:0; }
.table-card { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table-card table { min-width:680px; }
.toolbar,.filter-bar,.location-filter-bar { min-width:0; }

@media (max-width:1100px) {
  .module-content,.dashboard-content { padding-left:22px; padding-right:22px; }
  .topbar { padding-left:22px; padding-right:22px; }
  .toolbar,.filter-bar { grid-template-columns:minmax(160px,1fr) repeat(2,minmax(120px,170px)); }
}

@media (max-width:820px) {
  .app-shell { display:block; min-height:100vh; }
  .sidebar { position:fixed; inset:0 auto 0 0; width:282px; min-width:282px; height:100dvh; max-height:none; transform:translateX(-105%); box-shadow:16px 0 40px rgba(43,27,20,.2); padding:16px 14px; }
  body.sidebar-open .sidebar { transform:translateX(0); }
  body.sidebar-open { overflow:hidden; }
  .sidebar-toggle { display:block; }
  .sidebar-overlay { position:fixed; inset:0; display:block; z-index:25; background:rgba(31,20,15,.42); backdrop-filter:blur(2px); }
  .sidebar-overlay[hidden] { display:none; }
  .sidebar-collapsed .sidebar { width:282px; min-width:282px; padding:16px 14px; }
  .sidebar-collapsed .brand-block { justify-content:flex-start; padding-left:10px; padding-right:48px; }
  .sidebar-collapsed .brand-block > div,.sidebar-collapsed .nav-label,.sidebar-collapsed .sidebar-footer { display:block; }
  .sidebar-collapsed .nav-item { justify-content:flex-start; padding:8px 11px; }
  .sidebar-collapsed .nav-icon { width:30px; min-width:30px; height:30px; }
  .sidebar-collapsed .nav-item.active { box-shadow:inset 3px 0 0 #d4aa4b; }
  .main-navigation { overflow-y:auto; max-height:calc(100dvh - 150px); scrollbar-width:none; -ms-overflow-style:none; }
  .main-navigation::-webkit-scrollbar { width:0; height:0; display:none; }
  .mobile-menu-button { display:inline-flex; align-items:center; justify-content:center; }
  .topbar { position:sticky; top:0; min-height:var(--mobile-header); padding:10px 16px; gap:10px; z-index:20; }
  .topbar > div:nth-child(2) { margin-left:auto; }
  .topbar h1 { font-size:22px; }
  .user-summary { gap:6px; }
  .user-summary #user-email { max-width:170px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .module-content,.dashboard-content { padding:18px 14px 30px; }
  .module-toolbar,.module-header { margin-bottom:16px; }
  .module-toolbar > .primary-button,.module-toolbar > .secondary-button { width:100%; }
  .toolbar,.filter-bar,.location-filter-bar { grid-template-columns:1fr; gap:10px; padding:14px; }
  .form-grid,.form-grid-2 { grid-template-columns:1fr; }
  .form-card { padding:18px; }
  .modal,.modal-backdrop { padding:10px; }
  .modal-card,.modal-card-wide { width:100%; max-height:calc(100dvh - 20px); padding:18px; border-radius:14px; }
  .purchase-item-row { grid-template-columns:1fr 90px 110px 90px 40px; overflow-x:auto; }
}

@media (max-width:560px) {
  .topbar { align-items:center; }
  .topbar > div:first-of-type { min-width:0; }
  .topbar .eyebrow { margin-bottom:2px; font-size:9px; }
  .topbar h1 { font-size:20px; }
  .user-summary { flex-shrink:0; }
  .user-summary #user-email { display:none; }
  .role-badge { max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .module-toolbar,.module-header { gap:10px; }
  .module-toolbar h2,.module-header h2 { font-size:18px; }
  .muted { font-size:13px; }
  .table-card { margin-left:-2px; margin-right:-2px; border-radius:10px; }
  .table-card table { min-width:620px; }
  .table-card th,.table-card td { padding:9px 10px; font-size:12px; }
  .row-actions { justify-content:flex-start; }
  .row-actions > * { min-height:36px; }
  .settings-danger-card { padding:16px; }
  .settings-actions { width:100%; }
  .settings-actions > * { width:100%; }
}

@media (max-width:390px) {
  .module-content,.dashboard-content { padding-left:10px; padding-right:10px; }
  .topbar { padding-left:10px; padding-right:10px; }
  .modal-card { padding:14px; }
  .primary-button,.secondary-button,button { min-height:42px; }
}

/* -------------------------------------------------------------------------- */
/* Mobile navigation / layout final pass                                    */
/* -------------------------------------------------------------------------- */

@media (max-width: 820px) {
  /* The mobile drawer is a real vertical navigation, never a horizontal flex row. */
  .sidebar {
    width: min(300px, calc(100vw - 56px));
    min-width: min(300px, calc(100vw - 56px));
    padding: 16px 12px 14px;
    overflow: hidden;
    border-right: 1px solid #4a3222;
    transform: translate3d(-105%, 0, 0);
    transition: transform .22s ease;
  }

  body.sidebar-open .sidebar {
    transform: translate3d(0, 0, 0);
  }

  /* Never inherit the old mobile horizontal-nav rule. */
  .main-navigation {
    display: grid;
    grid-template-columns: 1fr;
    align-content: start;
    align-items: start;
    justify-items: stretch;
    gap: 4px;
    width: 100%;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px 0;
  }

  .nav-item,
  .sidebar-collapsed .nav-item {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    flex: none;
    justify-content: flex-start;
    align-self: start;
    padding: 7px 10px;
  }

  .nav-icon,
  .sidebar-collapsed .nav-icon {
    width: 32px;
    min-width: 32px;
    height: 32px;
  }

  .sidebar-collapsed .nav-label,
  .sidebar-collapsed .brand-block > div,
  .sidebar-collapsed .sidebar-footer {
    display: block;
  }

  .sidebar-collapsed .brand-block {
    justify-content: flex-start;
    padding-left: 8px;
    padding-right: 48px;
  }

  .sidebar-collapsed .nav-item.active {
    box-shadow: inset 3px 0 0 #d4aa4b;
  }

  .sidebar-toggle {
    top: 16px;
    right: 10px;
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
  }

  .sidebar-overlay {
    background: rgba(31, 20, 15, .52);
    backdrop-filter: blur(3px);
  }

  /* Compact mobile header: menu, page title, account badge. */
  .topbar {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    min-height: 68px;
    padding: 10px 14px;
    gap: 10px;
  }

  .mobile-menu-button {
    display: inline-flex;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 10px;
    font-size: 20px;
  }

  .topbar > div:first-of-type {
    min-width: 0;
    overflow: hidden;
  }

  .topbar .eyebrow {
    margin-bottom: 2px;
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-summary {
    min-width: 0;
    justify-content: flex-end;
  }

  .user-summary #user-email {
    display: none;
  }

  .role-badge {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Give all page content a comfortable phone gutter. */
  .module-content,
  .dashboard-content {
    width: 100%;
    padding: 16px 12px 28px;
  }

  .welcome-card,
  .dashboard-card,
  .form-card,
  .table-card,
  .filter-bar,
  .toolbar,
  .location-filter-bar {
    max-width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .module-toolbar,
  .module-header {
    width: 100%;
  }

  .module-toolbar > .primary-button,
  .module-toolbar > .secondary-button {
    width: 100%;
  }

  .modal-card,
  .modal-card-wide {
    width: min(100%, 520px);
    max-width: 100%;
    margin: 0 auto;
  }
}

@media (max-width: 430px) {
  .sidebar {
    width: min(292px, calc(100vw - 48px));
    min-width: min(292px, calc(100vw - 48px));
  }

  .topbar {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    padding-left: 10px;
    padding-right: 10px;
    gap: 8px;
  }

  .topbar h1 { font-size: 19px; }
  .role-badge { max-width: 86px; }

  .module-content,
  .dashboard-content {
    padding-left: 10px;
    padding-right: 10px;
  }
}
.customer-history-list{display:grid;gap:8px}.customer-history-row{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid rgba(122,83,42,.15)}

/* Reports + dashboard analytics */
.dashboard-content{display:flex;flex-direction:column;gap:18px}.dashboard-toolbar{display:flex;justify-content:space-between;gap:18px;align-items:end}.dashboard-toolbar h2{margin:0;font-size:20px}.dashboard-date-controls,.report-filters{display:flex;gap:10px;align-items:end}.dashboard-date-controls label,.report-filters label{margin:0 0 5px}.dashboard-date-controls>div,.report-filters>div{min-width:145px}.dashboard-stats{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:12px}.dashboard-stat,.report-stat{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:16px;box-shadow:var(--shadow-sm);min-width:0}.dashboard-stat span,.report-stat span{display:block;color:var(--text-muted);font-size:12px;font-weight:700}.dashboard-stat strong,.report-stat strong{display:block;margin-top:7px;font-size:21px;line-height:1.2;overflow:hidden;text-overflow:ellipsis}.dashboard-stat small,.report-stat small{display:block;margin-top:7px;color:var(--text-soft);font-size:11px}.report-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:12px;margin-bottom:18px}.report-panel{overflow:hidden}.panel-header{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:18px;border-bottom:1px solid var(--border)}.panel-header h2{margin:0;font-size:19px}.panel-header select{width:min(260px,100%)}.report-chart{padding:18px;display:flex;flex-direction:column;gap:12px;min-height:120px}.chart-row{display:grid;grid-template-columns:minmax(130px,220px) 1fr minmax(80px,130px);gap:10px;align-items:center}.chart-label{font-size:12px;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chart-track{height:12px;border-radius:999px;background:var(--surface-subtle);overflow:hidden;border:1px solid var(--border)}.chart-bar{height:100%;border-radius:999px;background:var(--primary)}.chart-row strong{text-align:right;font-size:12px}.chart-empty{color:var(--text-muted);font-size:13px;padding:15px 0}.table-scroll{overflow-x:auto}.reports-page{padding-bottom:30px}
@media(max-width:1100px){.dashboard-stats,.report-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:820px){.dashboard-toolbar,.dashboard-date-controls,.report-filters{flex-direction:column;align-items:stretch}.dashboard-date-controls>div,.report-filters>div{min-width:0}.dashboard-stats,.report-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.panel-header{align-items:stretch;flex-direction:column}.panel-header select{width:100%}.chart-row{grid-template-columns:minmax(90px,1fr) 1.4fr minmax(70px,90px)}}
@media(max-width:480px){.dashboard-stats,.report-grid{grid-template-columns:1fr}.dashboard-stat strong,.report-stat strong{font-size:19px}.chart-row{grid-template-columns:1fr;gap:5px}.chart-row strong{text-align:left}}

/* Users & Roles */
.users-stat-grid { margin-bottom: 18px; }
.users-table strong { display:block; font-size:13px; }
.users-email { margin-top:2px; color:var(--text-muted); font-size:12px; }
.user-status-active { color:var(--success); font-weight:700; }
.user-status-inactive { color:var(--danger); font-weight:700; }
.user-protected-label { display:inline-flex; align-items:center; min-height:34px; padding:7px 9px; border:1px solid var(--border); border-radius:8px; color:var(--text-muted); font-size:11px; font-weight:700; white-space:nowrap; }
.user-modal-card { width:min(600px,100%); }
.users-page .module-toolbar .settings-actions { flex-shrink:0; }
@media (max-width:700px) { .users-page .module-toolbar .settings-actions { width:100%; } }

/* Operational dashboard signals */
.dashboard-stat-link{display:inline-block;margin-top:9px;font-size:11px;font-weight:700;color:var(--primary);text-decoration:none}.dashboard-stat-link:hover{text-decoration:underline}
.dashboard-panels{display:grid;grid-template-columns:1.25fr .9fr;gap:18px}.dashboard-panel{overflow:hidden}.attention-list,.top-selling-list{padding:6px 18px 14px}.attention-item{display:flex;align-items:center;gap:14px;padding:13px 0;border-bottom:1px solid var(--border);text-decoration:none;color:inherit}.attention-item:last-child{border-bottom:0}.attention-item>strong{display:grid;place-items:center;min-width:38px;height:38px;border-radius:10px;background:var(--surface-subtle);font-size:15px}.attention-item div{min-width:0;flex:1}.attention-item span,.attention-item small{display:block}.attention-item span{font-size:13px;font-weight:700}.attention-item small{margin-top:3px;color:var(--text-muted);font-size:11px}.attention-item b{font-size:20px;color:var(--text-muted)}.attention-empty{padding:24px 0;color:var(--text-muted);font-size:13px}.top-selling-row{display:flex;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid var(--border)}.top-selling-row:last-child{border-bottom:0}.top-selling-rank{width:24px;font-size:12px;font-weight:800;color:var(--text-muted)}.top-selling-row div{min-width:0;flex:1}.top-selling-row strong,.top-selling-row small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.top-selling-row strong{font-size:13px}.top-selling-row small{margin-top:3px;color:var(--text-muted);font-size:11px}.top-selling-row>b{font-size:12px}
@media(max-width:820px){.dashboard-panels{grid-template-columns:1fr}}


/* Sale charge controls */
.form-field-compact { max-width: 220px; }
.custom-charges-section { margin-top: 2px; }
.custom-charges-header { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:10px; }
.custom-charges-header label { display:block; margin-bottom:3px; }
.custom-charges-list { display:grid; gap:8px; }
.custom-charge-row { display:grid; grid-template-columns:minmax(180px, 1fr) 150px 40px; gap:8px; align-items:center; }
.custom-charge-row input { min-width:0; }
.sale-charge-grid { grid-template-columns:repeat(3, minmax(0, 1fr)); }
@media (max-width:700px) { .sale-charge-grid { grid-template-columns:1fr; } .custom-charge-row { grid-template-columns:1fr 120px 40px; } .custom-charges-header { align-items:flex-start; } }
