/* Client-RaQ — Obsidian Precision + full light/dark */
:root, html.light {
  --surface-base: #F8FAFC;
  --surface-canvas: #F1F5F9;
  --surface-subtle: #E2E8F0;
  --surface-card: #FFFFFF;
  --surface-card-hover: #F8FAFC;
  --border-subtle: #E2E8F0;
  --border-glass: rgba(15, 23, 42, 0.08);
  --border-glass-bright: rgba(15, 23, 42, 0.14);
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --primary: #0284C7;
  --primary-hover: #0369A1;
  --primary-soft: #0EA5E9;
  --on-primary: #FFFFFF;
  --status-active: #059669;
  --status-active-bg: rgba(5, 150, 105, 0.12);
  --status-production: #0284C7;
  --status-production-bg: rgba(2, 132, 199, 0.12);
  --status-suspended: #DC2626;
  --status-suspended-bg: rgba(220, 38, 38, 0.12);
  --status-pending: #D97706;
  --status-pending-bg: rgba(217, 119, 6, 0.12);
  --status-confirmed: #7C3AED;
  --status-confirmed-bg: rgba(124, 58, 237, 0.12);
  --sidebar-width: 240px;
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
}

html.dark {
  --surface-base: #0B0F14;
  --surface-canvas: #0F1419;
  --surface-subtle: #131A22;
  --surface-card: #151C24;
  --surface-card-hover: #1A222D;
  --border-subtle: #1E2633;
  --border-glass: rgba(255, 255, 255, 0.07);
  --border-glass-bright: rgba(255, 255, 255, 0.14);
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --primary: #00AEFF;
  --primary-hover: #0284C7;
  --primary-soft: #8fcdff;
  --on-primary: #0B0F14;
  --status-active: #10B981;
  --status-active-bg: rgba(16, 185, 129, 0.12);
  --status-production: #00AEFF;
  --status-production-bg: rgba(0, 174, 255, 0.12);
  --status-suspended: #EF4444;
  --status-suspended-bg: rgba(239, 68, 68, 0.12);
  --status-pending: #F59E0B;
  --status-pending-bg: rgba(245, 158, 11, 0.12);
  --status-confirmed: #8B5CF6;
  --status-confirmed-bg: rgba(139, 92, 246, 0.12);
  --shadow-card: 0 8px 32px -4px rgba(0, 0, 0, 0.45);
}

html { scroll-behavior: smooth; }
body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--surface-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}
* { scrollbar-width: thin; scrollbar-color: var(--border-subtle) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 999px; }

.font-tabular { font-variant-numeric: tabular-nums; }

/* Logo: light mode = black mark, dark mode = white mark */
html.light .logo-for-dark, html:not(.dark) .logo-for-dark { display: none !important; }
html.light .logo-for-light, html:not(.dark) .logo-for-light { display: block !important; }
html.dark .logo-for-light { display: none !important; }
html.dark .logo-for-dark { display: block !important; }

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-glass);
  border-radius: 1rem;
  box-shadow: var(--shadow-card);
  transition: background 0.15s, border-color 0.15s;
}
.card-hover:hover { background: var(--surface-card-hover); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 42px; padding: 0 16px; border-radius: 0.5rem;
  background: var(--primary); color: var(--on-primary); font-weight: 600; font-size: 13px;
  transition: filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 42px; padding: 0 16px; border-radius: 0.5rem;
  background: transparent; border: 1px solid var(--border-subtle);
  color: var(--text-primary); font-weight: 500; font-size: 13px;
  transition: background 0.15s;
}
.btn-ghost:hover { background: var(--surface-subtle); }
.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 42px; padding: 0 16px; border-radius: 0.5rem;
  background: var(--status-suspended); color: #fff; font-weight: 600; font-size: 13px;
}

.input-field {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 0.5rem;
  background: var(--surface-canvas); border: 1px solid var(--border-subtle);
  color: var(--text-primary); font-size: 13px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
.input-field::placeholder { color: var(--text-muted); }
textarea.input-field { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 9999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 9999px; background: currentColor; }
.status-active { background: var(--status-active-bg); color: var(--status-active); }
.status-production { background: var(--status-production-bg); color: var(--status-production); }
.status-suspended { background: var(--status-suspended-bg); color: var(--status-suspended); }
.status-pending { background: var(--status-pending-bg); color: var(--status-pending); }
.status-confirmed { background: var(--status-confirmed-bg); color: var(--status-confirmed); }

/* ========== App shell (sidebar + main) ========== */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--surface-canvas);
}

.app-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface-canvas);
}

/* Single-row top bar — never stack on mobile */
.app-header {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  height: 56px !important;
  min-height: 56px !important;
  max-height: 56px !important;
  padding: 0 12px !important;
  gap: 10px !important;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface-base) 94%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-sizing: border-box;
}
@media (min-width: 1024px) {
  .app-header {
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    padding: 0 20px !important;
    gap: 12px !important;
  }
}

.app-title {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  font-size: 17px !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.app-header-actions {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 6px !important;
  flex-shrink: 0 !important;
  margin-left: auto !important;
}

.menu-btn,
.icon-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  padding: 0 !important;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0 !important;
}
.menu-btn:hover,
.icon-btn:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}
@media (min-width: 1024px) {
  .menu-btn { display: none !important; }
}

.notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--primary);
  pointer-events: none;
}
.notif-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(18rem, calc(100vw - 24px));
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  z-index: 60;
  box-shadow: 0 16px 40px rgba(0,0,0,0.4);
}

/* Avatar only on phone; name from sm up */
.profile-chip {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px;
  padding: 2px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-primary);
  flex-shrink: 0 !important;
}
.profile-chip:hover { background: var(--surface-subtle); }
.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  background: color-mix(in srgb, var(--primary) 22%, transparent);
  color: var(--primary);
  flex-shrink: 0;
}
.profile-name {
  display: none !important;
  font-size: 13px;
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 6px;
}
@media (min-width: 640px) {
  .profile-name { display: inline !important; }
  .profile-chip { padding: 2px 6px 2px 2px; border-radius: 10px; }
}

.app-content {
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  padding: 16px 12px 24px;
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  .app-content { padding: 20px 16px 32px; }
}
@media (min-width: 1024px) {
  .app-content { padding: 24px 24px 40px; }
}
@media (min-width: 1280px) {
  .app-content { padding: 28px 32px 48px; }
}

/* Page toolbar under header */
.page-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 640px) {
  .page-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }
}
.page-toolbar p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-secondary);
}
.page-toolbar .btn-primary {
  width: 100%;
  justify-content: center;
  height: 44px;
  font-size: 14px;
}
@media (min-width: 640px) {
  .page-toolbar .btn-primary {
    width: auto;
    height: 36px;
    font-size: 12px;
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-base);
  border-right: 1px solid var(--border-subtle);
  height: 100vh;
  height: 100dvh;
}

.sidebar-brand {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  height: 56px;
  min-height: 56px;
  padding: 0 12px 0 14px;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  box-sizing: border-box;
}
.sidebar-brand > span.font-semibold {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-badge {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
}
.sidebar-close {
  display: none;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.sidebar-close:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1 1 auto;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s, color 0.15s;
  box-sizing: border-box;
}
.nav-item:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}
.nav-item.active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-overlay { display: none; }

@media (max-width: 1023px) {
  .app-shell {
    display: block !important;
  }
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: min(288px, 88vw);
    transform: translateX(-110%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--border-subtle);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 12px 0 48px rgba(0, 0, 0, 0.5);
  }
  .sidebar-close {
    display: inline-flex !important;
  }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(6, 10, 16, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
  }
  .app-main {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
}

@media (min-width: 1024px) {
  .sidebar {
    position: sticky;
    top: 0;
    transform: none !important;
  }
  .sidebar-overlay {
    display: none !important;
  }
  .sidebar-brand {
    height: 60px;
    min-height: 60px;
    padding: 0 16px 0 18px;
  }
}

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(11, 15, 20, 0.65);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-panel {
  background: var(--surface-card);
  border: 1px solid var(--border-glass-bright);
  border-radius: 1rem;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 48px -8px rgba(0,0,0,0.4);
}

.table-head {
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* ========== Responsive polish ========== */
@media (max-width: 640px) {
  .card { border-radius: 0.75rem; }
  main { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
  .btn-primary, .btn-ghost { min-height: 44px; }
  .input-field { min-height: 44px; font-size: 16px; } /* avoid iOS zoom */
  h1, .text-4xl { font-size: 1.75rem !important; line-height: 1.2 !important; }
  .text-5xl, .text-\[3\.5rem\] { font-size: 2rem !important; }
}
@media (min-width: 641px) and (max-width: 1023px) {
  main { padding-left: 1rem !important; padding-right: 1rem !important; }
}
@media (min-width: 1536px) {
  .max-w-6xl { max-width: 80rem; }
}
/* Tables: horizontal scroll on small screens */
.card .overflow-x-auto { -webkit-overflow-scrolling: touch; }
/* Safe area for notched phones */
@supports (padding: max(0px)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}


/* Force mobile drawer (final) */
@media (max-width: 1023px) {
  .app-shell { display: block !important; }
  aside.sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    z-index: 50 !important;
    width: min(288px, 88vw) !important;
    height: 100dvh !important;
    transform: translateX(-110%) !important;
    transition: transform 0.28s ease !important;
  }
  aside.sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 12px 0 48px rgba(0,0,0,0.5) !important;
  }
  .app-main { width: 100% !important; max-width: 100% !important; }
}
@media (min-width: 1024px) {
  aside.sidebar {
    position: sticky !important;
    top: 0 !important;
    transform: none !important;
    width: var(--sidebar-width) !important;
    height: 100vh !important;
  }
}
