@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --sidebar: #0f172a;
  --sidebar-soft: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: var(--brand);
  --ink: #0f172a;
  --muted: #475569;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --green: #059669;
  --green-ink: #047857;
  --green-soft: #ecfdf5;
  --green-bg: #ecfdf5;
  --brand: #1a3a6e;
  --brand-ink: #142d54;
  --brand-soft: #e8eef7;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --amber-bg: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --red-bg: #fef2f2;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --blue-bg: #eff6ff;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  
  font-family: Outfit, Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Utilities */
.is-hidden {
  display: none !important;
}

.muted {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.muted-cell {
  color: var(--faint);
}

h1, h2, h3, p {
  letter-spacing: -0.01em;
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 800;
  color: #0f172a;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
  font-weight: 700;
  color: #1e293b;
}

h3 {
  font-size: 16px;
  line-height: 1.3;
  font-weight: 600;
  color: #1e293b;
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 10% 20%, rgb(236, 253, 245) 0%, rgb(248, 250, 252) 90.1%);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px 32px;
  animation: loginEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginEnter {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.login-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand);
  border: 1.5px solid rgba(26, 58, 110, 0.2);
}

.login-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.login-brand h1 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.login-brand p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  text-align: center;
}

.error-text {
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin-top: 4px;
}

/* ===== APP SHELL ===== */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--sidebar);
  color: #f8fafc;
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.univ-logo {
  width: 42px;
  height: 42px;
  color: var(--brand);
  flex-shrink: 0;
}

.univ-logo img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.univ-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.univ-text .arabic {
  font-size: 11px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
  color: #34d399;
}

.univ-text .french {
  font-size: 10px;
  font-weight: 500;
  color: #94a3b8;
}

.sidebar-brand .app-title {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  padding-left: 2px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  color: #94a3b8;
  background: transparent;
  min-height: 46px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  text-align: start;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  opacity: 0.8;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(26, 58, 110, 0.25);
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-item:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-role {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
}

.sidebar-role span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.sidebar-role strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: #e2e8f0;
  font-weight: 600;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: #f87171;
  font-weight: 600;
  font-size: 14px;
  text-align: start;
  transition: all 0.2s ease;
}

.sidebar-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

/* ===== WORKSPACE ===== */
.workspace {
  padding: 32px 40px;
  min-width: 0;
  position: relative;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 12px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  max-width: 500px;
}

.hamburger-btn {
  display: none;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 4px;
}

.topbar-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.topbar-search-wrap input {
  padding-left: 38px;
  background: #f8fafc;
  border-radius: 999px;
  border-color: #e2e8f0;
}

.topbar-search-wrap input:focus {
  background: #ffffff;
  border-color: var(--brand);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}

.topbar-icon-btn:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}

.badge-btn {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}

/* User Profile Widget */
.user-profile-widget {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  background: var(--surface);
  transition: all 0.2s ease;
}

.user-profile-widget:hover {
  background: var(--surface-subtle);
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

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

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.user-role {
  font-size: 11px;
  color: var(--muted);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 50;
  animation: dropdownEnter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownEnter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  text-align: start;
}

.dropdown-item:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}

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

.dropdown-item.danger-item:hover {
  background: var(--red-soft);
  color: var(--red);
}

.dropdown-icon {
  width: 16px;
  height: 16px;
}

/* Access Banner */
.access-banner {
  margin-bottom: 24px;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: 1.5px solid rgba(5, 150, 105, 0.15);
  background: var(--green-bg);
  color: var(--green-ink);
  font-weight: 600;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: bannerEnter 0.35s ease-out;
}

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

.access-banner::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
}

.access-banner.readonly {
  border-color: rgba(217, 119, 6, 0.15);
  background: var(--amber-bg);
  color: var(--amber);
}
.access-banner.readonly::before {
  background: var(--amber);
}

.access-banner strong {
  font-weight: 700;
}

.access-banner span {
  color: var(--muted);
  font-weight: 500;
  margin-inline-start: 4px;
}

body.readonly .write-only {
  display: none !important;
}

/* Workspace Headings */
.workspace-heading {
  margin-bottom: 24px;
}

.workspace-heading h1 {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
}

/* ===== METRICS ===== */
.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.metric:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.clickable-metric {
  cursor: pointer;
}

.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.metric-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.metric-icon--primary { background: var(--brand-soft); color: var(--brand); }
.metric-icon--success { background: #ecfdf5; color: #10b981; }
.metric-icon--info { background: #eff6ff; color: #3b82f6; }
.metric-icon--warning { background: #fffbeb; color: #f59e0b; }
.metric-icon--danger { background: #fef2f2; color: #ef4444; }

.metric-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.metric-body span {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  text-transform: capitalize;
}

.metric-body strong {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  margin: 6px 0 4px;
  color: #0f172a;
}

.metric-body .trend {
  font-size: 11px;
  font-weight: 700;
}

.metric-body .trend.positive {
  color: #10b981;
}

.metric-body .action-link {
  font-size: 11px;
  font-weight: 600;
  color: #3b82f6;
  text-decoration: underline;
}

.clickable-metric:hover .action-link {
  color: #2563eb;
}

/* ===== COMMAND ROW ===== */
.command-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.select-box {
  min-width: 200px;
  flex: 1;
}

.select-box span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

input,
select,
textarea {
  width: 100%;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  min-height: 42px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px rgba(26, 58, 110, 0.12);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

/* Form Grid & Dialog Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-grid label span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

/* Input Suffix */
.input-suffix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-suffix-wrap input {
  padding-right: 60px;
}

.input-suffix {
  position: absolute;
  right: 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--faint);
  pointer-events: none;
  text-transform: uppercase;
}

/* Buttons */
.primary-btn,
.secondary-btn,
.icon-btn {
  border-radius: var(--radius-sm);
  min-height: 40px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-size: 13.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.primary-btn {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.primary-btn:hover {
  background: var(--brand-ink);
  border-color: var(--brand-ink);
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(26, 58, 110, 0.2);
}

.primary-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
}

.secondary-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-subtle);
  color: var(--ink);
  transform: translateY(-1px);
}

.secondary-btn.compact {
  min-height: 32px;
  padding-inline: 12px;
  font-size: 12px;
}

.icon-btn {
  width: 40px;
  padding: 0;
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
}

.icon-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-subtle);
  color: var(--ink);
}

.btn-icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

/* View Sections list */
.view-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ===== TABLE PANEL ===== */
.table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.panel-heading-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 800;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.table-wrap {
  overflow-x: auto;
  scrollbar-width: thin;
}

table {
  width: 100%;
  min-width: 1000px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.supplier-table {
  min-width: 800px;
}

th, td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: middle;
  font-size: 13.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

th {
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: #f8fafc;
}

tbody tr.selected {
  background: #ecfdf5;
}

tbody tr.selected:hover {
  background: #d1fae5;
}

/* Columns widths */
.col-article { width: 20%; }
.col-nature { width: 15%; }
.col-supplier { width: 17%; }
.col-stock { width: 10%; }
.col-assign { width: 15%; }
.col-expiry { width: 11%; }
.col-actions { width: 12%; }

.col-supplier-name { width: 22%; }
.col-phone { width: 14%; }
.col-address { width: 22%; }
.col-email { width: 17%; }
.col-count { width: 13%; }

.primary-cell strong {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
}

.subtext {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 4px;
  font-weight: 500;
}

.internal-order {
  color: var(--brand-ink);
  font-weight: 650;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 11.5px;
  font-weight: 700;
  background: #e2e8f0;
  color: #475569;
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
  border: 1px solid transparent;
}

.nature-badge {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

.stock-ok {
  background: #ecfdf5;
  color: #065f46;
  border-color: rgba(5, 150, 105, 0.15);
}

.stock-low {
  background: #fef2f2;
  color: #991b1b;
  border-color: rgba(220, 38, 38, 0.15);
}

.discharge {
  background: #fffbeb;
  color: #92400e;
  border-color: rgba(217, 119, 6, 0.15);
  margin-top: 4px;
}

.expiry-date {
  background: #ecfdf5;
  color: #065f46;
  border-color: rgba(5, 150, 105, 0.15);
}

.expiry-missing {
  background: #fef2f2;
  color: #991b1b;
  border-color: rgba(220, 38, 38, 0.15);
}

.status-ok {
  background: #ecfdf5;
  color: #065f46;
  border-color: rgba(5, 150, 105, 0.15);
}

.status-alert {
  background: #fffbeb;
  color: #92400e;
  border-color: rgba(217, 119, 6, 0.15);
}

/* Row Actions */
.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-action {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: var(--surface);
  color: #64748b;
  padding: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.row-action svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row-action:hover {
  background: var(--brand-soft);
  border-color: rgba(26, 58, 110, 0.25);
  color: var(--brand);
  transform: translateY(-1px);
}

.danger-action:hover {
  background: var(--red-bg);
  border-color: rgba(220, 38, 38, 0.25);
  color: var(--red);
}

/* ===== EMPTY STATES ===== */
.table-empty {
  padding: 60px 24px;
  text-align: center;
}

.empty-illustration {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  color: var(--faint);
}

.empty-illustration svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.5;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 8px;
}

.empty-desc {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0;
}

/* ===== DETAIL PANEL (Slide-out Read-Only) ===== */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(460px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.detail-panel.open {
  transform: translateX(0);
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.detail-panel-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  scrollbar-width: thin;
}

.detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  border-bottom: 1.5px solid var(--line);
  padding-bottom: 16px;
}

.detail-title-row h3 {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}

.detail-field {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.detail-field.full {
  grid-column: 1 / -1;
}

.detail-field span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.detail-field strong {
  display: block;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 600;
  color: var(--ink);
}

/* ===== DIALOG DRAWER OVERLAYS (Centered styling or slide-outs) ===== */
.drawer-dialog {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  width: min(520px, 100vw);
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
}

.drawer-dialog[open] {
  transform: translateX(0);
  display: flex;
}

.drawer-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.drawer-dialog[open]::backdrop {
  opacity: 1;
}

.drawer-dialog form,
.drawer-dialog .dialog-panel {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.drawer-dialog .dialog-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}

.drawer-dialog .dialog-header h2 {
  font-size: 20px;
  font-weight: 800;
}

/* Dialog Tabs */
.dialog-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  background: #f8fafc;
}

.tab-btn {
  background: transparent;
  border: 0;
  padding: 14px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2.5px solid transparent;
  transition: all 0.2s ease;
}

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

.tab-btn:hover:not(.active) {
  color: var(--ink);
}

.tab-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.drawer-dialog .dialog-actions {
  padding: 18px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0;
}

.actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Special calendar icons in inputs */
input[type="date"] {
  position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* ===== REPORT VIEWS ===== */
.reports-placeholder {
  padding: 24px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.chart-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 18px;
}

.bar-chart-visual {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-row .label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  width: 140px;
}

.bar-row .bar-fill {
  height: 12px;
  background: var(--brand);
  border-radius: 6px;
}

.bar-row .value {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  margin-left: auto;
}

.trend-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.sparkline {
  width: 100%;
  max-width: 240px;
  height: 80px;
}

.trend-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-align: center;
}

/* ===== SETTINGS VIEWS ===== */
.settings-form-wrap {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-group h3 {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  border-bottom: 1.5px solid var(--line);
  padding-bottom: 8px;
}

.toggle-setting {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-setting input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}

.toggle-setting span {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 500;
  max-width: min(400px, calc(100vw - 48px));
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--brand-ink);
  color: #ffffff;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastEnter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastEnter {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* ===== LOADING ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease-out;
}

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

.loading-overlay span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3.5px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== RESPONSIVE STYLING ===== */
@media (max-width: 1100px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .hamburger-btn {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .workspace {
    padding: 20px 24px;
  }
}

@media (max-width: 768px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .topbar {
    padding: 10px 16px;
    gap: 12px;
  }

  .topbar-search-wrap {
    max-width: 220px;
  }

  .user-details {
    display: none;
  }
}

@media (max-width: 480px) {
  .metrics {
    grid-template-columns: 1fr;
  }

  .topbar-search-wrap {
    display: none;
  }
}
