/* King Mobile UI — Light theme with semantic color system */
:root {
  /* Brand (violet — primary identity, ~10% accent in 60-30-10 rule) */
  --primary: #6236ff;
  --primary-dark: #4c28c9;
  --primary-light: #ede9fe;
  --primary-hover: #5028e0;
  --primary-muted: #f5f3ff;

  /* Neutrals (60% — backgrounds & body text) */
  --bg-app: #eef0f6;
  --bg-sidebar: #f5f5f7;
  --bg-card: #ffffff;
  --text-primary: #1e1e2d;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(30, 30, 45, 0.06);
  --shadow-nav: 0 8px 32px rgba(98, 54, 255, 0.12);

  /* Semantic — split-complementary & analogous pairs for light surfaces (WCAG AA) */
  --success: #0f766e;
  --success-bg: #f0fdfa;
  --success-border: #99f6e4;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --radius-lg: 20px;
  --radius-xl: 24px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { line-height: 1.5; -webkit-text-size-adjust: 100%; }
body { font-family: Inter, system-ui, -apple-system, sans-serif; color: var(--text-primary); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }

/* ===== APP SHELL ===== */
.app-body { min-height: 100vh; background: var(--bg-app); }
.app-shell { display: flex; min-height: 100vh; }
.app-main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-bottom: 88px; }
.app-main { flex: 1; padding: 1rem 1.25rem 2rem; max-width: 1200px; width: 100%; margin: 0 auto; }

@media (min-width: 768px) {
  .app-main-wrap { padding-bottom: 0; margin-left: 260px; }
  .app-main { padding: 1.75rem 2rem 2.5rem; }
}

/* ===== SIDEBAR (desktop) ===== */
.sidebar {
  display: none;
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  z-index: 40;
  padding: 16px;
}
@media (min-width: 768px) { .sidebar { display: block; } }

.sidebar-inner {
  height: 100%;
  background: var(--bg-sidebar);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo, .sidebar-logo-fallback {
  width: 40px; height: 40px; border-radius: 12px; object-fit: cover; flex-shrink: 0;
}
.sidebar-logo-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary);
}
.sidebar-brand-name { display: block; font-weight: 700; font-size: 14px; letter-spacing: 0.02em; }
.sidebar-brand-tag { display: block; font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar-section {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); padding: 14px 12px 6px; margin: 0;
}
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  transition: background 0.15s, color 0.15s; margin-bottom: 2px;
}
.sidebar-link:hover { background: #ebebed; color: var(--text-primary); }
.sidebar-link-active {
  background: #ebebed; color: var(--text-primary); font-weight: 600;
}
.sidebar-icon { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.75; }
.sidebar-link-active .sidebar-icon { opacity: 1; color: var(--primary); }

.sidebar-profile {
  display: flex; align-items: center; gap: 10px;
  margin: 10px; padding: 12px;
  background: #ebebed; border-radius: 16px;
}
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar-profile-name { font-size: 13px; font-weight: 700; line-height: 1.2; }
.sidebar-profile-role { font-size: 11px; color: var(--text-secondary); }
.sidebar-profile-info { flex: 1; min-width: 0; }
.sidebar-logout {
  width: 32px; height: 32px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: background 0.15s;
}
.sidebar-logout:hover { background: rgba(0,0,0,0.06); color: var(--primary); }

/* ===== MOBILE HEADER ===== */
.mobile-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.mobile-header-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.mobile-header-logo, .mobile-header-logo-fallback {
  width: 32px; height: 32px; border-radius: 10px; object-fit: cover;
}
.mobile-header-logo-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary);
}
.mobile-header-role {
  font-size: 11px; font-weight: 600; color: var(--primary);
  background: var(--primary-light); padding: 4px 10px; border-radius: 999px;
}

/* ===== MOBILE BOTTOM NAV (pill style) ===== */
.mobile-bottom-nav {
  position: fixed; bottom: 16px; left: 16px; right: 16px; z-index: 50;
}
.mobile-bottom-nav-inner {
  display: flex; align-items: center; justify-content: space-around;
  background: var(--bg-card); border-radius: var(--radius-xl);
  padding: 8px 10px; box-shadow: var(--shadow-nav);
  border: 1px solid rgba(255,255,255,0.8);
}
.mobile-nav-item {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; border-radius: 16px; border: none; background: none;
  color: var(--text-secondary); cursor: pointer; transition: all 0.2s;
  min-width: 44px;
}
.mobile-nav-item-active {
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 14px rgba(98, 54, 255, 0.35);
  padding: 10px 18px;
}
.mobile-nav-icon { width: 22px; height: 22px; }
.mobile-nav-label { font-size: 12px; font-weight: 600; white-space: nowrap; }

.sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  z-index: 60; backdrop-filter: blur(2px);
}
.sheet-menu {
  position: fixed; bottom: 88px; left: 16px; right: 16px; z-index: 70;
  background: var(--bg-card); border-radius: var(--radius-xl);
  padding: 12px; box-shadow: var(--shadow-nav);
}
.sheet-menu-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); padding: 8px 12px 4px;
}
.sheet-menu-link {
  display: block; padding: 12px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 500; color: var(--text-primary);
}
.sheet-menu-link:hover { background: #f5f5f7; }
.sheet-menu-link-danger { color: #ef4444; }
.sheet-divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

/* ===== LOGIN PAGE ===== */
.login-body { min-height: 100vh; margin: 0; }
.login-page {
  min-height: 100vh; position: relative; overflow: hidden;
  background: linear-gradient(160deg, #7eb8ff 0%, #b8d4ff 35%, #dcecff 70%, #eef4ff 100%);
}
.login-bg-rings {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.4) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(98,54,255,0.08) 0%, transparent 45%);
}
.login-center {
  position: relative; z-index: 2;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px 40px;
}
.login-glass-card {
  width: 100%; max-width: 420px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  padding: 32px 32px 28px;
  box-shadow: 0 20px 60px rgba(98, 54, 255, 0.12), 0 4px 20px rgba(0,0,0,0.06);
  text-align: center;
}
.login-card-brand {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.login-card-logo, .login-card-logo-fallback {
  width: 64px; height: 64px; border-radius: 18px; object-fit: cover;
  box-shadow: 0 4px 16px rgba(98, 54, 255, 0.15);
}
.login-card-logo-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary);
}
.login-card-name {
  font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1.25;
}
.login-form { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.login-form .alert-error { margin-bottom: 4px; text-align: left; }
.login-footer-note { margin-top: 24px; font-size: 12px; color: var(--text-secondary); }

.input-icon-wrap { position: relative; }
.input-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; display: flex;
}
.input-with-icon { padding-left: 44px !important; background: rgba(255,255,255,0.9) !important; }

.btn-login-submit {
  width: 100%; margin-top: 8px; padding: 14px 20px;
  border: none; border-radius: 14px;
  background: linear-gradient(180deg, #2d2d3a 0%, #1a1a24 100%);
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}
.btn-login-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,0.25); }

/* ===== COMPONENTS ===== */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 10px 18px;
  font-size: 14px; font-weight: 600; color: #fff; cursor: pointer;
  background: var(--primary); transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 18px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  background: var(--bg-card); color: var(--text-primary); transition: background 0.15s;
}
.btn-secondary:hover { background: #f9f9fb; }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 10px 18px;
  font-size: 14px; font-weight: 600; color: #fff; cursor: pointer;
  background: var(--danger); transition: background 0.15s;
}
.btn-danger:hover { background: #991b1b; }

.tab-btn {
  display: inline-flex; align-items: center; padding: 8px 16px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-card); font-size: 14px; font-weight: 500;
  color: var(--text-primary); transition: all 0.15s;
}
.tab-btn-active { background: var(--primary); color: #fff; border-color: var(--primary); }

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow);
}

.input {
  width: 100%; border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 16px; font-size: 14px; outline: none;
  background: #f9f9fb; color: var(--text-primary); transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(98, 54, 255, 0.12);
  background: #fff;
}
.input::placeholder { color: var(--text-muted); }

.label {
  display: block; margin-bottom: 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-secondary);
}

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.badge-new { background: var(--success-border); color: var(--success); }
.badge-repaired { background: var(--warning-border); color: var(--warning); }
.badge-used { background: var(--info-border); color: var(--info); }
.badge-wasted { background: var(--danger-border); color: var(--danger); }

.table-wrap {
  overflow-x: auto; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--bg-card); box-shadow: var(--shadow);
}
.table { width: 100%; min-width: 100%; text-align: left; font-size: 14px; }
.table th {
  background: #f9f9fb; padding: 12px 16px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-secondary);
}
.table td { border-top: 1px solid var(--border); padding: 12px 16px; color: var(--text-primary); }
.table-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}
.table-row-actions form.inline { display: inline; margin: 0; }
.table-row-actions button[type="submit"],
.table-row-actions button[type="button"].text-king-400,
.table-row-actions button[type="button"].text-red-400 {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.row-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  text-decoration: none;
}
.row-action-icon:hover { opacity: 0.8; }
.stock-unit-card { border-left: 3px solid var(--primary); }
.stock-main-table td.font-mono { letter-spacing: 0.02em; }

.list-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}
.list-pagination-summary {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}
.list-pagination-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.list-pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.list-pagination-link:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.list-pagination-link-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.list-pagination-ellipsis {
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1.25; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; line-height: 1.45; max-width: 42rem; }
.page-header.flex {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header.flex.items-center { align-items: center; }
.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 16px;
}
.page-toolbar .input { flex: 1; min-width: 180px; }
.page-stack { display: flex; flex-direction: column; gap: 16px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

/* KPI cards: tinted surface + accent bar (semantic color on light bg) */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--kpi-accent, var(--primary));
}
.kpi-card--neutral { background: var(--primary-muted); --kpi-accent: var(--primary); }
.kpi-card--primary { background: var(--primary-muted); --kpi-accent: var(--primary); }
.kpi-card--success { background: var(--success-bg); --kpi-accent: var(--success); border-color: var(--success-border); }
.kpi-card--info { background: var(--info-bg); --kpi-accent: var(--info); border-color: var(--info-border); }
.kpi-card--warning { background: var(--warning-bg); --kpi-accent: var(--warning); border-color: var(--warning-border); }
.kpi-card--danger { background: var(--danger-bg); --kpi-accent: var(--danger); border-color: var(--danger-border); }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 6px;
}
.kpi-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--kpi-value-color, var(--text-primary));
  margin: 0;
}
.kpi-card--neutral .kpi-value,
.kpi-card--primary .kpi-value { color: var(--primary-dark); }
.kpi-card--success .kpi-value { color: var(--success); }
.kpi-card--info .kpi-value { color: var(--info); }
.kpi-card--warning .kpi-value { color: var(--warning); }
.kpi-card--danger .kpi-value { color: var(--danger); }

.kpi-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kpi-card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(30, 30, 45, 0.1);
}
.kpi-card-link.text-center .kpi-label { margin-top: 4px; margin-bottom: 0; }

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.list-toolbar-search { flex: 1; min-width: 160px; }
.list-toolbar-filter { width: auto; min-width: 120px; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  pointer-events: none;
}
.modal-overlay[style*="display: none"] { pointer-events: none; }
.modal-overlay:not([style*="display: none"]) { pointer-events: auto; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 17, 23, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-sheet {
  position: relative; z-index: 1;
  width: 100%; max-width: 480px; max-height: min(92vh, 720px);
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12), 0 24px 48px rgba(98, 54, 255, 0.08);
  overflow: hidden;
  pointer-events: auto;
}
.modal-handle {
  width: 40px; height: 4px; border-radius: 999px;
  background: #d1d1d6; margin: 10px auto 0;
}
.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 20px 0;
}
.modal-header-text { min-width: 0; flex: 1; }
.modal-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--primary); margin-bottom: 4px;
}
.modal-title { font-size: 20px; font-weight: 700; color: var(--text-primary); line-height: 1.25; }
.modal-close {
  flex-shrink: 0; width: 36px; height: 36px; border: none; border-radius: 12px;
  background: #f2f2f7; color: var(--text-secondary); font-size: 24px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: #e8e8ed; color: var(--text-primary); }
.modal-body {
  flex: 1; overflow-y: auto; padding: 16px 20px 8px;
  -webkit-overflow-scrolling: touch;
}
.modal-subtitle {
  font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.45;
  word-break: break-word;
}
.modal-progress-wrap { margin-bottom: 18px; }
.modal-progress-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 8px;
}
.modal-step-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--text-primary);
  background: var(--primary-light); color: var(--primary);
  padding: 6px 12px; border-radius: 999px; font-weight: 600;
}
.modal-progress-pct { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.modal-progress-track {
  height: 6px; border-radius: 999px; background: #ececf1; overflow: hidden;
}
.modal-progress-fill {
  height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #8b6cff);
  transition: width 0.25s ease;
}
.input-lg { padding: 14px 16px; font-size: 16px; border-radius: 14px; }
.modal-hint { margin-top: 10px; font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.modal-error {
  margin-top: 12px; padding: 10px 12px; border-radius: 12px;
  font-size: 13px; color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca;
}
.modal-actions {
  display: flex; flex-direction: column-reverse; gap: 10px;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border); background: #fafafa;
}
.modal-btn { width: 100%; min-height: 48px; font-size: 15px; font-weight: 600; }

.modal-enter { transition: opacity 0.2s ease; }
.modal-enter-start { opacity: 0; }
.modal-enter-end { opacity: 1; }
.modal-leave { transition: opacity 0.15s ease; }
.modal-leave-start { opacity: 1; }
.modal-leave-end { opacity: 0; }
.modal-enter-start .modal-sheet,
.modal-leave-end .modal-sheet { transform: translateY(100%); }
.modal-enter-end .modal-sheet,
.modal-leave-start .modal-sheet { transform: translateY(0); }
.modal-sheet { transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1); }

html.modal-open, html.modal-open body { overflow: hidden; }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal-sheet {
    border-radius: var(--radius-lg);
    max-height: min(85vh, 640px);
  }
  .modal-handle { display: none; }
  .modal-header { padding: 24px 24px 0; }
  .modal-body { padding: 16px 24px 8px; }
  .modal-actions {
    flex-direction: row; justify-content: flex-end;
    padding: 16px 24px 24px;
  }
  .modal-btn { width: auto; min-width: 120px; }
}

@media (min-width: 640px) {
  .modal-enter-start .modal-sheet,
  .modal-leave-end .modal-sheet { transform: translateY(16px) scale(0.98); opacity: 0; }
  .modal-enter-end .modal-sheet,
  .modal-leave-start .modal-sheet { transform: translateY(0) scale(1); opacity: 1; }
  .modal-sheet { transition: transform 0.22s ease, opacity 0.22s ease; }
}

/* Direct purchase — table row per line */
.direct-purchase-page { width: 100%; max-width: 100%; margin: 0 auto; }

.purchase-lines-card { padding: 20px; }
.purchase-lines-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.purchase-lines-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.purchase-lines-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }
.btn-compact { padding: 8px 10px; font-size: 12px; min-height: 38px; white-space: nowrap; }

.purchase-empty {
  padding: 28px 16px; text-align: center; font-size: 14px; color: var(--text-secondary);
  border: 1px dashed var(--border); border-radius: 14px; background: #fafafa;
  margin-bottom: 16px;
}

.purchase-table-wrap { margin-bottom: 0; }
.purchase-lines-table { min-width: 880px; }
.purchase-lines-table th,
.purchase-lines-table td { vertical-align: middle; padding: 10px 12px; }
.purchase-lines-table .input-compact {
  padding: 8px 10px; font-size: 13px; min-height: 38px;
}
.purchase-col-no { width: 40px; text-align: center; color: var(--text-muted); font-weight: 600; }
.purchase-col-type { width: 88px; }
.purchase-col-product { min-width: 180px; }
.purchase-col-variant { min-width: 180px; }
.purchase-col-qty { width: 100px; min-width: 100px; }
.purchase-col-qty .input-qty { width: 100%; min-width: 72px; text-align: center; }
.purchase-col-cost { width: 110px; }
.purchase-col-serials { width: 88px; text-align: center; }
.purchase-col-total { width: 120px; text-align: right; white-space: nowrap; }
.purchase-col-action { width: 44px; text-align: center; }

.purchase-type-badge {
  display: inline-block; padding: 4px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.purchase-type-badge.is-mobile { background: var(--primary-light); color: var(--primary-dark); }
.purchase-type-badge.is-accessory { background: var(--info-bg); color: var(--info); }

.purchase-line-total { font-size: 14px; font-weight: 700; color: var(--primary-dark); }
.purchase-na { color: var(--text-muted); font-size: 14px; }
.purchase-line-remove {
  width: 32px; height: 32px; border: none; border-radius: 8px;
  background: var(--danger-bg); color: var(--danger); font-size: 20px; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.purchase-line-remove:hover { background: var(--danger-border); }
.purchase-serial-btn { width: 100%; }

.purchase-grand-total {
  display: flex; flex-direction: column; gap: 16px;
  margin-top: 20px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.purchase-grand-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.purchase-grand-value { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.purchase-save-btn { width: 100%; min-height: 48px; font-size: 15px; }

@media (min-width: 640px) {
  .purchase-grand-total {
    flex-direction: row; align-items: center; justify-content: space-between;
  }
  .purchase-save-btn { width: auto; min-width: 200px; }
}

[x-cloak] { display: none !important; }

.stat-value { color: var(--primary-dark); }
.stat-value-green { color: var(--success); }
.stat-value-blue { color: var(--info); }
.stat-value-amber { color: var(--warning); }
.stat-value-red { color: var(--danger); }

.alert { border-radius: 12px; padding: 12px 16px; font-size: 14px; }
.alert-success { border: 1px solid var(--success-border); background: var(--success-bg); color: var(--success); }
.alert-error { border: 1px solid var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.flash-wrap { padding: 0 0 12px; }

/* ===== LEGACY CLASS OVERRIDES (views) ===== */
.app-main .text-white { color: var(--text-primary) !important; }
.app-main .text-slate-100, .app-main .text-slate-200 { color: var(--text-primary) !important; }
.app-main .text-slate-300, .app-main .text-slate-400 { color: var(--text-secondary) !important; }
.app-main .text-slate-500, .app-main .text-slate-600 { color: var(--text-muted) !important; }
.app-main .text-king-400, .app-main a.text-king-400 { color: var(--primary-dark) !important; }
.app-main .text-emerald-300, .app-main .text-emerald-400 { color: var(--success) !important; }
.app-main .text-amber-400 { color: var(--warning) !important; }
.app-main .text-blue-400 { color: var(--info) !important; }
.app-main .text-red-300, .app-main .text-red-400 { color: var(--danger) !important; }
.app-main .bg-surface-700, .app-main .bg-surface-800 { background: #f8fafc !important; }
.app-main .border-surface-600 { border-color: var(--border) !important; }
.app-main .hover\:bg-surface-600:hover, .app-main .hover\:bg-surface-700:hover { background: #f1f5f9 !important; }
.app-main .hover\:border-king-500\/50:hover, .app-main .hover\:border-amber-500\/50:hover { border-color: var(--primary) !important; }

/* ===== UTILITIES ===== */
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none; }
.inline-flex { display: inline-flex; }
.flex-1 { flex: 1; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }
.space-y-4 > * + * { margin-top: 16px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-12 { grid-template-columns: repeat(12, 1fr); }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }
.col-span-7 { grid-column: span 7; }
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-4 { width: 1rem; } .h-4 { height: 1rem; }
.w-5 { width: 1.25rem; } .h-5 { height: 1.25rem; }
.w-6 { width: 1.5rem; } .h-6 { height: 1.5rem; }
.max-w-xl { max-width: 36rem; }
.max-h-48 { max-height: 12rem; }
.max-h-96 { max-height: 24rem; }
.min-w-full { min-width: 100%; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.mb-1\.5 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.ml-2 { margin-left: 8px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.p-3 { padding: 12px; }
.p-8 { padding: 32px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.py-8 { padding-top: 32px; padding-bottom: 32px; }
.py-16 { padding-top: 64px; padding-bottom: 64px; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-xs { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }
.text-4xl { font-size: 36px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: ui-monospace, monospace; }
.uppercase { text-transform: uppercase; }
.rounded-lg { border-radius: 8px; }
.rounded-xl { border-radius: 12px; }
.rounded-2xl { border-radius: 16px; }
.border-t { border-top: 1px solid var(--border); }
.text-right { text-align: right; }
.\!py-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.\!px-3 { padding-left: 12px !important; padding-right: 12px !important; }
.\!py-1 { padding-top: 4px !important; padding-bottom: 4px !important; }
.\!text-xs { font-size: 12px !important; }
.\!w-full { width: 100% !important; }
.col-span-2 { grid-column: span 2 / span 2; }

@media (min-width: 768px) {
  .md\:hidden { display: none !important; }
  .md\:block { display: block !important; }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
  .md\:col-span-3 { grid-column: span 3; }
  .md\:col-span-4 { grid-column: span 4; }
  .md\:flex { display: flex; }
}
@media (min-width: 1024px) {
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}

/* POS */
.pos-page { max-width: 1400px; }
.pos-scanner { margin-bottom: 16px; }
.pos-scanner-input { font-size: 18px; min-height: 48px; }
.pos-layout {
  display: grid;
  gap: 16px;
  align-items: start;
}
@media (min-width: 1024px) {
  .pos-layout { grid-template-columns: 1fr 380px; }
}
.pos-catalog { display: flex; flex-direction: column; gap: 16px; }
.pos-section { padding: 20px; }
.pos-section-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.pos-section-icon {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
}
.pos-section-icon-mobile { background: var(--primary-light); color: var(--primary); }
.pos-section-icon-accessory { background: var(--info-bg); color: var(--info); }
.pos-section-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.pos-section-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.pos-step {
  display: flex; gap: 12px; margin-bottom: 20px;
}
.pos-step:last-child { margin-bottom: 0; }
.pos-step-num {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 999px;
  background: var(--primary-light); color: var(--primary-dark);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 22px;
}
.pos-step-body { flex: 1; min-width: 0; }
.pos-hint { font-size: 13px; color: var(--text-secondary); padding: 8px 0 16px 40px; }
.pos-variant-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.pos-variant-chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 12px 14px; border-radius: 12px; text-align: left;
  border: 2px solid var(--border); background: #fafafa;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.pos-variant-chip:hover { border-color: var(--primary); background: var(--primary-muted); }
.pos-variant-chip.is-selected {
  border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
}
.pos-variant-specs { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.pos-variant-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 11px; color: var(--text-secondary);
}
.pos-unit-list { display: flex; flex-direction: column; gap: 8px; }
.pos-unit-card {
  width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: #fff;
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.pos-unit-card:hover {
  border-color: var(--primary); box-shadow: 0 2px 12px rgba(98, 54, 255, 0.1);
}
.pos-unit-main {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.pos-unit-serial { font-family: ui-monospace, monospace; font-size: 14px; font-weight: 600; color: var(--primary-dark); }
.pos-unit-price { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.pos-unit-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 6px; font-size: 11px; color: var(--text-secondary);
}
.pos-unit-badge {
  padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; background: var(--warning-bg); color: var(--warning);
}
.pos-unit-badge.is-direct { background: var(--success-bg); color: var(--success); }
.pos-accessory-group { margin-bottom: 16px; }
.pos-accessory-group:last-child { margin-bottom: 0; }
.pos-accessory-cat {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-secondary); margin-bottom: 8px;
}
.pos-accessory-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.pos-accessory-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; border-radius: 12px; text-align: left;
  border: 1px solid var(--border); background: #fafafa;
  cursor: pointer; min-height: 88px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.pos-accessory-card:hover {
  border-color: var(--info); background: var(--info-bg);
  transform: translateY(-1px);
}
.pos-accessory-name { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.pos-accessory-foot {
  display: flex; flex-direction: column; gap: 2px; margin-top: auto;
}
.pos-accessory-price { font-size: 14px; font-weight: 700; color: var(--primary-dark); }
.pos-accessory-qty { font-size: 11px; color: var(--text-secondary); }
.pos-cart { position: sticky; top: 16px; padding: 20px; }
.pos-cart-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.pos-cart-empty {
  text-align: center; padding: 32px 16px; color: var(--text-secondary);
  border: 1px dashed var(--border); border-radius: 12px; margin-bottom: 16px;
}
.pos-cart-items { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; margin-bottom: 16px; }
.pos-cart-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px; border-radius: 10px; background: #f9f9fb;
  border: 1px solid var(--border);
}
.pos-cart-item-main { flex: 1; min-width: 0; }
.pos-cart-item-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.pos-cart-item-detail { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.pos-cart-qty { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.pos-cart-qty-input { width: 72px !important; min-height: 36px; padding: 6px 10px; }
.pos-cart-remove {
  width: 28px; height: 28px; border: none; border-radius: 8px; flex-shrink: 0;
  background: var(--danger-bg); color: var(--danger); font-size: 18px; line-height: 1;
  cursor: pointer;
}
.pos-cart-totals {
  border-top: 1px solid var(--border); padding-top: 16px; margin-bottom: 16px;
}
.pos-total-row {
  display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px;
}
.pos-total-grand { font-size: 18px; font-weight: 700; color: var(--primary-dark); margin-top: 8px; }
.pos-discount-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pos-discount-input { flex: 1; min-height: 38px; }
.pos-checkout-form { display: flex; flex-direction: column; gap: 12px; }
.pos-link-btn {
  margin-top: 6px; background: none; border: none; padding: 0;
  font-size: 12px; color: var(--primary); cursor: pointer;
}
.pos-new-customer {
  padding: 12px; border-radius: 12px;
  border: 1px solid var(--border); background: #fafafa;
  display: flex; flex-direction: column; gap: 8px;
}
.pos-change-row {
  display: flex; justify-content: space-between; font-size: 14px;
  padding: 10px 12px; border-radius: 10px; background: #f9f9fb;
}
.pos-checkout-btn { min-height: 48px; font-size: 15px; }

@media print { .no-print { display: none !important; } }
[x-cloak] { display: none !important; }

/* Reports */
.report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.report-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.report-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.report-tab-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.report-section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}
.report-section-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.45;
}
.pnl-statement {
  max-width: 40rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.pnl-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.pnl-row:last-child { border-bottom: none; }
.pnl-row-muted { color: var(--text-secondary); background: #fafafa; }
.pnl-row-note { color: var(--text-muted); font-size: 12px; background: #fafafa; }
.pnl-row-total {
  font-weight: 700;
  background: var(--primary-muted);
}
.pnl-row-net {
  font-weight: 800;
  font-size: 16px;
  background: var(--success-bg);
}
.report-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 768px) {
  .report-meta-grid { grid-template-columns: repeat(4, 1fr); }
}
.report-meta-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fafafa;
}
.report-meta-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 4px;
}
.report-meta-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
@media print {
  .list-toolbar,
  .report-tabs,
  .sidebar,
  .mobile-bottom-nav,
  .mobile-header { display: none !important; }
  .report-section { break-inside: avoid; }
  .delete-confirm-modal { display: none !important; }
}

/* Delete password confirmation */
.delete-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.delete-confirm-modal[hidden] { display: none !important; }
.delete-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}
.delete-confirm-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-nav, 0 20px 40px rgba(0,0,0,.2));
}
.delete-confirm-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--danger, #dc2626);
}
.delete-confirm-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 16px;
  line-height: 1.45;
}
.delete-confirm-error {
  color: var(--danger, #dc2626);
  font-size: 12px;
  margin: 8px 0 0;
}
.delete-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
body.delete-confirm-open { overflow: hidden; }
