/* ==========================================================================
   Fonts
   ========================================================================== */

@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-ExtraBold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
  --font: 'Vazirmatn', 'Tahoma', system-ui, sans-serif;

  --bg: #F4F5FB;
  --surface: #FFFFFF;
  --surface-alt: #F8F9FD;
  --surface-hover: #EFF0FA;
  --ink: #1A1B25;
  --ink-2: #6B7180;
  --ink-3: #9BA0B0;
  --line: #E5E7F0;
  --line-strong: #D4D7E6;

  --primary: #6C5CE7;
  --primary-dark: #5747D6;
  --primary-light: #EEEBFD;
  --on-primary: #FFFFFF;

  --coral: #FF7A59;
  --mint: #13C7A6;
  --amber: #F5A623;
  --red: #E5484D;
  --blue: #3D9BFF;

  --success: var(--mint);
  --success-bg: #E4F8F3;
  --danger: var(--red);
  --danger-bg: #FCE9EA;
  --warning: var(--amber);
  --warning-bg: #FDF1DD;
  --info: var(--blue);
  --info-bg: #E8F2FF;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 3px rgba(20, 21, 40, 0.06);
  --shadow: 0 4px 16px rgba(20, 21, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(20, 21, 40, 0.14);

  --header-h: 56px;
  --nav-h: 64px;

  --z-header: 40;
  --z-nav: 50;
  --z-modal: 100;
  --z-toast: 200;
}

[data-theme='dark'] {
  --bg: #121320;
  --surface: #1B1D2C;
  --surface-alt: #20222F;
  --surface-hover: #272A3B;
  --ink: #F1F2F8;
  --ink-2: #9498AC;
  --ink-3: #6E7286;
  --line: #2C2E40;
  --line-strong: #3A3D54;

  --primary: #8B7CF2;
  --primary-dark: #A496F5;
  --primary-light: #2A2748;
  --on-primary: #FFFFFF;

  --success-bg: #143832;
  --danger-bg: #3A1F22;
  --warning-bg: #3B2E16;
  --info-bg: #16293F;
}

/* ==========================================================================
   Reset & base
   ========================================================================== */

* {
  box-sizing: border-box;
}

/* Several components (e.g. .app-header__offline-badge) set their own `display` value
   with equal specificity to the UA [hidden] rule; without !important here, toggling the
   `hidden` property silently does nothing and the element stays visible forever. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  direction: rtl;
  text-align: start;
  -webkit-font-smoothing: antialiased;
  scrollbar-width: thin;
}

h1, h2, h3, h4, p {
  margin: 0;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--primary);
  text-decoration: none;
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: var(--space-2) 0;
}

input[type='checkbox'] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

canvas {
  max-width: 100%;
}

/* ==========================================================================
   Boot splash
   ========================================================================== */

.boot-splash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  background: var(--bg);
}

.skeleton-bars {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 180px;
}

.skeleton-bar {
  height: 10px;
  width: 100%;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--line) 25%, var(--line-strong) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-bar--md {
  width: 80%;
}

.skeleton-bar--sm {
  width: 55%;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.boot-logo {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  box-shadow: var(--shadow-lg);
  animation: boot-pulse 1.4s ease-in-out infinite;
}

@keyframes boot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.92); opacity: 0.75; }
}

/* ==========================================================================
   Auth screens
   ========================================================================== */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-brand {
  font-weight: 800;
  font-size: 16px;
  color: var(--primary);
}

.auth-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--ink-2);
  margin: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.auth-pin-input {
  text-align: center;
  font-size: 20px;
  letter-spacing: 6px;
}

.auth-error {
  font-size: 13px;
  color: var(--red);
  margin: 0;
}

.auth-lockout {
  font-size: 13px;
  color: var(--amber);
  margin: 0;
}

.auth-submit {
  width: 100%;
}

.auth-card--wide {
  max-width: 480px;
}

.auth-logo {
  margin-bottom: 0;
}

.auth-back-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.auth-step-actions {
  display: flex;
  gap: var(--space-2);
}

.auth-step-actions .btn {
  flex: 1;
}

.auth-user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-3);
  width: 100%;
}

.auth-user-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.auth-user-card:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
}

.auth-user-card:active {
  transform: scale(0.97);
}

.auth-user-card__avatar {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 800;
  font-size: 18px;
}

.auth-user-card__name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}

.auth-role-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

.auth-role-badge--superadmin {
  background: var(--primary-light);
  color: var(--primary);
}

.auth-role-badge--manager {
  background: rgba(61, 155, 255, 0.15);
  color: var(--blue);
}

.auth-role-badge--warehouse {
  background: rgba(245, 166, 35, 0.15);
  color: var(--amber);
}

.auth-role-badge--buyer {
  background: var(--success-bg);
  color: var(--success);
}

.auth-pin-circles {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin: var(--space-2) 0;
}

.auth-pin-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.auth-pin-circle--filled {
  background: var(--primary);
  border-color: var(--primary);
}

/* ==========================================================================
   Landing page
   ========================================================================== */

.landing-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-5) var(--space-7);
  background: var(--bg);
}

.landing-hero {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}

.landing-hero__title {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
  color: var(--ink);
}

.landing-hero__subtitle {
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-2);
  margin: 0;
}

.landing-features {
  width: 100%;
  max-width: 480px;
  display: grid;
  gap: var(--space-3);
}

.landing-feature {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: right;
}

.landing-feature__icon {
  font-size: 24px;
}

.landing-feature__title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}

.landing-feature__desc {
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
  margin: 0;
}

.landing-cta {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.auth-pin-circles--shake {
  animation: auth-pin-shake 0.3s;
}

@keyframes auth-pin-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.auth-pin-hidden-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.admin-extend-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.low-stock-alert-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 320px;
  overflow-y: auto;
}

.low-stock-alert-list__item {
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}

.low-stock-alert__footer {
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  padding: var(--space-2);
}

/* ==========================================================================
   Excel import (sales)
   ========================================================================== */

.import-mapping {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.import-mapping .field {
  min-width: 160px;
  flex: 1;
}

.import-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
}

.import-table__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  min-width: max-content;
}

.import-table__row:last-child {
  border-bottom: none;
}

.import-table__row > span {
  flex: 1 0 100px;
}

.import-table__row--head {
  font-weight: 700;
  background: var(--surface-alt);
  position: sticky;
  top: 0;
}

.import-table__match {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 2 0 200px;
}

.match-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  flex-shrink: 0;
}

.match-badge--exact {
  background: var(--success-bg);
  color: var(--success);
}

.match-badge--fuzzy {
  background: var(--warning-bg);
  color: var(--warning);
}

.match-badge--none {
  background: var(--danger-bg);
  color: var(--danger);
}

.import-summary-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface-alt);
  border-radius: var(--radius);
}

.import-summary-card__line {
  font-size: 14px;
}

.import-summary-card__line--strong {
  font-weight: 700;
  font-size: 15px;
  color: var(--success);
}

.import-summary-card__inventory {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: var(--space-2);
}

.tabs--sub {
  margin-top: var(--space-1);
}

/* ==========================================================================
   App shell
   ========================================================================== */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--header-h);
  padding-inline: clamp(16px, 4vw, 56px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.app-header__logo {
  font-weight: 800;
  font-size: 18px;
  color: var(--primary);
  white-space: nowrap;
}

.app-header__offline-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--warning-bg);
  color: var(--amber);
  font-size: 12px;
  font-weight: 600;
}

.app-header__sync-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  font-size: 12px;
  background: var(--surface-hover);
}

.app-header__sync-badge--syncing {
  color: var(--primary);
  animation: app-header-sync-spin 1s linear infinite;
}

.app-header__sync-badge--synced {
  color: var(--mint);
}

.app-header__sync-badge--error {
  color: var(--red);
}

@keyframes app-header-sync-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-inline-start: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.app-header__actions::-webkit-scrollbar {
  display: none;
}

.app-header__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 18px;
  transition: background 0.15s;
}

.app-header__icon-btn:hover {
  background: var(--surface-hover);
}

.notification-bell {
  position: relative;
  display: flex;
  flex-shrink: 0;
}

.notification-bell__badge {
  position: absolute;
  top: 2px;
  inset-inline-end: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: var(--radius-full);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.notification-bell__panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  width: min(320px, 90vw);
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.15));
  z-index: var(--z-modal);
}

.notification-bell__empty {
  padding: var(--space-2);
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

.notification-bell__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: var(--space-2);
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: start;
  font-family: inherit;
  cursor: pointer;
}

.notification-bell__item:last-child {
  border-bottom: none;
}

.notification-bell__item:hover {
  background: var(--surface-hover);
}

.notification-bell__item--unread {
  background: var(--surface-alt);
}

.notification-bell__item-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.notification-bell__item-message {
  font-size: 12px;
  color: var(--ink-2);
  white-space: pre-line;
}

.notification-bell__item-time {
  font-size: 11px;
  color: var(--ink-3);
}

.app-header__user-chip {
  flex-shrink: 0;
  padding: 4px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--surface-hover);
  color: var(--ink);
  opacity: 0.7;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) clamp(16px, 4vw, 56px);
  font-size: 13px;
  overflow-x: auto;
  scrollbar-width: none;
}

.breadcrumb::-webkit-scrollbar {
  display: none;
}

.breadcrumb__item {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  padding: 0;
  cursor: pointer;
}

.breadcrumb__item:hover {
  color: var(--primary);
}

.breadcrumb__sep {
  flex-shrink: 0;
  color: var(--ink-3);
}

.breadcrumb__item--current {
  flex-shrink: 0;
  color: var(--ink);
  font-weight: 600;
  cursor: default;
}

.app-main {
  flex: 1;
  padding: var(--space-4) clamp(16px, 4vw, 56px);
  padding-bottom: calc(var(--nav-h) + var(--space-6) + env(safe-area-inset-bottom));
}

.app-banner-host {
  padding: var(--space-3) clamp(16px, 4vw, 56px) 0;
}

.app-banner-host:empty {
  display: none;
}

.app-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: var(--z-nav);
  display: flex;
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.app-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  position: relative;
}

.app-nav__icon {
  font-size: 20px;
  line-height: 1;
}

.app-nav__label {
  font-size: 11px;
  font-weight: 500;
}

.app-nav__badge {
  position: absolute;
  top: 2px;
  inset-inline-end: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-nav__item--active {
  color: var(--primary);
}

@media (min-width: 768px) {
  .app-nav {
    inset-inline: 0;
    bottom: var(--space-4);
    max-width: 560px;
    margin-inline: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
  }

  .app-main {
    padding-bottom: calc(var(--nav-h) + var(--space-7) + env(safe-area-inset-bottom));
  }
}

/* ==========================================================================
   View shell
   ========================================================================== */

.view {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 1200px;
  margin-inline: auto;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.view-header__title {
  font-size: 22px;
  font-weight: 800;
}

.view-header__date {
  color: var(--ink-2);
  font-size: 14px;
}

.view-header__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 42px;
  padding-inline: var(--space-4);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: filter 0.15s, background 0.15s, transform 0.05s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--red);
}

.btn-danger:hover {
  filter: brightness(0.96);
}

.btn-sm {
  height: 34px;
  padding-inline: var(--space-3);
  font-size: 13px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 16px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--surface-hover);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.field__hint {
  font-size: 12px;
  color: var(--ink-3);
}

.form-hint {
  font-size: 13px;
  color: var(--ink-2);
}

.input {
  width: 100%;
  height: 42px;
  padding-inline: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.input:focus {
  border-color: var(--primary);
}

.input--sm {
  height: 34px;
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.toolbar .input,
.toolbar select.input {
  width: auto;
  flex: 1 1 160px;
}

.toolbar__checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
}

.tab-toolbar {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tab-toolbar .input {
  flex: 1 1 100%;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* ==========================================================================
   Badges / status chips
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--muted {
  background: var(--surface-alt);
  color: var(--ink-3);
}

.badge--warning {
  background: var(--warning-bg);
  color: var(--amber);
}

.badge--danger {
  background: var(--danger-bg);
  color: var(--red);
}

.badge--success {
  background: var(--success-bg);
  color: var(--success);
}

/* ==========================================================================
   Empty state
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  color: var(--ink-2);
}

.empty-state__icon {
  font-size: 36px;
}

.empty-state__title {
  font-weight: 700;
  color: var(--ink);
}

.empty-state__message {
  font-size: 13px;
  max-width: 320px;
}

/* ==========================================================================
   Cards (generic)
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
}

.kpi-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.kpi-card--clickable {
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}
.kpi-card--clickable:hover,
.kpi-card--clickable:focus-visible {
  background: var(--surface-hover);
}
.kpi-card--clickable:active {
  transform: scale(0.98);
}

.kpi-card__arrow {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 12px;
  color: var(--ink-3);
  opacity: 0.7;
}

.kpi-card__icon {
  font-size: 22px;
  flex-shrink: 0;
}

.kpi-card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kpi-card__label {
  font-size: 12px;
  color: var(--ink-2);
}

.kpi-card__value {
  font-size: 18px;
  font-weight: 700;
}

.kpi-card--positive {
  border-inline-start-color: var(--mint);
}
.kpi-card--positive .kpi-card__value {
  color: var(--mint);
}

.kpi-card--negative {
  border-inline-start-color: var(--red);
}
.kpi-card--negative .kpi-card__value {
  color: var(--red);
}

.kpi-card--warning {
  border-inline-start-color: var(--amber);
}
.kpi-card--warning .kpi-card__value {
  color: var(--amber);
}

.chart-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.chart-card__title {
  font-size: 14px;
  font-weight: 700;
}

.chart-card__canvas-wrap {
  position: relative;
  height: 240px;
}

.onboarding-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.onboarding-checklist {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  list-style: none;
}

.onboarding-checklist__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--ink);
  font-size: 13px;
  text-align: right;
}

.onboarding-checklist__item--done {
  color: var(--ink-2);
  text-decoration: line-through;
}

.onboarding-checklist__arrow {
  margin-inline-start: auto;
  color: var(--ink-2);
}

.quadrant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

.quadrant-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.quadrant-card__title {
  font-size: 13px;
  font-weight: 700;
}

.quadrant-card__desc {
  font-size: 12px;
  color: var(--ink-2);
}

.ai-insight-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.ai-insight-card__text {
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-line;
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 16, 30, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s;
  padding: 0;
}

.modal-overlay--visible {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: var(--space-4) var(--space-4) var(--space-5);
  transform: translateY(16px);
  transition: transform 0.18s;
}

.modal-overlay--visible .modal-dialog {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: 16px;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.modal-message {
  color: var(--ink-2);
  font-size: 14px;
}

.modal-details-list {
  margin: 0;
  padding-inline-start: var(--space-4);
  font-size: 13px;
  color: var(--ink-2);
  max-height: 120px;
  overflow-y: auto;
}

body.modal-open {
  overflow: hidden;
}

@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
  }
  .modal-dialog {
    border-radius: var(--radius-lg);
    transform: translateY(8px) scale(0.98);
  }
  .modal-overlay--visible .modal-dialog {
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast-container {
  position: fixed;
  inset-inline: 0;
  bottom: calc(var(--nav-h) + var(--space-3) + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding-inline: var(--space-4);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 360px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success {
  background: var(--mint);
  color: #06281f;
}

.toast--error {
  background: var(--red);
  color: #fff;
}

.toast--info {
  background: var(--blue);
  color: #fff;
}

/* ==========================================================================
   Alert banner
   ========================================================================== */

.alert-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: 13px;
}

.alert-banner__icon {
  font-size: 18px;
  flex-shrink: 0;
}

.alert-banner__text {
  flex: 1;
  font-weight: 600;
}

.alert-banner__action {
  border: none;
  background: rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-sm);
  padding: 6px var(--space-3);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.alert-banner__dismiss {
  border: none;
  background: transparent;
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0.6;
}

.alert-banner--warning {
  background: var(--warning-bg);
  color: #7A5310;
}

.alert-banner--danger {
  background: var(--danger-bg);
  color: var(--red);
}

.alert-banner--info {
  background: var(--info-bg);
  color: #1E5FA8;
}

[data-theme='dark'] .alert-banner--warning {
  color: var(--amber);
}
[data-theme='dark'] .alert-banner--info {
  color: var(--blue);
}

/* ==========================================================================
   Dashboard
   ========================================================================== */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
}

.quick-actions__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, transform 0.05s;
}

.quick-actions__btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.quick-actions__btn:active {
  transform: scale(0.98);
}

.quick-actions__icon {
  font-size: 24px;
}

.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}

.breakeven-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--primary-light);
  border-radius: var(--radius);
}

.breakeven-panel__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.breakeven-panel__text {
  font-size: 13px;
  color: var(--ink);
}

/* ==========================================================================
   Ingredients
   ========================================================================== */

.ingredient-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.ingredient-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.ingredient-card__main {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ingredient-card__title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ingredient-card__name {
  font-weight: 700;
}

.ingredient-card__meta {
  font-size: 12px;
  color: var(--ink-2);
}

.ingredient-card__meta--muted {
  color: var(--ink-3);
}

.ingredient-card__predict {
  font-size: 12px;
  color: var(--ink-2);
}

.ingredient-card__predict--warning {
  color: var(--amber);
  font-weight: 600;
}

.ingredient-card__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.stock-bar {
  position: relative;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--line);
  overflow: hidden;
}

.stock-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s;
}

.stock-bar__fill--low {
  background: var(--red);
}
.stock-bar__fill--ok {
  background: var(--mint);
}
.stock-bar__fill--full {
  background: var(--blue);
}

.purchase-history {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.purchase-history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 50vh;
  overflow-y: auto;
}

.purchase-history-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  flex-wrap: wrap;
}

.purchase-history-row__date {
  color: var(--ink-2);
  white-space: nowrap;
}

.purchase-history-row__qty {
  font-weight: 600;
  white-space: nowrap;
}

.purchase-history-row__price {
  color: var(--primary);
  font-weight: 700;
  white-space: nowrap;
}

.purchase-history-row__meta {
  flex: 1;
  min-width: 80px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Recipes
   ========================================================================== */

.recipe-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.recipe-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.recipe-row--inactive {
  opacity: 0.55;
}

.recipe-row--highlight {
  animation: recipe-row-pulse 2s ease;
  border-color: var(--primary);
}

@keyframes recipe-row-pulse {
  0%, 100% { box-shadow: var(--shadow-sm); }
  20%, 60% { box-shadow: 0 0 0 3px var(--primary); }
}

.recipe-row__main {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.recipe-row__title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.recipe-row__name {
  font-weight: 700;
}

.recipe-row__meta {
  font-size: 12px;
  color: var(--ink-2);
}

.recipe-row__pct {
  font-size: 18px;
  font-weight: 800;
  min-width: 56px;
  text-align: center;
}

.recipe-row__pct--green {
  color: var(--mint);
}
.recipe-row__pct--amber {
  color: var(--amber);
}
.recipe-row__pct--red {
  color: var(--red);
}

.recipe-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.recipe-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.recipe-section__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.recipe-picker-row {
  display: flex;
  gap: var(--space-2);
}

.recipe-picker-row select {
  flex: 2;
}
.recipe-picker-row .input {
  flex: 1;
}

.recipe-ingredient-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.recipe-ingredient-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.recipe-ingredient-row__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
}

.recipe-ingredient-row__name--deleted {
  color: var(--red);
  font-weight: 700;
  font-size: 15px;
}

.recipe-ingredient-row__unit {
  color: var(--ink-3);
  font-size: 12px;
}

.recipe-ingredient-row__cost {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.recipe-calc-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 1px solid var(--line);
}

.recipe-calc-panel__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.recipe-calc-panel--green {
  background: var(--success-bg);
  border-color: var(--mint);
}
.recipe-calc-panel--amber {
  background: var(--warning-bg);
  border-color: var(--amber);
}
.recipe-calc-panel--red {
  background: var(--danger-bg);
  border-color: var(--red);
}

/* ==========================================================================
   Expenses / payroll
   ========================================================================== */

.tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab-btn {
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn--active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.expense-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.expense-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.expense-row--inactive {
  opacity: 0.55;
}

.expense-row__main {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.expense-row__title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.expense-row__name {
  font-weight: 700;
}

.expense-row__meta {
  font-size: 12px;
  color: var(--ink-2);
}

.expense-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.expense-breakdown {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.expense-breakdown__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  padding: var(--space-1) 0;
}

.expense-breakdown__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.expense-breakdown__label {
  flex: 1;
  color: var(--ink);
}

.expense-breakdown__value {
  font-weight: 600;
  white-space: nowrap;
}

.expense-breakdown__pct {
  color: var(--ink-2);
  min-width: 44px;
  text-align: end;
  white-space: nowrap;
}

/* ==========================================================================
   Sales
   ========================================================================== */

.quick-sale-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.sales-log {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sales-log-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  flex-wrap: wrap;
}

.sales-log-row__date {
  color: var(--ink-2);
  white-space: nowrap;
  min-width: 70px;
}

.sales-log-row__name {
  flex: 1;
  min-width: 100px;
  font-weight: 600;
}

.sales-log-row__qty {
  color: var(--ink-2);
  white-space: nowrap;
}

.sales-log-row__total {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.top-items-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.top-items-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: 13px;
}

.top-items-row__rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.top-items-row__name {
  flex: 1;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-items-row__qty {
  color: var(--ink-2);
  white-space: nowrap;
}

.top-items-row__revenue {
  font-weight: 700;
  white-space: nowrap;
}

/* ==========================================================================
   Accounting
   ========================================================================== */

.accounting-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 1024px) {
  .accounting-grid {
    grid-template-columns: minmax(280px, 380px) 1fr;
  }
}

.pl-statement {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.pl-statement__title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.pl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-1) 0;
  font-size: 13px;
}

.pl-row__label {
  color: var(--ink-2);
}

.pl-row__value {
  font-weight: 600;
}

.pl-row--strong {
  font-size: 15px;
}
.pl-row--strong .pl-row__label {
  color: var(--ink);
  font-weight: 700;
}
.pl-row--strong .pl-row__value {
  font-weight: 800;
}

.pl-row--positive .pl-row__value {
  color: var(--mint);
}
.pl-row--negative .pl-row__value {
  color: var(--red);
}

.source-breakdown-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.source-breakdown-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  min-width: max-content;
}
.source-breakdown-row:last-child {
  border-bottom: none;
}
.source-breakdown-row > span {
  flex: 1 0 110px;
}
.source-breakdown-row__name {
  color: var(--ink-2);
  flex: 1.4 0 140px;
}

.source-breakdown-row--strong {
  font-weight: 700;
  background: var(--surface-alt);
}
.source-breakdown-row--strong .source-breakdown-row__name {
  color: var(--ink);
}

/* ==========================================================================
   Shopping list
   ========================================================================== */

.shopping-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.shopping-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.shopping-row--checked {
  opacity: 0.55;
}

.shopping-row--checked .shopping-row__name {
  text-decoration: line-through;
}

.shopping-row__main {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.shopping-row__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.shopping-row__name {
  font-weight: 700;
}

.shopping-row__stock {
  font-size: 12px;
  color: var(--ink-2);
}

.shopping-row__last-purchase {
  font-size: 12px;
  color: var(--ink-3);
}

.shopping-row__controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.shopping-row__unit {
  font-size: 12px;
  color: var(--ink-3);
}

.shopping-row__cost {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.shopping-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-alt);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
}

.purchase-request-btn {
  display: block;
  width: 100%;
  margin-bottom: var(--space-4);
}

.action-sheet {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.action-sheet__btn {
  width: 100%;
}

.shopping-footer__total {
  color: var(--primary);
}

/* ==========================================================================
   Settings
   ========================================================================== */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}

.settings-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.settings-card__title {
  font-size: 14px;
  font-weight: 700;
}

.automation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
}

.automation-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.automation-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.automation-card__title {
  font-size: 14px;
  font-weight: 700;
}

.automation-card__desc {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 4px;
}

.automation-card__switch input {
  width: 36px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

.subscription-progress {
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--surface-hover);
  overflow: hidden;
}

.subscription-progress__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--success);
  transition: width 0.3s ease;
}

.subscription-progress__fill--warning {
  background: var(--warning);
}

.subscription-progress__fill--danger {
  background: var(--danger);
}

.subscription-status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--ink-2);
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sync-code-display {
  direction: ltr;
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--primary);
}

/* ==========================================================================
   Platform owner panel
   ========================================================================== */

.platform-admin-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  overflow-y: auto;
  background: var(--bg);
}

.platform-admin-screen {
  min-height: 100%;
  padding-bottom: var(--space-6);
}

.platform-admin-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) clamp(16px, 4vw, 56px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.platform-admin-header__title {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.platform-admin-header__badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.platform-admin-screen .view {
  padding: var(--space-4) clamp(16px, 4vw, 56px) 0;
}

.platform-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.platform-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.platform-row__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.platform-row__name {
  font-weight: 700;
}

.platform-row__meta {
  font-size: 12px;
  color: var(--ink-2);
}

.theme-picker {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.theme-picker__btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
}

.theme-picker__icon {
  font-size: 16px;
}

.theme-picker__btn--active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ==========================================================================
   Responsive tweaks
   ========================================================================== */

@media (min-width: 768px) {
  .view {
    gap: var(--space-6);
  }
}

@media (min-width: 1440px) {
  .app-main {
    padding-inline: clamp(16px, 8vw, 120px);
  }
}
