:root {
  --gold: #c9a24e;
  --gold-dark: #9f7b2f;
  --gold-light: #e8ca75;
  --danger: #b84c43;
  --success: #2d7c59;

  --bg: #f7f5f1;
  --surface: #ffffff;
  --surface-alt: #f3f1ed;
  --text: #1d1a16;
  --text-secondary: #77716a;
  --text-primary: #1d1a16;
  --muted: #77716a;
  --hover-bg: rgba(201,162,78,.08);
  --border: #e9e4da;
  --input-bg: #ffffff;
  --shadow: rgba(32,27,19,.07);
  --shadow-heavy: rgba(0,0,0,.16);
  --overlay: rgba(0,0,0,.45);

  --sidebar-bg: #12110f;
  --sidebar-text: rgba(255,255,255,.72);
  --sidebar-text-secondary: rgba(255,255,255,.58);
  --sidebar-hover: rgba(201,162,78,.18);
  --sidebar-feature-border: rgba(201,162,78,.32);
  --sidebar-feature-bg: linear-gradient(180deg, rgba(201,162,78,.18), rgba(255,255,255,.04));

  --chart-bg: linear-gradient(180deg, #fbfaf6, #f1ede4);
  --chart-line-bg: linear-gradient(180deg, #fff, #f2eee5);
  --chart-fill: rgba(201,162,78,.18);

  --label-color: #39342d;
  --stock-warning-bg: #fffaf0;
  --stock-out-bg: #fff5f3;
  --badge-warning-bg: #fff4df;
  --badge-warning-text: #9a6b12;
  --badge-danger-bg: #fde8e6;
  --badge-danger-text: #9f3d36;
  --placeholder-bg: linear-gradient(160deg, #efe9df, #ddd4c6);
  --success-bg: rgba(45,124,89,.12);
  --gold-border: rgba(201,162,78,.45);
  --gold-focus: rgba(201,162,78,.18);
  --gold-shadow: rgba(159,123,47,.28);
  --brand-mark-border: rgba(201,162,78,.7);

  --toast-text: #fff;
  --black: #11100e;
  --white: #fff;
  --button-text: #15120d;
  --button-gradient: linear-gradient(135deg, #f2d88d, var(--gold));
  --topbar-bg: rgba(247,245,241,.88);
  --warning-border: rgba(201,162,78,.55);
  --danger-border: rgba(184,76,67,.5);
  --visual-placeholder-bg: linear-gradient(135deg, #2a2620, #4a4034);
  --visual-overlay: rgba(0,0,0,.78);
  --login-overlay: rgba(17,16,14,.9);
  --login-overlay-light: rgba(17,16,14,.28);
  --login-text-muted: rgba(255,255,255,.78);

  --theme-transition: .3s ease;
  --font-heading: 'Poppins', sans-serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font-body);
}

body.dark {
  --bg: #11100e;
  --surface: #1a1815;
  --surface-alt: #27231f;
  --text: #f9f4e9;
  --text-secondary: #b8afa2;
  --text-primary: #f9f4e9;
  --muted: #b8afa2;
  --hover-bg: rgba(201,162,78,.12);
  --border: #363029;
  --input-bg: #211e1a;
  --shadow: rgba(0,0,0,.25);
  --shadow-heavy: rgba(0,0,0,.4);
  --overlay: rgba(0,0,0,.6);

  --chart-bg: linear-gradient(180deg, #211e1a, #1a1815);
  --chart-line-bg: linear-gradient(180deg, #211e1a, #1a1815);
  --chart-fill: rgba(201,162,78,.15);

  --label-color: #b8afa2;
  --stock-warning-bg: #2a2418;
  --stock-out-bg: #2a1a18;
  --badge-warning-bg: #3d2b12;
  --badge-warning-text: #e8ca75;
  --badge-danger-bg: #3d1e1a;
  --badge-danger-text: #e88a7a;
  --placeholder-bg: linear-gradient(160deg, #2a2620, #1a1815);
  --success-bg: rgba(45,124,89,.25);
  --gold-border: rgba(201,162,78,.3);
  --gold-focus: rgba(201,162,78,.12);
  --gold-shadow: rgba(0,0,0,.3);

  --topbar-bg: rgba(17,16,14,.88);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background: var(--bg);
  transition: color var(--theme-transition), background var(--theme-transition);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
}
h1 { font-weight: 700; }

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(260px, .9fr);
  background: var(--black);
  overflow: hidden;
}

.login-art {
  position: relative;
  padding: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--white);
  background:
    linear-gradient(135deg, rgba(17,16,14,.92) 0%, rgba(17,16,14,.72) 50%, rgba(17,16,14,.88) 100%),
    url("../images/img1.png") center/cover no-repeat;
}

.login-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(201,162,78,.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(201,162,78,.08) 0%, transparent 50%);
  pointer-events: none;
}

.login-art-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  max-width: 560px;
  position: relative;
  z-index: 1;
}

.login-art-text {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand-mark {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border: 1px solid var(--brand-mark-border);
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 30px;
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(201,162,78,.15);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-art h1 {
  margin: 0;
  font-size: clamp(42px, 6vw, 76px);
  line-height: .95;
  letter-spacing: 0;
}

.login-art p:last-child {
  color: var(--login-text-muted);
  font-size: 18px;
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 32px;
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-alt) 100%);
  position: relative;
}

.login-panel::before {
  content: "";
  position: absolute;
  top: -120px;
  right: -120px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,162,78,.06) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  width: min(420px, 100%);
  padding: 40px 36px;
  border: 1px solid var(--gold-border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 32px var(--shadow-heavy), 0 0 0 1px var(--gold-focus);
  position: relative;
  z-index: 1;
  animation: loginCardIn .5s cubic-bezier(.23,1,.32,1) both;
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo-center {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.login-logo-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  padding: 3px;
  background: var(--black);
  box-shadow: 0 4px 20px rgba(201,162,78,.2);
  transition: transform .3s ease, box-shadow .3s ease;
}

.login-logo-circle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 28px rgba(201,162,78,.3);
}

.login-shop-name {
  display: none;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.02em;
  margin: 0 0 4px;
}

.logo-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--black);
  color: var(--gold);
  border-radius: 8px;
  font-family: var(--font-heading);
  font-weight: 800;
}

small { color: var(--text-secondary); }

.login-card h2 {
  margin: 24px 0 8px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.login-card p { color: var(--text-secondary); }

label {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  color: var(--label-color);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.01em;
  transition: color var(--theme-transition);
}

.language-field {
  margin: 0 0 20px;
}

.language-switcher {
  width: auto;
  min-width: 128px;
  padding: 10px 12px;
  border-color: var(--gold-border);
  font-weight: 800;
}

input, select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  background: var(--input-bg);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
  font-size: 15px;
}

input:hover, select:hover {
  border-color: var(--gold-border);
}

input:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-focus), 0 2px 8px rgba(201,162,78,.12);
}

.login-card button, .gold-button {
  border: 0;
  border-radius: 10px;
  padding: 13px 18px;
  color: var(--button-text);
  background: var(--button-gradient);
  font-weight: 800;
  box-shadow: 0 4px 16px var(--gold-shadow);
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}

.login-card button:hover, .gold-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--gold-shadow);
}

.login-card button:active, .gold-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px var(--gold-shadow);
}

.login-card button {
  width: 100%;
  margin-top: 24px;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.login-card button.password-toggle {
  width: auto;
  min-height: 0;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
  box-shadow: none;
}

.login-card button.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: .75;
}

.login-card button.btn-loading i.bi {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: splashSpin .6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

.login-card button.btn-loading .btn-text { display: none; }
.login-card button.btn-loading .btn-loading-text { display: inline; }
.login-card button:not(.btn-loading) .btn-loading-text { display: none; }

.login-recovery-hint {
  text-align: center;
  margin-top: 14px;
  font-size: 12px;
}

.login-recovery-hint a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color .2s ease;
}

.login-recovery-hint a:hover {
  color: var(--gold);
}

.login-card .link-button {
  background: none;
  border: none;
  color: var(--gold);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 8px 0;
  margin-top: 4px;
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: 0.75;
}
.login-card .link-button:hover {
  opacity: 1;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  padding: 24px 18px;
  color: var(--white);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  gap: 26px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(201,162,78,.35) transparent;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(201,162,78,.35); border-radius: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar .logo { background: var(--white); color: var(--black); }
.sidebar small { color: var(--sidebar-text-secondary); }

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: transform .2s ease, opacity .2s ease;
}

.sidebar-brand:hover {
  transform: scale(1.02);
  opacity: 0.88;
}

.sidebar-brand:active {
  transform: scale(0.97);
  opacity: 0.75;
}

.sidebar-logo {
  width: 192px;
  height: 192px;
  object-fit: contain;
  border-radius: 12px;
  flex-shrink: 0;
  max-width: 100%;
}

/* Scale the enlarged logo down on shorter screens so the sidebar never overflows */
@media (max-height: 880px) {
  .sidebar-logo { width: 168px; height: 168px; }
}
@media (max-height: 800px) {
  .sidebar-logo { width: 144px; height: 144px; }
}
@media (max-height: 720px) {
  .sidebar-logo { width: 120px; height: 120px; }
}
@media (max-height: 640px) {
  .sidebar-logo { width: 96px; height: 96px; }
}

.sidebar-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--gold);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 13px 14px;
  text-align: left;
  color: var(--sidebar-text);
  background: transparent;
  font-weight: 700;
}

.nav-item.active, .nav-item:hover {
  color: var(--white);
  background: var(--sidebar-hover);
}

.sidebar-feature {
  margin-top: auto;
  padding: 18px;
  border: 1px solid var(--sidebar-feature-border);
  border-radius: 8px;
  background: var(--sidebar-feature-bg);
}

.sidebar-feature span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-feature p {
  margin-bottom: 0;
  color: var(--sidebar-text-secondary);
  font-size: 13px;
}

.workspace {
  min-width: 0;
  background: var(--bg);
}

.topbar {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

/* Legacy selectors – kept hidden for safety */
.topbar-left,
.topbar-page-title {
  display: none;
}

/* ── Topbar Center: Search + Controls ─────────────────── */
.topbar-center {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.topbar-search {
  flex: 1;
  max-width: 320px;
}

/* ── Topbar Right: Status + Clock + User + Controls ─────── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* Online Status */
.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.offline {
  background: #ef4444;
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Clock */
.topbar-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
  flex-shrink: 0;
}

.clock-time {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.clock-date {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* User Area + Dropdown */
.topbar-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease;
}

.topbar-user:hover {
  background: var(--hover-bg);
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.topbar-user-info strong {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.topbar-chevron {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform .2s ease;
}

.topbar-user.open .topbar-chevron {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 30px var(--shadow-heavy);
  z-index: 100;
  padding: 6px;
  animation: dropdownIn .15s ease;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease;
}

.dropdown-item:hover {
  background: var(--hover-bg);
}

.dropdown-item i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  color: var(--text-secondary);
}

.dropdown-danger {
  color: var(--danger);
}

.dropdown-danger i {
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* ── Profile Modal ─────────────────────────────────────── */
.profile-details {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.profile-row:last-child {
  border-bottom: none;
}

.profile-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.profile-label i {
  width: 16px;
  text-align: center;
  font-size: 14px;
}

.profile-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  word-break: break-word;
}

.menu-button {
  display: none;
  min-width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 800;
  align-items: center;
  justify-content: center;
}

.hamburger-icon {
  font-size: 22px;
  line-height: 1;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
}

.search-box span {
  color: var(--gold-dark);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
}

.search-box input {
  border: 0;
  box-shadow: none;
}

.admin-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-profile img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-owner {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--white);
}

.role-seller {
  background: var(--surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.page {
  display: none;
  padding: 28px;
}

.page.active { display: block; }

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 8px;
  margin-bottom: 22px;
}

.page-heading h2 {
  margin: 0;
  font-size: 34px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stats-grid.compact { grid-template-columns: repeat(3, minmax(180px, 1fr)); align-items: start; }

.stat-card, .panel, .product-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 28px var(--shadow);
  transition: background var(--theme-transition), border-color var(--theme-transition), box-shadow var(--theme-transition);
}

.stat-card {
  padding: 18px;
}

.stat-card span {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 28px;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.15;
}

.stat-card.warning { border-color: var(--warning-border); }
.stat-card.danger { border-color: var(--danger-border); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(240px, .8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel h3, .panel-title h3 {
  margin: 0;
  font-size: 18px;
}

.panel-title span { color: var(--text-secondary); font-size: 13px; }

.bar-chart {
  min-height: 280px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 14px;
  align-items: end;
  padding: 20px;
  border-radius: 8px;
  background: var(--chart-bg);
}

.sales-chart-svg {
  grid-column: 1 / -1;
  width: 100%;
  height: 250px;
}

.sales-chart-svg rect {
  fill: var(--gold);
  border-radius: 8px;
}

.sales-chart-svg .chart-day-label {
  fill: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
}

.empty-state {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  margin: 0;
  color: var(--text-secondary);
  font-weight: 800;
  text-align: center;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th, td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.paid { color: var(--success); background: var(--success-bg); }
.ghost-button, .logout-button {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
}

.logout-button {
  color: var(--danger);
  border-color: var(--danger);
  white-space: nowrap;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 220px;
  gap: 12px;
  margin-bottom: 18px;
}

.product-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.product-image-field { display: flex; flex-direction: column; gap: 10px; }

.image-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.image-input-row input[type="file"] {
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

.image-preview {
  width: 100%;
  max-width: 220px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.image-preview img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
}

.edit-image-preview {
  width: 100%;
  height: 170px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  margin-bottom: 12px;
}

.edit-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.edit-image-preview .image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  color: var(--text-secondary);
  font-size: 34px;
}

.edit-image-preview .image-placeholder span {
  font-size: 13px;
  font-weight: 700;
}

.form-hint-row {
  display: flex;
  align-items: center;
  margin: 10px 0;
}

.form-hint-row input[type="checkbox"] { accent-color: var(--gold); }

.product-edit-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.product-card {
  position: relative;
  overflow: hidden;
}

.product-img-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.product-img-layer.placeholder {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 24px;
}

.product-card.has-image { min-height: 210px; }

.product-body {
  position: relative;
  z-index: 1;
  padding: 12px;
}

.product-card.has-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0.08) 100%);
  z-index: 1;
  pointer-events: none;
}

.product-card.has-image .product-body {
  z-index: 2;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.product-card.has-image .product-body h3,
.product-card.has-image .product-body .price-grid,
.product-card.has-image .product-body .price-grid strong {
  color: #fff;
}

.product-card.has-image .card-actions button {
  text-shadow: none;
  background: rgba(20, 20, 24, 0.6);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.product-card.has-image .card-actions button:last-child { color: #ffb4b4; }

.product-body h3 { margin: 0 0 6px; font-size: 15px; }
.product-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.product-meta span, .best-sellers span {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 10px 0;
  font-size: 11px;
}

.price-grid strong { display: block; margin-top: 3px; }

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.card-actions button {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: var(--surface);
  font-weight: 800;
  font-size: 12px;
}

.card-actions button:last-child { color: var(--danger); }

.pos-layout, .expense-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, .7fr);
  gap: 18px;
}

.pos-products {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.pos-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.pos-item img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}

.pos-item .pos-thumb.placeholder {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 22px;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-controls button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
}

.receipt-panel { align-self: start; }
.cart-list { display: grid; gap: 10px; margin: 18px 0; }
.cart-line, .receipt-row, .expense-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.full { width: 100%; margin-top: 16px; }
.receipt-note { color: var(--text-secondary); }
.receipt-footer { color: var(--text-secondary); text-align: center; margin-top: 12px; font-size: 0.85em; }

/* Promotions */
.promo-badge {
  display: inline-block;
  background: var(--gold);
  color: #1a1200;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  vertical-align: middle;
}
.promo-badge.bulk { background: #2f7d57; color: #fff; }
.promo-price { color: var(--gold); }
.promo-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 16px;
}
.promotions-list { display: grid; gap: 12px; }
.promotions-hint { margin: 0; }
.promo-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.promo-card-head strong { font-size: 15px; }
.promo-state {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 9px;
  border-radius: 999px;
}
.promo-state.active { background: #1f7a44; color: #fff; }
.promo-state.scheduled { background: #7a5a1f; color: #fff; }
.promo-state.expired { background: var(--surface-alt); color: var(--text-secondary); }
.promo-state.draft { background: var(--surface-alt); color: var(--text-secondary); }
.promo-state.inactive { background: #7a1f2b; color: #fff; }
.promo-desc { color: var(--text-secondary); margin: 8px 0 0; font-size: 13px; }
.promo-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--text-secondary);
  font-size: 13px;
  margin: 12px 0;
}
.promo-meta span { display: inline-flex; align-items: center; gap: 5px; }
.promo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.promo-actions .ghost-button.danger { color: #d9534f; border-color: #d9534f; }

.promotion-fields { display: grid; gap: 12px; margin-top: 14px; }
.form-field { display: grid; gap: 5px; font-size: 13px; color: var(--text-secondary); }
.form-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text);
}
.promo-date-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.promo-product-picker {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 4px;
  background: var(--surface-alt);
}
.promo-product-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 6px;
}
.promo-product-option:hover { background: var(--surface); }

/* Bulk discount */
.bulk-discount-wrap {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
}
.bulk-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.bulk-controls span { font-size: 12px; color: var(--text-secondary); }
.bulk-controls input {
  width: 70px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text);
}
.bulk-hint { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.toggle-line { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.inventory-list, .settings-grid, .report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 24px;
}

.report-grid + .report-grid {
  margin-top: 24px;
}

#reports .panel + .panel,
#reports .report-grid ~ .panel {
  margin-top: 24px;
}

.inventory-list { grid-template-columns: repeat(2, minmax(240px, 1fr)); align-items: start; }

.inventory-list .panel .inventory-items {
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.inventory-list .panel .inventory-items::-webkit-scrollbar { width: 5px; }
.inventory-list .panel .inventory-items::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.stock-warning { background: var(--stock-warning-bg); }
.stock-out { background: var(--stock-out-bg); }

.report-grid .panel strong {
  display: block;
  margin: 12px 0;
  font-size: 30px;
}

.financial-card .financial-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 0.5rem;
}

.financial-card .fin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.85rem;
}

.financial-card .fin-row strong {
  font-size: 0.9rem;
  margin: 0;
}

.financial-card .fin-divider {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}

.financial-card .fin-highlight strong {
  color: var(--success);
  font-size: 1rem;
}

.financial-card .report-note {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  padding: 1rem 0;
}

/* Seller performance analytics (dashboard) */
.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 4px 0 16px;
}
.section-title h3 { margin: 0; font-size: 18px; }
.section-title span { color: var(--muted); font-size: 0.82rem; }

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(200px, 1fr));
  gap: 18px;
}
.analytics-card h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}
.analytics-card .financial-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.analytics-card .fin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.85rem;
}
.analytics-card .fin-row strong { font-size: 0.9rem; margin: 0; }
.analytics-card .fin-divider {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.analytics-card .fin-highlight strong { color: var(--success); font-size: 1rem; }

/* Report generation wizard */
.modal-dialog.wizard-dialog {
  min-width: min(420px, 90vw);
  max-width: 500px;
  width: min(500px, 94vw);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-head h3 { margin: 0; font-size: 19px; }
.modal-head .reset-close { position: static; }

.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 20px;
  padding: 10px 12px;
  background: var(--gold-focus);
  border-radius: 10px;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.wizard-step i { font-size: 0.95rem; }
.wizard-step.active { color: var(--gold-dark); }

.wizard-panel { min-height: 0; }
.wizard-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.wizard-field span { font-size: 0.82rem; color: var(--text-secondary); font-weight: 600; }
.wizard-field select,
.wizard-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
.wizard-date-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.wizard-type-row,
.wizard-format-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.wizard-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.wizard-radio:hover { border-color: var(--gold); background: var(--gold-focus); }
.wizard-radio.selected {
  border-color: var(--gold);
  background: var(--gold-focus);
}
.wizard-radio i { font-size: 1.15rem; color: var(--gold); }
.wizard-radio span { font-size: 0.9rem; }

.wizard-categories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.wizard-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
.wizard-cat:hover { border-color: var(--gold); }
.wizard-cat.selected {
  border-color: var(--gold);
  background: var(--gold-focus);
}
.wizard-cat input { accent-color: var(--gold); }

@media (max-width: 900px) {
  .analytics-grid { grid-template-columns: repeat(2, minmax(200px, 1fr)); }
}
@media (max-width: 620px) {
  .analytics-grid { grid-template-columns: 1fr; }
  .wizard-categories { grid-template-columns: 1fr; }
  .wizard-date-row { grid-template-columns: 1fr; }
  .wizard-steps { padding: 8px 10px; gap: 6px; margin-bottom: 14px; }
  .wizard-step { font-size: 0.75rem; gap: 4px; }
  .wizard-field { margin-bottom: 10px; }
  .wizard-field select, .wizard-field input { padding: 9px 10px; font-size: 13px; }
  .wizard-radio { padding: 10px 12px; }
  .wizard-radio span { font-size: 0.85rem; }
  .wizard-type-row, .wizard-format-row { gap: 8px; margin-bottom: 10px; }
}

@media (max-width: 480px) {
  .modal-dialog.wizard-dialog { min-width: 0; padding: 14px; }
  .wizard-step span { display: none; }
  .wizard-step i { font-size: 1.1rem; }
  .section-title { flex-direction: column; gap: 4px; }
  .wizard-steps { padding: 6px 8px; margin-bottom: 12px; border-radius: 8px; }
  .wizard-field select, .wizard-field input { padding: 8px 10px; font-size: 13px; border-radius: 6px; }
  .wizard-radio { padding: 8px 10px; border-radius: 8px; gap: 8px; }
  .wizard-radio i { font-size: 1rem; }
  .wizard-radio span { font-size: 0.82rem; }
  .wizard-categories { gap: 6px; }
  .wizard-cat { padding: 6px 8px; font-size: 0.8rem; }
  .modal-actions { gap: 8px; }
  .modal-actions button { min-height: 38px; font-size: 13px; padding: 8px 14px; }
  .modal-head h3 { font-size: 16px; }
}
.financial-card h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.profit-card {
  border-left: 3px solid var(--success);
}

.expense-card {
  border-left: 3px solid var(--danger);
}

.line-chart {
  height: 210px;
  border-radius: 8px;
  background: var(--chart-line-bg);
  overflow: hidden;
}

.line-chart svg {
  width: 100%;
  height: 100%;
}

.line-chart polyline {
  fill: none;
  stroke: var(--gold-dark);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.best-sellers { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.expense-form {
  display: grid;
  gap: 14px;
}

.expense-date-amount {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.expense-date-amount > div {
  min-width: 0;
}

.expense-date-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.expense-date-wrap input {
  width: 100%;
  box-sizing: border-box;
}

.expense-date-wrap::before {
  content: "\f1e8";
  font-family: "bootstrap-icons";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 16px;
  pointer-events: none;
  transition: color .2s ease;
}

.expense-date-wrap:focus-within::before {
  color: var(--gold);
}

.settings-card {
  display: grid;
  gap: 12px;
}

.settings-card > label {
  color: var(--label-color);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: -4px;
  transition: color var(--theme-transition);
}

.toggle-line {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.toggle-line input {
  width: auto;
  accent-color: var(--gold);
}

.stock-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.stock-badge.warning { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.stock-badge.danger { background: var(--badge-danger-bg); color: var(--badge-danger-text); }

.settings-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}

.settings-actions .form-hint.success { color: var(--success); }

.report-output {
  white-space: pre-wrap;
  background: var(--surface-alt);
  padding: 16px;
  border-radius: 12px;
  font-size: 13px;
  max-height: 420px;
  overflow: auto;
  overflow-x: auto;
}

.report-note { color: var(--text-secondary); font-size: 14px; margin-top: 8px; }

.stock-alerts-panel { border-left: 4px solid var(--gold); }

.profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--white);
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--toast-text);
  box-shadow: 0 6px 20px var(--shadow-heavy);
  pointer-events: auto;
  animation: toastIn .3s ease forwards;
  max-width: 380px;
  word-break: break-word;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.toast.removing { animation: toastOut .25s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* Modal dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: var(--overlay);
  display: grid;
  place-items: center;
}

.modal-dialog {
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  min-width: 360px;
  max-width: 440px;
  box-shadow: 0 12px 40px var(--shadow-heavy);
}

.modal-dialog h3 { margin: 0 0 16px; }

.modal-quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-date-fields {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-date-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-date-fields input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Idle session warning modal */
.idle-dialog {
  text-align: center;
  max-width: 380px;
  animation: idleFadeIn 0.3s ease-out;
}
@keyframes idleFadeIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.idle-heading { font-size: 20px; }
.idle-message {
  margin: 8px 0 20px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}
.idle-timer-wrap {
  position: relative;
  width: 148px;
  height: 148px;
  margin: 0 auto 22px;
}
.idle-ring {
  width: 148px;
  height: 148px;
  transform: rotate(-90deg);
}
.idle-ring-track,
.idle-ring-progress {
  fill: none;
  stroke-width: 8;
}
.idle-ring-track {
  stroke: var(--border);
}
.idle-ring-progress {
  stroke: var(--gold);
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.5s ease;
}
.idle-ring-progress.danger {
  stroke: var(--danger);
}
.idle-timer-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.idle-timer-number {
  font-size: 44px;
  font-weight: 700;
  font-family: var(--font-heading);
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.idle-timer-label {
  margin-top: 5px;
  font-size: 13px;
  color: var(--text-secondary);
}
.idle-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.idle-actions .ghost-button,
.idle-actions .gold-button {
  flex: 1 1 150px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 14px;
}
.idle-logout-btn {
  color: var(--danger);
  border-color: var(--danger-border);
}
.idle-logout-btn:hover {
  color: var(--badge-danger-text);
  border-color: var(--danger);
  background: var(--badge-danger-bg);
}
@media (max-width: 400px) {
  .idle-timer-wrap {
    width: 120px;
    height: 120px;
  }
  .idle-ring {
    width: 120px;
    height: 120px;
  }
  .idle-timer-number { font-size: 34px; }
  .idle-actions .ghost-button,
  .idle-actions .gold-button {
    flex-basis: 100%;
  }
}

/* Reset password dialog */
.reset-dialog {
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 34px 28px;
  width: min(420px, 94vw);
  box-shadow: 0 24px 60px var(--shadow-heavy);
  position: relative;
  animation: resetFadeIn 0.25s ease-out;
}
@keyframes resetFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.reset-dialog h3 {
  margin: 0 0 6px;
  font-size: 24px;
}
.reset-dialog .reset-info {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 4px;
}
.reset-dialog form label {
  margin-top: 16px;
}
.reset-dialog form label:first-of-type {
  margin-top: 20px;
}
.reset-dialog form input {
  padding: 11px 14px;
}
.reset-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.reset-close:hover {
  color: var(--text);
  background: var(--hover-bg);
}
.reset-actions {
  display: flex;
  gap: 12px;
  margin-top: 26px;
}
.reset-actions .ghost-button,
.reset-actions .gold-button {
  flex: 1;
  text-align: center;
}

/* Report table */
.report-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.report-table caption {
  font-weight: 700;
  text-align: left;
  padding: 8px 0;
  font-size: 14px;
}

.report-table th, .report-table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.report-table th { background: var(--surface-alt); font-weight: 700; }
.report-table td { background: var(--surface); }

/* Search icon */
.search-icon-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text-secondary);
}

.search-icon-btn:hover { background: var(--surface-alt); color: var(--text); }

/* Product image placeholder */
.product-image-placeholder {
  width: 100%;
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  background: var(--placeholder-bg);
  color: var(--gold-dark);
  font-size: 42px;
  font-weight: 800;
}

.inventory-items {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
}

.inventory-items li + li { margin-top: 8px; }

.best-seller-row {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.best-seller-row strong { color: var(--text); }
.best-seller-row span { color: var(--text-secondary); font-size: 14px; }
.best-seller-row small { color: var(--gold-dark); }

.form-hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: background var(--theme-transition), color var(--theme-transition), border-color var(--theme-transition), transform .2s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--surface-alt);
  color: var(--gold);
  transform: rotate(15deg);
}

.theme-toggle:active {
  transform: scale(.92);
}

body.dark .topbar .theme-toggle {
  border-color: var(--border);
}

/* Sidebar overlay (mobile backdrop) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: var(--overlay);
  -webkit-tap-highlight-color: transparent;
}

/* Responsive tables wrapper */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Prevent body scroll when sidebar is open */
body.sidebar-open { overflow: hidden; }

/* Responsive modals */
.modal-dialog {
  width: min(440px, 94vw);
  min-width: 0;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-date-fields {
  flex-wrap: wrap;
}

.modal-date-fields label {
  flex: 1 1 140px;
  min-width: 0;
}

.modal-actions {
  flex-wrap: wrap;
}

.modal-actions button {
  flex: 1 1 120px;
}

/* Toast responsive */
.toast {
  max-width: min(380px, calc(100vw - 32px));
}

/* Splash / loading screen */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  background: var(--black);
  transition: opacity .4s ease, visibility .4s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  animation: splashPulse 1.5s ease-in-out infinite;
}

.splash-logo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--gold);
  padding: 4px;
  animation: splashSpin 2s linear infinite;
}

@keyframes splashSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.05); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes splashPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}

.splash-loader {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(201,162,78,.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: splashSpin .8s linear infinite;
}

.splash-text {
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
}

/* Login card entrance animation */
/* (duplicate .login-card / @keyframes loginCardIn removed – see line 245) */

/* App shell entrance animation */
.app-shell:not(.hidden) {
  animation: appFadeIn .4s ease forwards;
}

@keyframes appFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Health Check / Maintenance Screens */
.health-screen,
.maintenance-screen {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity .4s ease, visibility .4s ease;
}

.health-screen.hidden,
.maintenance-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.health-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 480px;
  padding: 32px;
}

.health-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.health-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 28px;
  line-height: 1.6;
}

.health-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(201,162,78,.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: splashSpin .8s linear infinite;
  margin-bottom: 28px;
}

.health-checks {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.health-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  text-align: left;
}

.health-check-item.pass {
  border-color: rgba(45,124,89,.3);
}

.health-check-item.fail {
  border-color: rgba(184,76,67,.3);
}

.health-check-item.warn {
  border-color: rgba(201,162,78,.3);
}

.health-check-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.health-check-item.pass .health-check-icon { color: var(--success); }
.health-check-item.fail .health-check-icon { color: var(--danger); }
.health-check-item.warn .health-check-icon { color: var(--gold); }

.health-check-label {
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.health-check-detail {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: auto;
}

.health-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
}

.maintenance-icon {
  font-size: 64px;
  color: var(--gold);
  margin: 24px 0;
  animation: splashPulse 2s ease-in-out infinite;
}

/* Nav item icons */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item i {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* Form input modern styling (Bootstrap-like) */
input, select, textarea {
  transition: border-color .2s ease, box-shadow .2s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-focus), 0 2px 8px rgba(201,162,78,.12);
}

.input-icon-wrap {
  position: relative;
  border-radius: 10px;
}

.input-icon-wrap > i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 16px;
  pointer-events: none;
  transition: color .2s ease;
}

.input-icon-wrap:focus-within > i {
  color: var(--gold);
}

.input-icon-wrap input,
.input-icon-wrap select {
  padding-left: 40px;
  border-radius: 10px;
}

/* Password toggle icon (bare icon inside input) */
.password-wrap {
  position: relative;
}
.password-wrap input {
  padding-right: 36px;
}
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  padding: 0;
  line-height: 1;
  border-radius: 0;
  transition: color .2s ease;
  z-index: 1;
}
.password-toggle:hover {
  color: var(--gold);
  background: none;
}
.password-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Button modern styling */
.gold-button, .ghost-button, .logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.gold-button:active, .ghost-button:active, .logout-button:active {
  transform: scale(.97);
}

.gold-button i, .ghost-button i, .logout-button i {
  font-size: 16px;
}

/* Search box modern */
.search-box {
  transition: border-color .2s ease;
}

/* Card actions modern */
.card-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
}

.card-actions button i {
  font-size: 14px;
}

/* Theme toggle modern */
.theme-toggle {
  transition: background .2s, color .2s, border-color .2s, transform .2s ease;
}

/* Toast modern */
.toast {
  border: none;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* ── Expense scroll card — hidden on desktop ──────────────── */
.ecl-mobile-card { display: none; }

/* ── Global mobile improvements ──────────────────────────── */
img, video { max-width: 100%; height: auto; }
.product-card img, .pos-item img { max-width: 100%; }
.table-wrap { -webkit-overflow-scrolling: touch; }
.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
input[type="date"] { min-height: 44px; }
select { min-height: 44px; -webkit-appearance: auto; appearance: auto; }

@media (max-width: 900px) {
  body { -webkit-text-size-adjust: 100%; }
  .workspace { overflow-x: hidden; }
  .login-art { padding: 36px; }
  .sidebar { padding: 10px 8px; }
  .side-nav { gap: 4px; }
}

@media (max-width: 1200px) {
  .stats-grid, .product-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 900px) {
  .login-screen, .app-shell, .dashboard-grid, .pos-layout, .expense-layout, .inventory-list, .settings-grid, .report-grid {
    grid-template-columns: 1fr;
  }

  .login-art { min-height: 360px; }

  .sidebar {
    position: fixed;
    z-index: 100;
    top: 0;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .menu-button { display: block; }
  .sidebar-logo { width: 120px; height: 120px; }

  .stats-grid, .stats-grid.compact, .pos-products { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .product-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }

  .pos-layout { grid-template-columns: 1fr; }
  .receipt-panel { order: -1; }
  .pos-cart-section { order: 0; }

  .expense-layout { grid-template-columns: 1fr; }
  .expense-layout > * { min-width: 0; }

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

  .inventory-list { grid-template-columns: repeat(2, minmax(200px, 1fr)); }
}

@media (max-width: 620px) {
  .page { padding: 12px 14px; padding-top: 120px; }
  .sidebar-logo { width: 96px; height: 96px; }

  /* ── Recent expenses: horizontal card scroll ──────────── */
  .expense-scroll-table .ecl-mobile-card { display: none; }

  .expense-scroll-table {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .expense-scroll-table::-webkit-scrollbar { height: 4px; }
  .expense-scroll-table::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  .expense-scroll-table thead { display: none; }

  .expense-scroll-table tbody { display: contents; }
  .expense-scroll-table tr { display: contents; }
  .expense-scroll-table .ecl-desktop { display: none; }

  .expense-scroll-table .ecl-mobile-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 170px;
    max-width: 200px;
    flex-shrink: 0;
    padding: 10px 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    scroll-snap-align: start;
    font-size: 12px;
    line-height: 1.4;
  }

  .expense-scroll-table .ecl-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
  }

  .expense-scroll-table .ecl-value {
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
    margin-bottom: 2px;
  }

  .expense-scroll-table .ecl-amount {
    font-size: 15px;
    font-weight: 800;
    color: var(--gold);
    margin-bottom: 2px;
  }

  .expense-scroll-table .ecl-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
  }

  .expense-scroll-table .ecl-actions button {
    padding: 4px 8px;
    font-size: 10px;
    min-height: 32px;
  }

  .expense-scroll-table .ecl-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100%;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 13px;
  }

  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 12px;
    gap: 0;
    flex-wrap: wrap;
    z-index: 99;
  }

  /* ── Row 1: hamburger ... spacer ... avatar ──────── */

  .menu-button {
    order: 0;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    margin-right: 8px;
  }

  /* Push avatar to far right */
  .topbar-right {
    order: 2;
    margin-left: auto;
    gap: 8px;
  }

  /* ── Row 2: search | lang | theme ──────────────── */
  .topbar-center {
    order: 3;
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  .topbar-search { flex: 1; max-width: none; }

  .language-switcher {
    min-width: 0;
    width: auto;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
  }

  .theme-toggle {
    min-width: 36px;
    width: 36px;
    height: 36px;
    font-size: 16px;
    flex-shrink: 0;
  }

  /* ── Hide bulky elements on mobile ─────────────────────── */
  .topbar-clock { display: none; }
  .topbar-status { display: none; }
  .topbar-user-info { display: none; }
  .topbar-chevron { display: none; }

  /* Avatar: bigger tap target, no extra labels */
  .profile-avatar {
    width: 40px;
    height: 40px;
    font-size: 13px;
    cursor: pointer;
  }

  .topbar-user {
    padding: 2px;
    border-radius: 50%;
  }
  .topbar-user:hover { background: var(--hover-bg); }

  /* Dropdown: slides below avatar on mobile */
  .user-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: auto;
    width: 220px;
    min-width: 0;
    border-radius: 12px;
    box-shadow: 0 8px 30px var(--shadow-heavy);
    padding: 6px;
    animation: dropdownIn .15s ease;
  }

  .dropdown-item {
    padding: 12px 14px;
    font-size: 14px;
    border-radius: 8px;
    min-height: 44px;
  }

  .dropdown-divider { margin: 4px 8px; }

  /* ── Page content ──────────────────────────────────────── */
  .page-heading { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-heading h2 { font-size: 22px; }

  .stats-grid, .stats-grid.compact, .pos-products, .toolbar, .product-form { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .promo-date-row { grid-template-columns: 1fr; }

  .pos-item { grid-template-columns: 60px 1fr; }
  .pos-item img, .pos-item .pos-thumb.placeholder { width: 60px; height: 60px; }
  .qty-controls { grid-column: 1 / -1; justify-content: flex-end; }

  .ghost-button, .logout-button, .card-actions button, .gold-button {
    min-height: 44px;
    padding: 10px 14px;
  }

  .qty-controls button { width: 40px; height: 40px; }

  .reset-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
  }

  .nav-item { min-height: 48px; padding: 14px 16px; }

  .login-card { padding: 28px; border-radius: 14px; }
  .login-card h2 { font-size: 22px; margin-top: 20px; }
  .login-card button { min-height: 48px; font-size: 15px; }

  .settings-card > label { font-size: 14px; }

  .expense-form, .settings-card { gap: 0; }
  .expense-form label, .settings-card label { gap: 0; }

  .expense-form input,
  .expense-form select {
    width: 100%;
    height: 46px;
    min-height: 46px;
    max-height: 46px;
    box-sizing: border-box;
    padding: 0 14px;
    margin: 6px 0;
    border-radius: 10px;
  }

  .expense-date-amount {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .expense-date-amount > div {
    width: 100%;
  }

  .expense-date-wrap {
    position: relative;
    width: 60%;
    margin: 0 auto;
  }

  .expense-date-wrap input {
    width: 100%;
    height: 46px;
    box-sizing: border-box;
    text-align: center;
  }

  .expense-form .gold-button.full {
    margin-top: 12px;
    min-height: 46px;
  }

  .expense-layout > .panel { overflow: hidden; }

  .report-grid .panel strong { font-size: 24px; }

  .stat-card strong { font-size: 22px; }

  .chart-bar { min-height: 180px; }
  .bar-chart { min-height: 220px; }
  .line-chart { height: 180px; }

  .modal-dialog { padding: 20px; min-width: 0; width: min(420px, 92vw); }
  .modal-dialog h3 { font-size: 18px; }

  .reset-dialog { padding: 24px 20px 20px; width: min(400px, 92vw); }
  .reset-dialog h3 { font-size: 18px; }

  .pos-layout { gap: 14px; }
  .pos-products { gap: 10px; }

  .best-sellers { gap: 8px; }

  .stock-alerts-panel ul { padding-left: 16px; }

  .inventory-list { grid-template-columns: 1fr; }

  .settings-grid { grid-template-columns: 1fr; }

  .report-grid { grid-template-columns: 1fr; }

  .toast { max-width: calc(100vw - 32px); }

  input, select { font-size: 16px; }

  .product-body h3 { font-size: 16px; }

  .price-grid { font-size: 12px; }

  .cart-line, .receipt-row, .expense-row { gap: 8px; padding: 10px 0; }
}

@media (max-width: 480px) {
  .login-art { display: none; }
  .login-panel {
    padding: 24px 16px;
    background: var(--surface);
    min-height: 100vh;
    min-height: 100dvh;
  }
  .login-panel::before { display: none; }
  .login-shop-name { display: block; }
  .login-card { padding: 24px 20px; border-radius: 12px; width: 100%; }
  .login-card h2 { font-size: 20px; }

  .expense-form input,
  .expense-form select {
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    margin: 8px 0;
  }

  .expense-date-wrap input {
    height: 44px;
  }

  .product-card.has-image { min-height: 190px; }
  .product-edit-fields { grid-template-columns: 1fr; }

  /* Topbar row 1: even tighter */
  .topbar { padding: 8px 10px; gap: 0; }

  .menu-button { min-width: 36px; height: 36px; padding: 0 8px; margin-right: 6px; }
  .menu-button .hamburger-icon { font-size: 20px; }

  /* Topbar row 2: compact */
  .topbar-center { gap: 6px; margin-top: 6px; padding-top: 6px; }

  .profile-avatar { width: 36px; height: 36px; font-size: 12px; }

  .language-switcher { padding: 5px 6px; font-size: 11px; }
  .theme-toggle { min-width: 32px; width: 32px; height: 32px; font-size: 14px; }

  .page { padding: 14px; padding-top: 110px; }
  .page-heading h2 { font-size: 20px; }

  .stat-card { padding: 14px; }
  .stat-card strong { font-size: 20px; }
  .stat-card span { font-size: 12px; }

  .product-card .product-body { padding: 12px; }
  .product-body h3 { font-size: 15px; }

  .price-grid { font-size: 11px; }

  .pos-item { padding: 8px; gap: 8px; }
  .pos-item img, .pos-item .pos-thumb.placeholder { width: 56px; height: 56px; }

  .toast { padding: 12px 14px; font-size: 13px; }

  .settings-card > label { font-size: 13px; }

  .modal-dialog { padding: 16px; width: min(380px, 94vw); border-radius: 12px; max-width: 94vw !important; }
  .modal-dialog h3 { font-size: 17px; }

  .reset-dialog { padding: 20px 16px 16px; border-radius: 12px; max-width: 96vw !important; }
  .reset-dialog h3 { font-size: 17px; }

  .chart-bar { min-height: 160px; }
  .bar-chart { min-height: 200px; }
  .line-chart { height: 160px; }

  .report-grid .panel strong { font-size: 20px; }

  .cart-line, .receipt-row, .expense-row { font-size: 13px; }

  .financial-card .fin-row { font-size: 0.8rem; }

  .sidebar { width: min(280px, 85vw); }
}

@media (max-width: 360px) {
  .topbar { padding: 6px 8px; gap: 0; }

  .menu-button { min-width: 32px; height: 32px; padding: 0 6px; margin-right: 4px; }
  .menu-button .hamburger-icon { font-size: 18px; }

  .topbar-center { gap: 4px; margin-top: 4px; padding-top: 4px; }

  .profile-avatar { width: 32px; height: 32px; font-size: 11px; }

  .language-switcher { padding: 4px 5px; font-size: 10px; }
  .theme-toggle { min-width: 28px; width: 28px; height: 28px; font-size: 13px; }

  .page { padding: 10px; padding-top: 100px; }
  .page-heading h2 { font-size: 18px; }

  .stat-card strong { font-size: 18px; }

  .login-card { padding: 18px 16px; border-radius: 10px; }
  .login-card h2 { font-size: 18px; margin-top: 16px; }
  .login-card button { min-height: 44px; font-size: 14px; }

  .sidebar { width: min(260px, 82vw); }

  .stats-grid { gap: 10px; }
  .stat-card { padding: 12px; }

  .product-grid { gap: 10px; }

  .pos-item { padding: 6px; gap: 6px; }
  .pos-item img, .pos-item .pos-thumb.placeholder { width: 50px; height: 50px; }

  .modal-dialog { padding: 14px; width: min(340px, 96vw); max-width: 96vw !important; }
  .reset-dialog { padding: 18px 14px 14px; width: min(340px, 96vw); }

  .qty-controls button { width: 36px; height: 36px; }

  .toast { max-width: calc(100vw - 20px); font-size: 12px; padding: 10px 12px; }
}

/* ── Sale Details / Receipt Modal ──────────────────────────────────── */
.sale-details-dialog {
  width: min(520px, 94vw);
  max-width: 520px;
  padding: 0;
  overflow: hidden;
}

.sale-details-dialog .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.sale-details-dialog .modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.sale-details-dialog .reset-close {
  position: static;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.sale-details-dialog .reset-close:hover {
  color: var(--text);
  background: var(--surface-alt);
}

#saleDetailsContent {
  padding: 16px 20px 20px;
  max-height: 65vh;
  overflow-y: auto;
}

.sale-details-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.sale-details-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: saleSpin 0.8s linear infinite;
}

@keyframes saleSpin {
  to { transform: rotate(360deg); }
}

.sale-details-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--danger, #e74c3c);
  font-size: 14px;
  text-align: center;
}

.sale-details-error i {
  font-size: 36px;
}

/* ── Professional Receipt Layout ────────────────────────────────────── */
.receipt-brand {
  text-align: center;
  margin-bottom: 12px;
}

.receipt-logo {
  max-width: 80px;
  max-height: 80px;
  margin-bottom: 8px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.receipt-store-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  color: var(--text);
}

.receipt-contact {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 2px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.receipt-contact i {
  font-size: 11px;
}

.receipt-divider {
  border-top: 1px dashed var(--border);
  margin: 10px 0;
}

.receipt-divider-thick {
  border-top: 2px solid var(--text);
  margin: 12px 0;
}

.receipt-header-info {
  margin-bottom: 8px;
}

.receipt-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 13px;
}

.receipt-meta-label {
  color: var(--text-secondary);
}

.receipt-meta-value {
  font-weight: 600;
  text-align: right;
  color: var(--text);
}

.receipt-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0;
}

.receipt-items-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}

.receipt-items-table thead th.receipt-col-center {
  text-align: center;
}

.receipt-items-table thead th.receipt-col-right {
  text-align: right;
}

.receipt-items-table tbody td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--surface-alt);
  vertical-align: top;
  color: var(--text);
}

.receipt-items-table td.receipt-col-center {
  text-align: center;
}

.receipt-items-table td.receipt-col-right {
  text-align: right;
}

.receipt-items-table td.receipt-col-total {
  font-weight: 600;
}

.receipt-item-variant {
  color: var(--text-secondary);
  font-size: 11px;
}

.receipt-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 16px 4px;
}

.receipt-summary {
  margin: 8px 0;
}

.receipt-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.receipt-summary-row span:last-child {
  font-weight: 500;
  color: var(--text);
}

.receipt-summary-discount span:last-child {
  color: var(--danger, #e74c3c);
}

.receipt-summary-total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}

.receipt-summary-total span {
  font-weight: 700;
  font-size: 16px !important;
  color: var(--text) !important;
}

.receipt-payment-info {
  margin: 8px 0;
  font-size: 13px;
}

.receipt-profit-info {
  margin: 8px 0;
  font-size: 13px;
}

.receipt-profit-value {
  color: var(--accent-green, #27ae60);
  font-weight: 600;
}

.receipt-footer-area {
  text-align: center;
  margin-top: 12px;
}

.receipt-footer-message {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-style: italic;
}

.receipt-thankyou {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.receipt-powered {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.6;
}

/* ── Receipt Action Buttons ─────────────────────────────────────────── */
.sale-details-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sale-details-footer .ghost-button {
  padding: 8px 20px;
}

.receipt-actions {
  display: flex;
  gap: 8px;
}

.receipt-action-btn i {
  margin-right: 4px;
}

/* ── Print Styles ───────────────────────────────────────────────────── */
@media print {
  body * {
    visibility: hidden !important;
  }

  .receipt-print-area,
  .receipt-print-area * {
    visibility: visible !important;
  }

  .receipt-print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    max-width: 80mm;
    margin: 0 auto;
    padding: 4mm;
    background: #fff;
    color: #000;
  }

  .receipt-logo {
    max-width: 60px;
    max-height: 60px;
  }

  .receipt-store-name {
    font-size: 16px;
    color: #000;
  }

  .receipt-contact {
    color: #333;
  }

  .receipt-divider {
    border-color: #ccc;
  }

  .receipt-divider-thick {
    border-color: #000;
  }

  .receipt-meta-label {
    color: #555;
  }

  .receipt-meta-value {
    color: #000;
  }

  .receipt-items-table thead th {
    color: #555;
    border-bottom-color: #ccc;
  }

  .receipt-items-table tbody td {
    color: #000;
    border-bottom-color: #eee;
  }

  .receipt-summary-row {
    color: #555;
  }

  .receipt-summary-row span:last-child {
    color: #000;
  }

  .receipt-summary-total span {
    color: #000 !important;
  }

  .receipt-footer-message {
    color: #555;
  }

  .receipt-thankyou {
    color: #000;
  }

  .receipt-powered {
    color: #999;
  }
}

/* ── Sale details modal responsive ──────────────────────────────────── */
@media (max-width: 640px) {
  .sale-details-dialog {
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    border-radius: 0;
    max-height: 100vh;
    max-height: 100dvh;
    align-self: center;
  }

  .sale-details-dialog .modal-head {
    padding: 10px 14px;
  }

  .sale-details-dialog .modal-head h3 {
    font-size: 15px;
  }

  #saleDetailsContent {
    padding: 10px 14px;
    max-height: calc(100vh - 52px);
    max-height: calc(100dvh - 52px);
  }

  .receipt-store-name {
    font-size: 18px;
  }

  .receipt-contact {
    font-size: 11px;
  }

  .receipt-meta-row {
    font-size: 12px;
  }

  .receipt-items-table {
    font-size: 12px;
  }

  .receipt-items-table thead th {
    font-size: 10px;
    padding: 5px 3px;
  }

  .receipt-items-table tbody td {
    padding: 5px 3px;
  }

  .receipt-summary-row {
    font-size: 12px;
  }

  .receipt-summary-total span {
    font-size: 14px;
  }

  .sale-details-footer {
    margin-top: 8px;
    padding-top: 8px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .sale-details-footer .ghost-button {
    min-height: 36px;
    padding: 6px 16px;
    font-size: 13px;
  }

  .receipt-action-btn {
    min-height: 36px;
    padding: 6px 14px !important;
    font-size: 13px;
  }
}

@media (max-width: 520px) {
  #saleDetailsContent {
    padding: 8px 10px;
  }

  .receipt-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 420px) {
  .receipt-store-name {
    font-size: 16px;
  }

  .receipt-contact {
    font-size: 10px;
  }

  .receipt-meta-row {
    font-size: 11px;
  }

  .receipt-items-table {
    font-size: 11px;
  }

  .receipt-items-table thead th {
    font-size: 9px;
    padding: 4px 2px;
  }

  .receipt-items-table tbody td {
    padding: 4px 2px;
    font-size: 11px;
  }

  .receipt-summary-row {
    font-size: 11px;
    padding: 3px 0;
  }

  .receipt-summary-total span {
    font-size: 13px;
  }

  .receipt-thankyou {
    font-size: 13px;
  }

  .sale-details-footer .ghost-button {
    min-height: 34px;
    padding: 5px 12px;
    font-size: 12px;
  }
}

@media (max-width: 360px) {
  .receipt-items-table {
    font-size: 10px;
  }

  .receipt-items-table thead th {
    font-size: 8px;
    padding: 3px 2px;
  }

  .receipt-items-table tbody td {
    font-size: 10px;
    padding: 3px 2px;
  }

  .receipt-meta-row {
    font-size: 10px;
  }

  .receipt-summary-row {
    font-size: 10px;
    padding: 2px 0;
  }

  .receipt-summary-total span {
    font-size: 12px;
  }
}

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

/* --- Audit Log Page ---------------------------------------------------- */
.audit-filters { padding: 16px; }
.audit-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.audit-filter-field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.audit-filter-field select,
.audit-filter-field input[type="date"] { width: 100%; }
.audit-search { min-width: 220px; }
.audit-filter-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.audit-table th, .audit-table td { white-space: nowrap; }
.audit-desc-cell { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audit-table .nowrap { white-space: nowrap; }

.audit-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.pagination-info { font-size: 13px; color: var(--text-secondary); }
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.pagination-page { font-size: 13px; color: var(--text-secondary); padding: 0 4px; }

/* Detail dialog */
.audit-detail-dialog {
  width: min(680px, calc(100vw - 24px));
  max-width: 680px;
  min-width: 0;
  border-radius: 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  box-shadow: 0 12px 40px var(--shadow-heavy);
}

.audit-detail-dialog .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.audit-detail-dialog .modal-head h3 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.audit-detail-dialog .reset-close {
  position: static;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.audit-detail-dialog .reset-close:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.audit-detail-dialog .modal-actions {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.audit-detail-dialog .audit-detail-body {
  padding: 16px 20px 4px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.audit-detail-section { margin-bottom: 18px; }
.audit-detail-section:last-child { margin-bottom: 4px; }

.audit-section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.audit-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 16px;
  margin-bottom: 12px;
}
.audit-detail-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.audit-detail-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); }
.audit-detail-value { font-size: 14px; color: var(--text); word-break: break-word; overflow-wrap: anywhere; min-width: 0; }
.audit-na { color: var(--muted); font-style: italic; }
.audit-detail-desc { margin-bottom: 12px; }
.audit-detail-desc .audit-detail-value { margin-top: 4px; background: var(--surface-alt); padding: 8px 10px; border-radius: 8px; }

.audit-detail-ua {
  margin-top: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.audit-no-changes { font-size: 13px; color: var(--text-secondary); padding: 4px 0; }

/* Loading / error states inside the modal */
.audit-detail-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 0;
  font-size: 14px;
  color: var(--text-secondary);
}
.audit-detail-state-error { color: var(--danger); }
.audit-detail-state-error i { font-size: 16px; }
.audit-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: audit-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes audit-spin { to { transform: rotate(360deg); } }

/* Old → New changes table */
.audit-change-table-wrap { overflow-x: auto; margin: 0 -2px; }
.audit-change-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 420px;
}
.audit-change-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.audit-change-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.audit-change-table tbody tr:last-child td { border-bottom: none; }
.audit-change-key-cell { color: var(--text-secondary); white-space: nowrap; width: 1%; }
.audit-before { color: var(--danger); text-decoration: line-through; }
.audit-after { color: var(--success); font-weight: 600; }
.audit-empty { color: var(--muted); font-weight: 400; text-decoration: none; }
.audit-val-json pre {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* Dark mode */
body.dark .audit-detail-value { color: var(--text); }
body.dark .audit-detail-ua { background: var(--surface); color: var(--text-secondary); }
body.dark .audit-val-json pre { background: var(--surface); }

/* Responsive: small screens */
@media (max-width: 900px) {
  .audit-filter-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .audit-detail-dialog {
    width: min(680px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    max-height: calc(100vh - 16px);
  }
  .audit-detail-dialog .modal-head { padding: 10px 14px; }
  .audit-detail-dialog .modal-head h3 { font-size: 16px; }
  .audit-detail-dialog .modal-actions { padding: 10px 14px; }
  .audit-detail-dialog .audit-detail-body { padding: 12px 14px 4px; }
}
@media (max-width: 560px) {
  .audit-filter-grid { grid-template-columns: 1fr; }
  .audit-table { min-width: 720px; }
  .audit-table-wrap { overflow-x: auto; }
  .audit-pagination { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 400px) {
  .audit-detail-dialog {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    border-radius: 12px;
  }
  .audit-detail-grid { grid-template-columns: 1fr; }
  .audit-change-table { min-width: 360px; }
  .audit-val-json pre { font-size: 11px; }
}

/* --- Backup Management Page ---------------------------------------------- */
.backup-heading-actions { display: flex; gap: 10px; }

.backup-status-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.backup-actions-panel { margin-bottom: 18px; }
.backup-action-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.backup-action-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body.dark .backup-action-card { background: var(--surface-alt); }
.backup-action-icon { font-size: 30px; color: var(--gold); }
.backup-action-icon.file { color: var(--success); }
.backup-action-icon.full { color: var(--danger); }
.backup-action-card h4 { margin: 0; font-size: 16px; color: var(--text); }
.backup-action-card p { margin: 0 0 8px; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.backup-action-card .gold-button { justify-content: center; margin-top: auto; }

.backup-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}
.retention-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.retention-field { display: flex; flex-direction: column; gap: 4px; }
.retention-field span { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.retention-field input { width: 100%; }
.retention-actions { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.backup-storage-info { margin-top: 14px; }
.backup-storage-info .form-hint { margin: 0; }

.storage-detail { display: flex; flex-direction: column; gap: 10px; }
.storage-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.storage-row:last-child { border-bottom: none; }
.storage-row > span { color: var(--text-secondary); }
.storage-value { color: var(--text); font-weight: 600; text-align: right; word-break: break-word; }

.backup-history-panel { margin-top: 0; }
.backup-table th, .backup-table td { white-space: nowrap; }
.backup-filename-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-body); font-size: 13px; }
.backup-actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.backup-actions-cell .ghost-button { padding: 4px 8px; min-height: 32px; font-size: 12px; }

.backup-type-badge,
.backup-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.backup-type-badge.type-database { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.backup-type-badge.type-files { background: var(--success-bg); color: var(--success); }
.backup-type-badge.type-full { background: var(--badge-danger-bg); color: var(--badge-danger-text); }
body.dark .backup-type-badge.type-database { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
body.dark .backup-type-badge.type-files { background: rgba(45,124,89,.25); color: var(--success); }
body.dark .backup-type-badge.type-full { background: var(--badge-danger-bg); color: var(--badge-danger-text); }

.backup-status-badge.status-success { background: var(--success-bg); color: var(--success); }
.backup-status-badge.status-failed { background: var(--badge-danger-bg); color: var(--badge-danger-text); }

/* Backup detail / modals */
.backup-detail-dialog { max-width: 640px; width: 100%; }
.backup-detail-name { font-family: var(--font-body); word-break: break-all; }
.backup-detail-note {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Restore modal */
.restore-dialog { max-width: 560px; width: 100%; }
.restore-warning {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--badge-danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: 10px;
}
.restore-warning-icon { font-size: 28px; color: var(--danger); flex-shrink: 0; }
.restore-warning strong { color: var(--badge-danger-text); font-size: 14px; line-height: 1.4; }
.restore-warning-text { margin: 6px 0 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

.restore-details {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.restore-detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }
.restore-detail-row span { color: var(--text-secondary); }
.restore-detail-row strong { color: var(--text); word-break: break-all; text-align: right; }

.restore-confirm-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text); cursor: pointer; }
.restore-confirm-check input { margin-top: 2px; }
.restore-confirm-check span { line-height: 1.5; }

.danger-button {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-heading);
  cursor: pointer;
  transition: background .2s ease, transform .1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.danger-button:hover:not(:disabled) { background: #9f3d36; }
.danger-button:disabled { opacity: .5; cursor: not-allowed; }
.danger-button.btn-loading { opacity: .6; cursor: progress; }

/* Responsive backups */
@media (max-width: 900px) {
  .backup-layout { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .backup-action-row { grid-template-columns: 1fr; }
  .retention-form { grid-template-columns: 1fr 1fr; }
  .backup-table { min-width: 720px; }
  .backup-table-wrap { overflow-x: auto; }
  .backup-status-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
@media (max-width: 480px) {
  .retention-form { grid-template-columns: 1fr; }
  .backup-heading-actions { flex-direction: column; align-items: stretch; }
  .backup-action-card { padding: 16px; }
  .restore-warning { flex-direction: column; }
}

/* ════════════════════════════════════════════════════════════════════════════
   BUSINESS INTELLIGENCE — Phase 2
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Date Filter Bar ───────────────────────────────────────────────────── */
.bi-date-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
}
.bi-date-filter label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}
.bi-period-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.bi-period-btn:hover { background: var(--hover-bg); color: var(--text); border-color: var(--gold-border); }
.bi-period-btn.active { background: var(--gold); color: #fff; border-color: var(--gold); }
.bi-custom-range {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: 4px;
}
.bi-custom-range input[type="date"] {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
}
.bi-custom-range .ghost-button {
  padding: 5px 12px;
  font-size: 12px;
}

/* ── BI Tab Navigation ─────────────────────────────────────────────────── */
.bi-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.bi-tabs::-webkit-scrollbar { display: none; }
.bi-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s ease;
}
.bi-tab:hover { color: var(--text); background: var(--hover-bg); }
.bi-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ── BI KPI Grid ───────────────────────────────────────────────────────── */
.bi-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.bi-kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .15s ease;
}
.bi-kpi-card:hover { border-color: var(--gold-border); }
.bi-kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.bi-kpi-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--text);
  word-break: break-word;
}
.bi-kpi-value.gold { color: var(--gold); }
.bi-kpi-value.success { color: var(--success); }
.bi-kpi-value.danger { color: var(--danger); }
.bi-kpi-sub {
  font-size: 12px;
  color: var(--text-secondary);
}
.bi-kpi-sub.positive { color: var(--success); font-weight: 600; }
.bi-kpi-sub.negative { color: var(--danger); font-weight: 600; }
.bi-kpi-sub.no-change { color: var(--text-secondary); }

/* ── Comparison Indicators ─────────────────────────────────────────────── */
.bi-compare {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}
.bi-compare.up { color: var(--success); background: var(--success-bg); }
.bi-compare.down { color: var(--danger); background: var(--badge-danger-bg); }
.bi-compare.same { color: var(--text-secondary); background: var(--surface-alt); }
.bi-compare i { font-size: 11px; }

/* ── BI Chart Containers ───────────────────────────────────────────────── */
.bi-chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
}
.bi-chart-panel .panel-title { margin-bottom: 16px; }
.bi-chart-canvas {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.bi-chart-canvas svg { width: 100%; height: auto; }
.bi-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.bi-chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bi-chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── BI Tables ─────────────────────────────────────────────────────────── */
.bi-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
}
.bi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bi-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .3px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: var(--surface-alt);
  position: sticky;
  top: 0;
}
.bi-table th.align-right, .bi-table td.align-right { text-align: right; }
.bi-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.bi-table tr:hover td { background: var(--hover-bg); }
.bi-table .rank-cell {
  font-weight: 700;
  color: var(--gold);
  width: 40px;
}
.bi-table .rank-1 { font-size: 16px; }
.bi-table .product-name-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.bi-table .seller-name-cell { font-weight: 600; }
.bi-table .margin-good { color: var(--success); }
.bi-table .margin-bad { color: var(--danger); }
.bi-table .margin-neutral { color: var(--text-secondary); }
.bi-table .stock-badge-sm {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.bi-table .stock-badge-sm.out { background: var(--badge-danger-bg); color: var(--badge-danger-text); }
.bi-table .stock-badge-sm.low { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.bi-table .stock-badge-sm.in { background: var(--success-bg); color: var(--success); }

/* ── Insight Cards ─────────────────────────────────────────────────────── */
.bi-insights {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}
.bi-insight {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.bi-insight.positive { background: var(--success-bg); border-left: 3px solid var(--success); }
.bi-insight.negative { background: var(--badge-danger-bg); border-left: 3px solid var(--danger); }
.bi-insight.warning { background: var(--badge-warning-bg); border-left: 3px solid var(--gold); }
.bi-insight.info { background: var(--hover-bg); border-left: 3px solid var(--gold); }
.bi-insight-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.bi-insight.positive .bi-insight-icon { color: var(--success); }
.bi-insight.negative .bi-insight-icon { color: var(--danger); }
.bi-insight.warning .bi-insight-icon { color: var(--gold); }
.bi-insight.info .bi-insight-icon { color: var(--gold); }

/* ── Expense Impact Flow ───────────────────────────────────────────────── */
.bi-expense-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.bi-flow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.bi-flow-card .flow-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.bi-flow-card .flow-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-heading);
}
.bi-flow-card .flow-arrow {
  font-size: 18px;
  color: var(--gold);
  margin: 4px 0;
}
.bi-flow-card.flow-revenue .flow-value { color: var(--text); }
.bi-flow-card.flow-gross .flow-value { color: var(--gold); }
.bi-flow-card.flow-expense .flow-value { color: var(--danger); }
.bi-flow-card.flow-net .flow-value { color: var(--success); }

/* ── BI Section Grids ──────────────────────────────────────────────────── */
.bi-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.bi-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }

/* ── Sort Controls ─────────────────────────────────────────────────────── */
.bi-sort-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.bi-sort-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.bi-sort-btn:hover { border-color: var(--gold-border); color: var(--text); }
.bi-sort-btn.active { background: var(--gold); color: #fff; border-color: var(--gold); }

/* ── Sub-sections ──────────────────────────────────────────────────────── */
.bi-subsection { margin-bottom: 18px; }
.bi-subsection-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Empty States ──────────────────────────────────────────────────────── */
.bi-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.bi-empty-state i {
  font-size: 48px;
  color: var(--gold);
  opacity: .5;
  margin-bottom: 12px;
  display: block;
}
.bi-empty-state p {
  font-size: 14px;
  margin: 0;
}

/* ── Loading Spinner ───────────────────────────────────────────────────── */
.bi-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.bi-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: bi-spin .8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes bi-spin { to { transform: rotate(360deg); } }

/* ── Seller Comparison Select ──────────────────────────────────────────── */
.bi-seller-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
}

/* ── Product Category Badges ───────────────────────────────────────────── */
.bi-category-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}
.bi-category-badge.best-seller { background: var(--success-bg); color: var(--success); }
.bi-category-badge.most-profitable { background: var(--gold-focus); color: var(--gold-dark); }
.bi-category-badge.high-rev-low { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.bi-category-badge.slow-moving { background: var(--surface-alt); color: var(--text-secondary); }

/* ── Responsive BI ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .bi-kpi-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .bi-grid-2, .bi-grid-3 { grid-template-columns: 1fr; }
  .bi-expense-flow { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .bi-date-filter { gap: 6px; padding: 10px 12px; }
  .bi-period-btn { padding: 5px 10px; font-size: 12px; }
  .bi-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .bi-kpi-card { padding: 12px 14px; }
  .bi-kpi-value { font-size: 18px; }
  .bi-tab { padding: 8px 14px; font-size: 13px; }
  .bi-expense-flow { grid-template-columns: 1fr 1fr; }
  .bi-flow-card .flow-value { font-size: 16px; }
}
@media (max-width: 480px) {
  .bi-kpi-grid { grid-template-columns: 1fr 1fr; }
  .bi-custom-range { flex-wrap: wrap; }
  .bi-sort-bar { overflow-x: auto; flex-wrap: nowrap; }
}

/* -- amCharts 5 Integration ----------------------------------------------- */

/* -- amCharts 5 Integration ----------------------------------------------- */

/* Chart containers need an explicit height for amCharts to size the Root. */
.revenue-chart,
.profit-chart {
  position: relative;
  width: 100%;
  height: 340px;
  background: var(--chart-bg);
  border-radius: 8px;
  overflow: hidden;
}
.bi-chart-canvas {
  position: relative;
}
.bi-chart-canvas .amcharts-chart {
  width: 100%;
  height: 400px;
}

/* Dashboard bar-chart grid should no longer force 7 columns for amCharts. */
.bar-chart.revenue-chart,
.bar-chart.profit-chart {
  display: block;
  padding: 12px;
}

/* -- AmCharts child sizing (svg is width/height driven by am5) ----------- */
.revenue-chart > div,
.profit-chart > div,
.bi-chart-canvas > div {
  width: 100%;
  height: 100%;
}

/* -- Shared loading / empty / error states ------------------------------- */
.am-chart-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  min-height: 220px;
  text-align: center;
  color: var(--text-secondary);
  background: var(--chart-bg);
  border-radius: 8px;
  padding: 24px 16px;
  box-sizing: border-box;
}
.am-chart-state i {
  font-size: 34px;
  color: var(--gold);
  opacity: .5;
}
.am-chart-state p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  max-width: 320px;
}
.am-chart-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: bi-spin .8s linear infinite;
}
.am-chart-error i { color: var(--danger); }
.am-chart-error p { color: var(--danger); }

/* -- BI View Switcher ---------------------------------------------------- */
.bi-view-switcher {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
}
.bi-view-btn {
  padding: 10px 22px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-heading);
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}
.bi-view-btn:hover { color: var(--text); }
.bi-view-btn.active {
  background: var(--gold);
  color: #fff;
  box-shadow: 0 2px 8px var(--gold-shadow);
}
.bi-view-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Smooth view transition */
.bi-view-panel {
  animation: biViewIn .28s ease;
}
@keyframes biViewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.bi-view-panel.hidden { display: none; }

/* Two-col trend layout for View 1 */
.bi-trend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 900px) {
  .bi-trend-grid { grid-template-columns: 1fr; }
  .bi-chart-canvas .amcharts-chart { height: 360px; }
  .revenue-chart, .profit-chart { height: 300px; }
}
@media (max-width: 620px) {
  .bi-chart-canvas .amcharts-chart { height: 320px; }
  .revenue-chart, .profit-chart { height: 280px; }
  .bi-view-btn { padding: 8px 14px; font-size: 13px; }
}

/* Keep amCharts tooltips above other content and readable in both themes. */
.amcharts-tooltip {
  background: #11100e;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.12);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 10px;
}
