/* ========================================================================== 
   SME Orbit Business Management System
   Authenticated application design system
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;

  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;

  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;

  --primary: 215 25% 27%;
  --primary-foreground: 0 0% 98%;

  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;

  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;

  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;

  /* Industry-standard semantic colours. */
  --destructive: 0 72.2% 50.6%;
  --destructive-foreground: 0 0% 98%;

  --success: 142 71% 29%;
  --success-foreground: 0 0% 98%;
  --success-muted: 141 79% 95%;

  --warning: 32 95% 38%;
  --warning-foreground: 0 0% 98%;
  --warning-muted: 48 100% 96%;

  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 193 82% 31%;

  --sidebar: 210 20% 97%;
  --sidebar-foreground: 240 10% 3.9%;
  --sidebar-border: 215 18% 89%;
  --sidebar-accent: 210 20% 94%;

  /* SME Orbit core palette. */
  --brand-slate: 215 25% 27%;       /* #334155 */
  --brand-deep: 142 10% 21%;        /* #313c35 */
  --brand-green: 142 71% 45%;       /* #22c55e */
  --brand-teal: 193 82% 31%;        /* #0e7490 */
  --brand-blue: 226 71% 40%;        /* #1e40af */
  --brand-amber: 32 95% 44%;        /* #d97706 */
  --brand-steel: 190 16% 29%;       /* #3d5155 */
  --brand-ink: 0 0% 9%;             /* #171717 */

  /* Extended editorial accents. Used sparingly. */
  --brand-forest: 153 30% 18%;      /* #1f3a2e */
  --brand-gold: 41 56% 51%;         /* #c79a3b */
  --brand-maroon: 346 53% 31%;      /* #7a263a */
  --brand-cream: 38 50% 94%;        /* #f7f1e7 */

  /* Data visualisation. */
  --chart-revenue: 193 82% 31%;
  --chart-secondary: 226 71% 40%;

  /* Cool application canvas: intentionally not cream. */
  --app-canvas: 210 25% 98%;

  --radius: 0.5rem;

  --shadow-sm: 0 1px 2px 0 hsl(240 6% 10% / 0.05);
  --shadow: 0 1px 3px 0 hsl(240 6% 10% / 0.08),
            0 1px 2px -1px hsl(240 6% 10% / 0.08);
  --shadow-md: 0 4px 6px -1px hsl(240 6% 10% / 0.08),
               0 2px 4px -2px hsl(240 6% 10% / 0.06);
  --shadow-lg: 0 10px 15px -3px hsl(240 6% 10% / 0.1),
               0 4px 6px -4px hsl(240 6% 10% / 0.08);

  --header-height: 3.75rem;
  --sidebar-width: 16rem;

  --font-sans: ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono",
    Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;

  --card: 240 10% 5.5%;
  --card-foreground: 0 0% 98%;

  --popover: 240 10% 5.5%;
  --popover-foreground: 0 0% 98%;

  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;

  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;

  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;

  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;

  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;

  --success: 142 69% 45%;
  --success-foreground: 144 61% 8%;
  --success-muted: 143 45% 12%;

  --warning: 38 92% 55%;
  --warning-foreground: 26 83% 8%;
  --warning-muted: 33 60% 12%;

  --border: 240 3.7% 17%;
  --input: 240 3.7% 20%;
  --ring: 188 72% 54%;

  --sidebar: 240 10% 5.5%;
  --sidebar-foreground: 0 0% 98%;
  --sidebar-border: 240 3.7% 17%;
  --sidebar-accent: 240 3.7% 15.9%;

  --shadow-sm: 0 1px 2px 0 hsl(0 0% 0% / 0.3);
  --shadow: 0 1px 3px 0 hsl(0 0% 0% / 0.4),
            0 1px 2px -1px hsl(0 0% 0% / 0.4);
  --shadow-md: 0 4px 6px -1px hsl(0 0% 0% / 0.4),
               0 2px 4px -2px hsl(0 0% 0% / 0.3);
  --shadow-lg: 0 10px 15px -3px hsl(0 0% 0% / 0.5),
               0 4px 6px -4px hsl(0 0% 0% / 0.4);
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  border-color: hsl(var(--border));
}

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  min-height: 100vh;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.011em;
  line-height: 1.25;
}

a { color: inherit; text-decoration: none; }

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

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

button:disabled { cursor: not-allowed; }

svg {
  display: block;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

::selection { background-color: hsl(var(--brand-teal) / 0.16); }

* {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--border)) transparent;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background-color: hsl(var(--border));
  border: 3px solid transparent;
  border-radius: 9999px;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: hsl(var(--muted-foreground) / 0.5);
}

/* --------------------------------------------------------------------------
   3. Utilities
   -------------------------------------------------------------------------- */

.hidden { display: none !important; }

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

.muted { color: hsl(var(--muted-foreground)); }
.mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.full-width { width: 100%; }

.row { display: flex; align-items: center; gap: 0.5rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.col { display: flex; flex-direction: column; gap: 0.5rem; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-sm { gap: 0.375rem; }
.gap-lg { gap: 1rem; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 1.25rem; }

/* --------------------------------------------------------------------------
   4. Application shell
   -------------------------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  background-color: hsl(var(--background));
  transition: grid-template-columns 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: hsl(var(--sidebar));
  border-right: 1px solid hsl(var(--sidebar-border));
  color: hsl(var(--sidebar-foreground));
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  height: var(--header-height);
  padding: 0 1rem;
  border-bottom: 1px solid hsl(var(--sidebar-border));
  flex-shrink: 0;
}

.sidebar-brand-mark {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: calc(var(--radius) - 2px);
  background-color: hsl(var(--brand-slate));
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

[data-theme="dark"] .sidebar-brand-mark {
  background-color: hsl(var(--brand-teal) / 0.22);
  border: 1px solid hsl(var(--brand-teal) / 0.42);
  color: hsl(188 72% 72%);
}

/* SME Orbit logo used in the shared sidebar and authentication screens. */
.sidebar-brand-logo {
  display: block;
  object-fit: contain;
  padding: 0;
  background-color: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
}

[data-theme="dark"] .sidebar-brand-logo {
  background-color: transparent;
  border: 0;
  color: inherit;
}

.sidebar-brand-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-brand-name {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-brand-tagline {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.75rem 0.625rem 1rem;
}
.nav-group + .nav-group { margin-top: 1rem; }
.nav-group-label {
  padding: 0 0.625rem;
  margin-bottom: 0.3125rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: hsl(var(--muted-foreground));
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4375rem 0.625rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-item + .nav-item { margin-top: 0.125rem; }
.nav-item svg { width: 1rem; height: 1rem; opacity: 0.85; }
.nav-item:hover {
  background-color: hsl(var(--sidebar-accent));
  color: hsl(var(--foreground));
}

/* Light active navigation: teal identity without overpowering the sidebar. */
[data-theme="light"] .nav-item[aria-current="page"] {
  background-color: hsl(var(--brand-teal) / 0.085);
  color: hsl(var(--brand-teal));
  font-weight: 600;
  box-shadow: inset 3px 0 0 hsl(var(--brand-teal));
}
[data-theme="light"] .nav-item[aria-current="page"] svg { opacity: 1; }

/* Dark active navigation: same identity, adjusted for dark contrast. */
[data-theme="dark"] .nav-item[aria-current="page"] {
  background-color: hsl(var(--brand-teal) / 0.13);
  color: hsl(188 72% 66%);
  font-weight: 600;
  box-shadow: inset 3px 0 0 hsl(var(--brand-teal));
}
[data-theme="dark"] .nav-item[aria-current="page"] svg {
  color: hsl(188 72% 66%);
  opacity: 1;
}

.nav-item-badge {
  margin-left: auto;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3125rem;
  display: inline-grid;
  place-items: center;
  border-radius: 9999px;
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  font-size: 0.6875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  padding: 0.625rem;
  border-top: 1px solid hsl(var(--sidebar-border));
  flex-shrink: 0;
}

@media (min-width: 1025px) {
  .app-shell.sidebar-collapsed { grid-template-columns: 4.5rem minmax(0, 1fr); }
  .app-shell.sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: 0.5rem; }
  .app-shell.sidebar-collapsed .sidebar-brand-text,
  .app-shell.sidebar-collapsed .nav-group-label,
  .app-shell.sidebar-collapsed .nav-item > span:not(.nav-item-badge),
  .app-shell.sidebar-collapsed .user-button-text,
  .app-shell.sidebar-collapsed .user-button > svg { display: none; }
  .app-shell.sidebar-collapsed .sidebar-nav { padding-inline: 0.5rem; }
  .app-shell.sidebar-collapsed .nav-group + .nav-group { margin-top: 0.5rem; }
  .app-shell.sidebar-collapsed .nav-item { justify-content: center; padding: 0.5rem; }
  .app-shell.sidebar-collapsed .nav-item svg { width: 1.0625rem; height: 1.0625rem; }
  .app-shell.sidebar-collapsed .nav-item-badge {
    position: absolute;
    top: 0.1rem;
    right: 0.1rem;
    min-width: 0.95rem;
    height: 0.95rem;
    padding: 0 0.15rem;
    font-size: 0.55rem;
  }
  .app-shell.sidebar-collapsed .sidebar-footer { padding: 0.5rem; }
  .app-shell.sidebar-collapsed .user-button { justify-content: center; padding: 0.375rem; }
  .app-shell.sidebar-collapsed .sidebar-footer .dropdown-menu {
    left: calc(100% + 0.5rem) !important;
    right: auto !important;
    bottom: 0 !important;
    top: auto !important;
    width: 14rem;
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--header-height);
  padding: 0 1.25rem;
  background-color: hsl(var(--background) / 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid hsl(var(--border));
}
.topbar-title { font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.01em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.sidebar-toggle { display: inline-flex; }

.page {
  padding: 1.5rem 1.25rem 4rem;
  max-width: 88rem;
  margin: 0 auto;
  width: 100%;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-title { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.02em; }
.page-description {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  max-width: 60ch;
}
.page-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4375rem;
  height: 2.25rem;
  padding: 0 0.875rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  transition: background-color 0.12s ease, border-color 0.12s ease,
              color 0.12s ease, opacity 0.12s ease, transform 0.12s ease;
}
.btn svg { width: 0.9375rem; height: 0.9375rem; }
.btn:hover:not(:disabled) { background-color: hsl(var(--primary) / 0.88); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; }

.btn-secondary { background-color: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover:not(:disabled) { background-color: hsl(var(--secondary) / 0.7); }
.btn-outline {
  background-color: hsl(var(--background));
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}
.btn-outline:hover:not(:disabled) { background-color: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-ghost { background-color: transparent; color: hsl(var(--foreground)); }
.btn-ghost:hover:not(:disabled) { background-color: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-destructive { background-color: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-destructive:hover:not(:disabled) { background-color: hsl(var(--destructive) / 0.88); }
.btn-sm { height: 1.875rem; padding: 0 0.6875rem; font-size: 0.78125rem; }
.btn-sm svg { width: 0.875rem; height: 0.875rem; }
.btn-lg { height: 2.5rem; padding: 0 1.125rem; font-size: 0.875rem; }
.btn-icon { width: 2.25rem; padding: 0; }
.btn-icon.btn-sm { width: 1.875rem; }
.btn-block { width: 100%; }
.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: hsl(var(--foreground));
  font-size: 0.8125rem;
  font-weight: 500;
  text-underline-offset: 3px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.destructive { color: hsl(var(--destructive)); }

/* --------------------------------------------------------------------------
   6. Forms
   -------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 0.4375rem; }
.label { font-size: 0.8125rem; font-weight: 500; line-height: 1.2; }
.label-hint { font-weight: 400; color: hsl(var(--muted-foreground)); }

.input,
.select,
.textarea {
  width: 100%;
  height: 2.25rem;
  padding: 0 0.6875rem;
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.8125rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}
.textarea {
  height: auto;
  min-height: 4.5rem;
  padding: 0.5rem 0.6875rem;
  resize: vertical;
  line-height: 1.5;
}
.input::placeholder,
.textarea::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
}
.input:disabled,
.select:disabled,
.textarea:disabled {
  background-color: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  cursor: not-allowed;
}
.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] { border-color: hsl(var(--destructive)); }
.input[aria-invalid="true"]:focus,
.select[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px hsl(var(--destructive) / 0.15);
}

.select {
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
}
[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.field-error { font-size: 0.75rem; color: hsl(var(--destructive)); }
.field-help { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon svg {
  position: absolute;
  left: 0.625rem;
  width: 0.9375rem;
  height: 0.9375rem;
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}
.input-icon .input { padding-left: 2rem; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; }
.checkbox { width: 1rem; height: 1rem; accent-color: hsl(var(--brand-teal)); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

/* --------------------------------------------------------------------------
   7. Card
   -------------------------------------------------------------------------- */

.card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}
.card-header.no-border { border-bottom: none; padding-bottom: 0; }
.card-title { font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.01em; }
.card-description { margin-top: 0.1875rem; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
.card-content { padding: 1.25rem; }
.card-content.flush { padding: 0; }
.card-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid hsl(var(--border));
}

/* --------------------------------------------------------------------------
   8. Statistic tiles
   -------------------------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 1.125rem 1.25rem;
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-top-width: 2px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.stat-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

.stat-value {
  margin-top: 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.stat-hint {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.stat-hint.positive { color: hsl(var(--success)); }
.stat-hint.negative { color: hsl(var(--destructive)); }

.stat-icon {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: calc(var(--radius) - 2px);
  flex-shrink: 0;
}

.stat-icon svg {
  width: 0.9375rem;
  height: 0.9375rem;
  opacity: 1;
}

/*
 * Shared SME Orbit stat tones.
 *
 * These colours identify the type of information, while green/amber/red
 * remain reserved for familiar success/warning/destructive meanings.
 */

/* Teal: revenue, primary analytics, general business totals */
.stat-tone-teal { border-top-color: hsl(var(--brand-teal)); }
.stat-icon-teal,
.stat-icon-revenue {
  color: hsl(var(--brand-teal));
  background-color: hsl(var(--brand-teal) / 0.10);
}

/* Blue: averages, secondary analytics, informational totals */
.stat-tone-blue { border-top-color: hsl(var(--brand-blue)); }
.stat-icon-blue,
.stat-icon-average {
  color: hsl(var(--brand-blue));
  background-color: hsl(var(--brand-blue) / 0.10);
}

/* Forest: operational totals and subtle SME Orbit brand emphasis */
.stat-tone-forest { border-top-color: hsl(var(--brand-forest)); }
.stat-icon-forest,
.stat-icon-items {
  color: hsl(var(--brand-forest));
  background-color: hsl(var(--brand-forest) / 0.10);
}

/* Gold: non-semantic emphasis only; never used as a warning substitute */
.stat-tone-gold { border-top-color: hsl(var(--brand-gold)); }
.stat-icon-gold {
  color: hsl(41 63% 38%);
  background-color: hsl(var(--brand-gold) / 0.12);
}

/* Slate: neutral system totals */
.stat-tone-slate { border-top-color: hsl(var(--brand-slate)); }
.stat-icon-slate {
  color: hsl(var(--brand-slate));
  background-color: hsl(var(--brand-slate) / 0.09);
}

/* Maroon: rare non-destructive editorial/administrative emphasis */
.stat-tone-maroon { border-top-color: hsl(var(--brand-maroon)); }
.stat-icon-maroon {
  color: hsl(var(--brand-maroon));
  background-color: hsl(var(--brand-maroon) / 0.09);
}

/* Semantic tones remain industry-standard. */
.stat-tone-success { border-top-color: hsl(var(--success)); }
.stat-icon-success {
  color: hsl(var(--success));
  background-color: hsl(var(--success) / 0.10);
}

.stat-tone-warning { border-top-color: hsl(var(--warning)); }
.stat-icon-warning,
.stat-icon-stock {
  color: hsl(var(--warning));
  background-color: hsl(var(--warning) / 0.11);
}

.stat-tone-destructive { border-top-color: hsl(var(--destructive)); }
.stat-icon-destructive {
  color: hsl(var(--destructive));
  background-color: hsl(var(--destructive) / 0.10);
}

/* Dark-mode tone contrast. */
[data-theme="dark"] .stat-icon-teal,
[data-theme="dark"] .stat-icon-revenue {
  background-color: hsl(var(--brand-teal) / 0.17);
}

[data-theme="dark"] .stat-icon-blue,
[data-theme="dark"] .stat-icon-average {
  color: hsl(226 78% 72%);
  background-color: hsl(var(--brand-blue) / 0.22);
}

[data-theme="dark"] .stat-icon-forest,
[data-theme="dark"] .stat-icon-items {
  color: hsl(151 39% 64%);
  background-color: hsl(var(--brand-forest) / 0.30);
}

[data-theme="dark"] .stat-tone-forest {
  border-top-color: hsl(151 33% 42%);
}

[data-theme="dark"] .stat-icon-gold {
  color: hsl(41 70% 67%);
  background-color: hsl(var(--brand-gold) / 0.18);
}

[data-theme="dark"] .stat-icon-slate {
  color: hsl(215 20% 72%);
  background-color: hsl(var(--brand-slate) / 0.30);
}

[data-theme="dark"] .stat-icon-maroon {
  color: hsl(346 58% 72%);
  background-color: hsl(var(--brand-maroon) / 0.22);
}

[data-theme="dark"] .stat-icon-success {
  background-color: hsl(var(--success) / 0.14);
}

[data-theme="dark"] .stat-icon-warning,
[data-theme="dark"] .stat-icon-stock {
  background-color: hsl(var(--warning) / 0.14);
}

[data-theme="dark"] .stat-icon-destructive {
  color: hsl(0 90% 72%);
  background-color: hsl(var(--destructive) / 0.17);
}

@media (hover: hover) {
  [data-theme="light"] .stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 9px 26px hsl(var(--brand-slate) / 0.075);
  }

  [data-theme="dark"] .stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px hsl(0 0% 0% / 0.35);
  }
}

/* --------------------------------------------------------------------------
   9. Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 9999px;
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-outline { background: transparent; border-color: hsl(var(--border)); color: hsl(var(--muted-foreground)); }
.badge-success {
  background: hsl(var(--success-muted));
  border-color: hsl(var(--success) / 0.25);
  color: hsl(var(--success));
}
.badge-warning {
  background: hsl(var(--warning-muted));
  border-color: hsl(var(--warning) / 0.3);
  color: hsl(var(--warning));
}
.badge-destructive {
  background: hsl(var(--destructive) / 0.1);
  border-color: hsl(var(--destructive) / 0.25);
  color: hsl(var(--destructive));
}
[data-theme="dark"] .badge-destructive {
  background: hsl(var(--destructive) / 0.18);
  color: hsl(0 90% 78%);
}
.badge-dot { width: 0.375rem; height: 0.375rem; border-radius: 9999px; background: currentColor; }

/* --------------------------------------------------------------------------
   10. Table
   -------------------------------------------------------------------------- */

.table-wrap { width: 100%; overflow-x: auto; }
.table { font-size: 0.8125rem; }
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.625rem 0.875rem;
  background-color: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}
.table tbody td { padding: 0.6875rem 0.875rem; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color 0.1s ease; }
.table tbody tr:hover { background-color: hsl(var(--muted) / 0.5); }
[data-theme="light"] .table tbody tr:hover { background-color: hsl(var(--brand-teal) / 0.035); }
.table .col-actions { text-align: right; white-space: nowrap; }
.table .cell-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.375rem; }
.table .cell-primary { font-weight: 500; color: hsl(var(--foreground)); }
.table .cell-sub { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.table .numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   11. Empty/loading states
   -------------------------------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 1.5rem;
}
.empty-state-icon {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 0.875rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background-color: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}
.empty-state-icon svg { width: 1.25rem; height: 1.25rem; }
.empty-state-title { font-size: 0.875rem; font-weight: 600; }
.empty-state-text { margin-top: 0.25rem; max-width: 38ch; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
.empty-state .btn { margin-top: 1rem; }

.skeleton {
  background-color: hsl(var(--muted));
  border-radius: calc(var(--radius) - 2px);
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.skeleton-text { height: 0.75rem; }
.skeleton-row { height: 2.75rem; }
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 9999px;
  animation: spin 0.6s linear infinite;
}
.spinner-lg { width: 1.75rem; height: 2rem; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.875rem;
  min-height: 60vh;
  color: hsl(var(--muted-foreground));
}

/* --------------------------------------------------------------------------
   12. Alerts
   -------------------------------------------------------------------------- */

.alert {
  display: flex;
  gap: 0.6875rem;
  padding: 0.875rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background-color: hsl(var(--card));
  font-size: 0.8125rem;
}
.alert svg { width: 1rem; height: 1rem; margin-top: 0.0625rem; }
.alert-title { font-weight: 600; margin-bottom: 0.125rem; }
.alert-body { color: hsl(var(--muted-foreground)); }
.alert-destructive {
  border-color: hsl(var(--destructive) / 0.35);
  background: hsl(var(--destructive) / 0.06);
  color: hsl(var(--destructive));
}
.alert-destructive .alert-body { color: hsl(var(--destructive) / 0.9); }
.alert-warning {
  border-color: hsl(var(--warning) / 0.35);
  background: hsl(var(--warning-muted));
  color: hsl(var(--warning));
}
.alert-warning .alert-body { color: hsl(var(--warning) / 0.95); }
.alert-success {
  border-color: hsl(var(--success) / 0.3);
  background: hsl(var(--success-muted));
  color: hsl(var(--success));
}
.alert-success .alert-body { color: hsl(var(--success) / 0.9); }

/* --------------------------------------------------------------------------
   13. Dialog
   -------------------------------------------------------------------------- */

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
  background-color: hsl(240 10% 3.9% / 0.55);
  backdrop-filter: blur(2px);
  animation: overlay-in 0.15s ease;
  overflow-y: auto;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  width: 100%;
  max-width: 30rem;
  margin: auto;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: dialog-in 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.dialog-lg { max-width: 44rem; }
.dialog-sm { max-width: 24rem; }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.dialog-header { display: flex; align-items: flex-start; gap: 1rem; padding: 1.25rem 1.25rem 0; }
.dialog-heading { flex: 1 1 auto; min-width: 0; }
.dialog-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.dialog-description { margin-top: 0.3125rem; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
.dialog-close {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  margin: -0.25rem -0.25rem 0 0;
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
}
.dialog-close:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.dialog-close svg { width: 1rem; height: 1rem; }
.dialog-body { padding: 1.25rem; max-height: min(60vh, 34rem); overflow-y: auto; }
.dialog-footer { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; padding: 0 1.25rem 1.25rem; }
.dialog-footer .spacer { margin-right: auto; }
@media (max-width: 520px) {
  .dialog-footer { flex-direction: column-reverse; align-items: stretch; }
  .dialog-footer .btn { width: 100%; }
  .dialog-footer .spacer { margin-right: 0; }
}

/* --------------------------------------------------------------------------
   14. Toast
   -------------------------------------------------------------------------- */

.toast-region {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 80;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.8125rem 0.875rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.leaving { animation: toast-out 0.15s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }
.toast svg { width: 1rem; height: 1rem; margin-top: 0.0625rem; }
.toast-content { flex: 1 1 auto; min-width: 0; }
.toast-title { font-size: 0.8125rem; font-weight: 600; }
.toast-text { margin-top: 0.125rem; font-size: 0.78125rem; color: hsl(var(--muted-foreground)); overflow-wrap: anywhere; }
.toast-success svg { color: hsl(var(--success)); }
.toast-error svg { color: hsl(var(--destructive)); }
.toast-warning svg { color: hsl(var(--warning)); }
.toast-info svg { color: hsl(var(--brand-teal)); }
.toast-dismiss { color: hsl(var(--muted-foreground)); border-radius: 0.25rem; }
.toast-dismiss:hover { color: hsl(var(--foreground)); }
.toast-dismiss svg { width: 0.875rem; height: 0.875rem; }

/* --------------------------------------------------------------------------
   15. Dropdown
   -------------------------------------------------------------------------- */

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.375rem);
  z-index: 50;
  min-width: 12rem;
  padding: 0.25rem;
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.dropdown-menu[hidden] { display: none; }
.dropdown-label { padding: 0.4375rem 0.5rem; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4375rem 0.5rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  text-align: left;
  color: hsl(var(--foreground));
}
.dropdown-item svg { width: 0.875rem; height: 0.875rem; opacity: 0.8; }
.dropdown-item:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.dropdown-item.destructive { color: hsl(var(--destructive)); }
.dropdown-item.destructive:hover { background: hsl(var(--destructive) / 0.1); color: hsl(var(--destructive)); }
.dropdown-separator { height: 1px; margin: 0.25rem -0.25rem; background: hsl(var(--border)); }

/* --------------------------------------------------------------------------
   16. Avatar and user button
   -------------------------------------------------------------------------- */

.avatar {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 9999px;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  font-size: 0.6875rem;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-lg { width: 2.25rem; height: 2.25rem; font-size: 0.8125rem; }
.user-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  text-align: left;
  transition: background-color 0.12s ease;
}
.user-button:hover { background: hsl(var(--sidebar-accent)); }
.user-button-text { min-width: 0; flex: 1 1 auto; }
.user-button-name { font-size: 0.8125rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-button-meta { font-size: 0.6875rem; color: hsl(var(--muted-foreground)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-button svg { width: 0.875rem; height: 0.875rem; color: hsl(var(--muted-foreground)); }

/* --------------------------------------------------------------------------
   17. Tabs
   -------------------------------------------------------------------------- */

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.1875rem;
  background: hsl(var(--muted));
  border-radius: calc(var(--radius) - 1px);
}
.tab {
  padding: 0.3125rem 0.6875rem;
  border-radius: calc(var(--radius) - 3px);
  font-size: 0.78125rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.tab:hover { color: hsl(var(--foreground)); }
.tab[aria-selected="true"] {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-sm);
}
[data-theme="light"] .tab[aria-selected="true"] { color: hsl(var(--brand-teal)); }

/* --------------------------------------------------------------------------
   18. Toolbar and pagination
   -------------------------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}
.toolbar .search { flex: 1 1 16rem; max-width: 22rem; min-width: 12rem; }
.toolbar .select { width: auto; min-width: 9rem; }
.toolbar .push { margin-left: auto; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid hsl(var(--border));
  font-size: 0.78125rem;
  color: hsl(var(--muted-foreground));
}
.pagination-controls { display: flex; align-items: center; gap: 0.375rem; }

/* --------------------------------------------------------------------------
   19. Description list
   -------------------------------------------------------------------------- */

.detail-list { display: grid; gap: 0; }
.detail-row {
  display: grid;
  grid-template-columns: minmax(8rem, 34%) minmax(0, 1fr);
  gap: 1rem;
  padding: 0.6875rem 0;
  border-bottom: 1px solid hsl(var(--border));
  font-size: 0.8125rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: hsl(var(--muted-foreground)); }
.detail-value { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .detail-row { grid-template-columns: minmax(0, 1fr); gap: 0.125rem; }
}

/* --------------------------------------------------------------------------
   20. Authentication
   -------------------------------------------------------------------------- */

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: hsl(var(--muted) / 0.4);
}
.auth-panel { width: 100%; max-width: 23rem; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 0.625rem; margin-bottom: 1.5rem; }
.auth-brand .sidebar-brand-mark { width: 2.25rem; height: 2.25rem; font-size: 0.875rem; }
.auth-brand-name { font-size: 1rem; font-weight: 600; letter-spacing: -0.015em; }
.auth-brand-tagline { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.auth-footer { margin-top: 1.25rem; text-align: center; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }

/* --------------------------------------------------------------------------
   21. Point of sale
   -------------------------------------------------------------------------- */

.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(20rem, 1fr);
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 1024px) { .pos-layout { grid-template-columns: minmax(0, 1fr); } }
.pos-cart { position: sticky; top: calc(var(--header-height) + 1rem); }
.product-picker { max-height: 30rem; overflow-y: auto; }
.picker-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  padding: 0.6875rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
  text-align: left;
  transition: background-color 0.1s ease;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:hover:not(:disabled) { background: hsl(var(--muted) / 0.6); }
.picker-item:disabled { opacity: 0.55; cursor: not-allowed; }
.picker-item-main { flex: 1 1 auto; min-width: 0; }
.picker-item-name { font-size: 0.8125rem; font-weight: 500; }
.picker-item-meta { font-size: 0.75rem; color: hsl(var(--muted-foreground)); display: flex; align-items: center; gap: 0.4375rem; flex-wrap: wrap; margin-top: 0.125rem; }
.picker-item-price { font-size: 0.8125rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.cart-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem 0.875rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}
.cart-line-name { font-size: 0.8125rem; font-weight: 500; }
.cart-line-meta { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-top: 0.0625rem; }
.cart-line-total { font-size: 0.8125rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.cart-line-controls { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.375rem; }
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  overflow: hidden;
}
.stepper button { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; color: hsl(var(--muted-foreground)); }
.stepper button:hover:not(:disabled) { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.stepper button:disabled { opacity: 0.4; }
.stepper button svg { width: 0.8125rem; height: 0.8125rem; }
.stepper input {
  width: 2.75rem;
  height: 1.75rem;
  border: none;
  border-left: 1px solid hsl(var(--input));
  border-right: 1px solid hsl(var(--input));
  background: transparent;
  text-align: center;
  font-size: 0.78125rem;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}
.stepper input:focus { outline: none; background: hsl(var(--muted)); }
.totals { padding: 1rem 1.25rem; }
.totals-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.3125rem 0; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
.totals-row .value { color: hsl(var(--foreground)); font-variant-numeric: tabular-nums; }
.totals-row.grand { margin-top: 0.5rem; padding-top: 0.75rem; border-top: 1px solid hsl(var(--border)); font-size: 0.9375rem; font-weight: 600; color: hsl(var(--foreground)); }
.totals-row.grand .value { font-size: 1.125rem; letter-spacing: -0.02em; }

/* --------------------------------------------------------------------------
   22. Charts/layout
   -------------------------------------------------------------------------- */

.chart-box { position: relative; width: 100%; height: 17rem; }
.chart-box canvas { max-width: 100%; }
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(21rem, 100%), 1fr));
  gap: 1.25rem;
  align-items: start;
}

/* --------------------------------------------------------------------------
   23. Receipt
   -------------------------------------------------------------------------- */

.receipt { max-width: 44rem; margin: 0 auto; }
.receipt-head { padding: 1.5rem 1.75rem; border-bottom: 1px solid hsl(var(--border)); text-align: center; }
.receipt-business { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.02em; }
.receipt-sub { margin-top: 0.25rem; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
.receipt-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem 1.5rem; padding: 1.25rem 1.75rem; border-bottom: 1px solid hsl(var(--border)); }
.receipt-meta-label { font-size: 0.6875rem; font-weight: 600; color: hsl(var(--muted-foreground)); margin-bottom: 0.1875rem; }
.receipt-meta-value { font-size: 0.8125rem; overflow-wrap: anywhere; }
.receipt-total { padding: 1.25rem 1.75rem; border-top: 1px solid hsl(var(--border)); }
.receipt-foot { padding: 1.25rem 1.75rem; border-top: 1px solid hsl(var(--border)); text-align: center; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.cancelled-stamp { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.3125rem 0.75rem; border: 1px solid hsl(var(--destructive) / 0.4); border-radius: calc(var(--radius) - 2px); color: hsl(var(--destructive)); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; }
.cancelled-stamp svg { width: 0.875rem; height: 0.875rem; }

/* --------------------------------------------------------------------------
   24. Light-mode global polish
   -------------------------------------------------------------------------- */

[data-theme="light"] body,
[data-theme="light"] .app-shell {
  background-color: hsl(var(--app-canvas));
}

[data-theme="light"] .card {
  background-color: hsl(var(--card));
  border-color: hsl(var(--brand-slate) / 0.11);
  box-shadow: 0 1px 2px hsl(var(--brand-slate) / 0.035),
              0 7px 22px hsl(var(--brand-slate) / 0.028);
}

[data-theme="light"] .stat {
  background-color: hsl(var(--card));
  border-left-color: hsl(var(--brand-slate) / 0.11);
  border-right-color: hsl(var(--brand-slate) / 0.11);
  border-bottom-color: hsl(var(--brand-slate) / 0.11);
  box-shadow: 0 1px 2px hsl(var(--brand-slate) / 0.035),
              0 7px 22px hsl(var(--brand-slate) / 0.028);
}

[data-theme="light"] .topbar {
  background-color: hsl(var(--app-canvas) / 0.92);
  border-bottom-color: hsl(var(--brand-slate) / 0.10);
}

[data-theme="light"] .sidebar {
  background-color: hsl(var(--sidebar));
  border-right-color: hsl(var(--brand-slate) / 0.11);
}

[data-theme="light"] .btn-outline {
  background-color: hsl(var(--card));
  border-color: hsl(var(--brand-slate) / 0.17);
}

[data-theme="light"] .input,
[data-theme="light"] .select,
[data-theme="light"] .textarea {
  background-color: hsl(var(--card));
  border-color: hsl(var(--brand-slate) / 0.16);
}

[data-theme="light"] .input:hover,
[data-theme="light"] .select:hover,
[data-theme="light"] .textarea:hover {
  border-color: hsl(var(--brand-slate) / 0.28);
}

[data-theme="light"] .empty-state-icon {
  background-color: hsl(var(--brand-teal) / 0.055);
  border-color: hsl(var(--brand-teal) / 0.12);
  color: hsl(var(--brand-steel));
}

/* --------------------------------------------------------------------------
   25. Dashboard palette
   -------------------------------------------------------------------------- */

/* No cream canvas. Dashboard uses the same cool application surface. */
[data-theme="light"] .dashboard-page,
[data-theme="light"] .dashboard-page .app-shell {
  background-color: hsl(var(--app-canvas));
}

[data-theme="light"] .dashboard-page .grid-2 > .card {
  border-color: hsl(var(--brand-slate) / 0.11);
}

/* Small section markers use colour without turning whole headers colourful. */
.dashboard-page .grid-2 > .card .card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.dashboard-page .grid-2 > .card .card-title::before {
  content: "";
  width: 0.38rem;
  height: 0.38rem;
  flex-shrink: 0;
  border-radius: 999px;
  background-color: hsl(var(--brand-gold));
}
[data-theme="light"] .dashboard-page .grid-2 > .card .card-title {
  color: hsl(var(--brand-deep));
}
[data-theme="dark"] .dashboard-page .grid-2 > .card .card-title::before {
  background-color: hsl(var(--brand-teal));
}

[data-theme="light"] .dashboard-page .table thead th {
  background-color: hsl(var(--brand-slate) / 0.035);
  color: hsl(var(--brand-steel));
  border-bottom-color: hsl(var(--brand-slate) / 0.10);
}

/* --------------------------------------------------------------------------
   26. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 70;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 65;
    background-color: hsl(240 10% 3.9% / 0.5);
    animation: overlay-in 0.15s ease;
  }
}

@media (max-width: 640px) {
  .page { padding: 1.25rem 1rem 3rem; }
  .topbar { padding: 0 1rem; }
  .page-title { font-size: 1.1875rem; }
  .stat-value { font-size: 1.3125rem; }
  .toolbar { padding: 0.75rem 1rem; }
  .card-header,
  .card-content,
  .card-footer { padding-left: 1rem; padding-right: 1rem; }
  .pagination { padding-left: 1rem; padding-right: 1rem; }
  .page-actions .btn { flex: 1 1 auto; }}

/* --------------------------------------------------------------------------
   27. Print
   -------------------------------------------------------------------------- */

@media print {
  :root {
    --background: 0 0% 100%;
    --foreground: 0 0% 0%;
    --card: 0 0% 100%;
    --border: 0 0% 80%;
    --muted-foreground: 0 0% 35%;
  }
  .sidebar,
  .topbar,
  .no-print,
  .toast-region,
  .sidebar-scrim { display: none !important; }
  .app-shell { display: block; }
  .page { padding: 0; max-width: none; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  .receipt { max-width: none; }
  body { font-size: 11pt; }
  @page { margin: 14mm; }
}

/* --------------------------------------------------------------------------
   28. Reduced motion
   -------------------------------------------------------------------------- */

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