/* ============================================================
   main.css — Ziora Pharmaceutical Procurement Portal v4.0
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --brand-dark:      #1B3A6B;
  --brand-mid:       #2756A8;
  --brand-light:     #EBF1FB;
  --brand-accent:    #F0A500;

  /* Neutrals */
  --bg:              #F4F6FA;
  --surface:         #FFFFFF;
  --surface-2:       #F8F9FC;
  --border:          #E2E6EF;
  --border-strong:   #C8CEDC;

  /* Text */
  --text-primary:    #1A1F2E;
  --text-secondary:  #5A6478;
  --text-muted:      #9BA3B5;
  --text-on-brand:   #FFFFFF;

  /* Status */
  --green:           #1A8A4A;
  --green-bg:        #E6F7ED;
  --red:             #C0392B;
  --red-bg:          #FDECEA;
  --amber:           #B45309;
  --amber-bg:        #FEF3C7;
  --blue:            #1D4ED8;
  --blue-bg:         #EFF6FF;
  --purple:          #6D28D9;
  --purple-bg:       #EDE9FE;

  /* Layout */
  --sidebar-w:       220px;
  --header-h:        56px;
  --panel-w:         400px;
  --radius:          8px;
  --radius-lg:       12px;
  --shadow:          0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:       0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.16);

  /* Type */
  --font:            'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:       'JetBrains Mono', 'Fira Code', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-mid); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font); }

/* ── Login Screen ─────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-mid) 100%);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 4px;
}

.login-logo p {
  font-size: 12px;
  color: var(--text-muted);
}

.login-card .form-group { margin-bottom: 16px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.login-card input { width: 100%; }

#login-error {
  color: var(--red);
  font-size: 12px;
  margin-bottom: 12px;
  min-height: 16px;
}

#login-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
}

/* ── App Shell ────────────────────────────────────────────── */
#app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--brand-dark);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h2 {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.sidebar-brand span {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  font-weight: 400;
}

#sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}

.nav-active {
  background: rgba(255,255,255,0.12) !important;
  color: #fff !important;
  border-left-color: var(--brand-accent) !important;
}

.nav-icon { font-size: 15px; width: 20px; text-align: center; }

#user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 10px; color: rgba(255,255,255,0.45); text-transform: capitalize; }

.signout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

.signout-btn:hover { color: #fff; }

/* ── Main Area ────────────────────────────────────────────── */
#main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#top-bar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}

#page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  position: relative;
}

/* ── Module Header ────────────────────────────────────────── */
.module-header {
  margin-bottom: 20px;
}

.module-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.module-title-row h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.module-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Stats Bar ────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
}

.stat-chip.accent { border-color: var(--brand-mid); background: var(--brand-light); }
.stat-chip.warn { border-color: var(--amber); background: var(--amber-bg); }

.stat-num { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.stat-label { color: var(--text-secondary); }

/* ── Search & Filters ─────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  font-size: 13px;
  pointer-events: none;
}

.search-input {
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  width: 280px;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.15s;
}

.search-input:focus { outline: none; border-color: var(--brand-mid); }

.filter-select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
}

.filter-select:focus { outline: none; border-color: var(--brand-mid); }

/* ── Table ────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--brand-mid); }

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr.row-selected { background: var(--brand-light) !important; }
.data-table tbody tr.row-overdue { background: var(--red-bg); }
.data-table tbody tr.row-merged { opacity: 0.55; }
.data-table tbody tr { cursor: pointer; transition: background 0.1s; }

/* ── Name Cells ───────────────────────────────────────────── */
.rm-name-cell, .cs-name-cell, .vendor-name-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rm-name, .cs-name, .vendor-name { font-weight: 600; color: var(--text-primary); }
.rm-grade, .cs-composition, .vendor-city { font-size: 11px; color: var(--text-muted); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-active      { background: var(--green-bg);   color: var(--green); }
.badge-inactive    { background: #F1F3F7;            color: var(--text-secondary); }
.badge-merged      { background: var(--purple-bg);   color: var(--purple); }
.badge-new         { background: var(--blue-bg);     color: var(--blue); }
.badge-confirmed   { background: var(--amber-bg);    color: var(--amber); }
.badge-inprod      { background: var(--purple-bg);   color: var(--purple); }
.badge-dispatched  { background: #FFF0E0;            color: #C05000; }
.badge-primary     { background: var(--brand-light); color: var(--brand-mid); font-size: 10px; }

/* ── Type Pills ───────────────────────────────────────────── */
.type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.type-api       { background: #E0F2FF; color: #0369A1; }
.type-excipient { background: #F0FDF4; color: #166534; }
.type-solvent   { background: #FFF7ED; color: #C2410C; }
.type-coating   { background: var(--purple-bg); color: var(--purple); }
.type-other     { background: #F1F3F7; color: var(--text-secondary); }
.type-rm        { background: #E0F2FF; color: #0369A1; }
.type-pm        { background: #F0FDF4; color: #166534; }
.type-both      { background: var(--amber-bg); color: var(--amber); }
.type-service   { background: #F1F3F7; color: var(--text-secondary); }

/* ── Rate Cells ───────────────────────────────────────────── */
.rate-cell { display: flex; align-items: baseline; gap: 3px; }
.rate-cash { font-weight: 600; color: var(--text-primary); }
.rate-label { font-size: 10px; color: var(--text-muted); }
.rate-display small { font-size: 10px; color: var(--text-muted); margin-left: 2px; }
.no-rate, .no-vendor, .no-linked, .no-ing, .no-contact, .no-type { color: var(--text-muted); font-size: 12px; }
.vendor-count, .linked-count, .ing-count { font-size: 12px; color: var(--brand-mid); font-weight: 500; }

/* ── Order / PO specific ──────────────────────────────────── */
.order-num { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--brand-dark); }
.batch-size { font-family: var(--font-mono); font-size: 12px; }
.overdue-date { color: var(--red); font-weight: 600; }
.seq-num { color: var(--text-muted); font-size: 11px; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.page-btns { display: flex; align-items: center; gap: 8px; }
.page-btns button {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-primary);
  transition: background 0.15s;
}
.page-btns button:hover:not(:disabled) { background: var(--surface-2); }
.page-btns button:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { color: var(--text-muted); }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }

/* ── Skeleton Loading ─────────────────────────────────────── */
.skeleton-row td { padding: 12px 14px; }
.skeleton-cell {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #EEF0F5 25%, #F8F9FC 50%, #EEF0F5 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

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

/* ── Side Panel ───────────────────────────────────────────── */
.side-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  width: var(--panel-w);
  height: calc(100vh - var(--header-h));
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.side-panel.panel-open { transform: translateX(0); }
.panel-placeholder { padding: 32px; color: var(--text-muted); font-size: 13px; text-align: center; margin-top: 40px; }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title-block { flex: 1; min-width: 0; }
.panel-title-block h3 { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; }
.panel-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.panel-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.panel-grade, .version-chip { font-size: 11px; color: var(--text-secondary); background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }

.panel-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  margin-left: 8px;
  flex-shrink: 0;
}
.panel-close:hover { background: var(--surface-2); color: var(--text-primary); }

/* Panel tabs */
.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
  overflow-x: auto;
}

.ptab {
  padding: 10px 14px;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s;
}

.ptab:hover { color: var(--text-primary); }
.ptab.active { color: var(--brand-mid); border-bottom-color: var(--brand-mid); font-weight: 600; }
.tab-count { font-size: 10px; background: var(--border); border-radius: 10px; padding: 1px 5px; margin-left: 4px; }

.panel-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.ptab-content { display: none; }
.ptab-content.active { display: block; }

/* Detail grid in panel */
.detail-grid { display: flex; flex-direction: column; gap: 0; margin-bottom: 16px; }
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row > span:first-child { color: var(--text-secondary); font-size: 12px; flex-shrink: 0; }
.detail-row > span:last-child { text-align: right; color: var(--text-primary); }
.detail-row.full-row { flex-direction: column; gap: 4px; }
.detail-row.full-row > span:last-child { text-align: left; }
.detail-row.highlight { background: var(--surface-2); margin: 0 -4px; padding: 8px 4px; border-radius: 4px; }
.detail-row.highlight.accent span:last-child { color: var(--brand-mid); font-weight: 700; }
.detail-row.warn-row span { color: var(--amber); }

.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border); margin-top: 4px; }

/* Rates table in panel */
.rates-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.rates-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.rates-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; margin-bottom: 6px; }

.rates-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rates-table th { text-align: left; padding: 6px 8px; font-size: 11px; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.rates-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.rates-table tbody tr:last-child td { border-bottom: none; }
.rates-table tfoot td { font-weight: 600; background: var(--surface-2); padding: 8px; }

.preferred-rate-row td { background: #FFFBF0; }
.rm-linked { color: var(--green); font-size: 11px; }
.empty-rates { padding: 24px; text-align: center; color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.existing-rates-note { margin-top: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 6px; font-size: 12px; color: var(--text-secondary); }

/* Contacts */
.contact-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.contact-card.contact-primary { border-color: var(--brand-mid); background: var(--brand-light); }
.contact-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.designation { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
.contact-phones, .contact-emails { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }

/* Drug licence cards */
.dl-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.dl-card.dl-expired { border-color: var(--red); background: var(--red-bg); }
.dl-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.dl-meta { display: flex; gap: 12px; font-size: 11px; color: var(--text-secondary); flex-wrap: wrap; }

/* Upload rows */
.upload-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.upload-row:last-child { border-bottom: none; }
.upload-info { display: flex; flex-direction: column; gap: 2px; }
.upload-name { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.upload-type { font-size: 11px; color: var(--text-muted); }
.upload-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.upload-date, .upload-size, .upload-stats { font-size: 11px; color: var(--text-muted); }

/* Variant cards */
.variant-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.variant-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.variant-grid { display: flex; flex-direction: column; gap: 0; }
.variant-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.variant-row:last-child { border-bottom: none; }
.variant-row.highlight { background: var(--surface-2); margin: 0 -4px; padding: 5px 4px; font-weight: 500; }
.variant-row.highlight.accent span:last-child { color: var(--brand-mid); font-weight: 700; font-size: 13px; }
.variant-preview-box { background: var(--brand-light); border: 1px solid var(--brand-mid); border-radius: var(--radius); padding: 10px 14px; margin-top: 8px; }
.preview-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.preview-row.accent span:last-child { color: var(--brand-mid); font-weight: 700; }
.calc-preview { font-size: 12px; background: var(--surface-2); border-radius: 6px; padding: 6px 10px; margin-bottom: 8px; color: var(--text-secondary); }

/* Ingredient summary */
.ing-summary { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); padding: 8px 0; margin-bottom: 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }

/* Mapping rules */
.mapping-help { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.5; }

/* Status update panel */
.status-update-panel { padding: 4px 0; }
.status-steps { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 12px 0; }
.status-step-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 11px;
  background: var(--surface);
  color: var(--text-secondary);
  transition: all 0.15s;
  text-transform: capitalize;
}
.status-step-btn:hover { border-color: var(--brand-mid); color: var(--brand-mid); }
.status-current { background: var(--brand-mid) !important; color: #fff !important; border-color: var(--brand-mid) !important; font-weight: 600; }
.status-done { background: var(--green-bg) !important; color: var(--green) !important; border-color: var(--green) !important; }

/* ── Main Tab Group ────────────────────────────────────────── */
.main-tab-group { display: flex; gap: 4px; }
.main-tab-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.main-tab-btn:hover { border-color: var(--brand-mid); color: var(--brand-mid); }
.main-tab-btn.active { background: var(--brand-mid); color: #fff; border-color: var(--brand-mid); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  padding: 8px 16px;
  background: var(--brand-mid);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  padding: 8px 16px;
  background: var(--surface);
  color: var(--brand-mid);
  border: 1px solid var(--brand-mid);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--brand-light); }

.btn-danger {
  padding: 8px 16px;
  background: var(--surface);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
}
.btn-danger:hover { background: var(--red-bg); }

.btn-warning {
  padding: 8px 16px;
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
}

.btn-ghost {
  padding: 8px 12px;
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  transition: all 0.15s;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }

.btn-sm { padding: 5px 10px !important; font-size: 12px !important; }
.btn-xs { padding: 3px 7px !important; font-size: 11px !important; }
.btn-ghost.btn-xs.danger { color: var(--red); border-color: transparent; }
.btn-ghost.btn-xs.danger:hover { background: var(--red-bg); border-color: var(--red); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.form-group label small { font-weight: 400; color: var(--text-muted); }

.form-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-primary);
  width: 100%;
  transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--brand-mid); box-shadow: 0 0 0 3px rgba(39,86,168,0.08); }
.form-input[readonly] { background: var(--surface-2); color: var(--text-secondary); }

.form-select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-primary);
  width: 100%;
  cursor: pointer;
}
.form-select:focus { outline: none; border-color: var(--brand-mid); }

textarea.form-input { resize: vertical; min-height: 60px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid-2 .full-span { grid-column: 1 / -1; }
.form-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; margin-bottom: 12px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }

.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-primary); cursor: pointer; font-weight: 400 !important; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 12px; }
.radio-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}

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

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}

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

.modal-closing { animation: fadeOut 0.2s ease forwards; }
@keyframes fadeOut { to { opacity: 0; } }

.modal-sm { max-width: 420px; }
.modal-md { max-width: 580px; }
.modal-lg { max-width: 740px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.modal-close { background: none; border: none; font-size: 16px; color: var(--text-muted); padding: 4px; border-radius: 4px; }
.modal-close:hover { background: var(--surface-2); color: var(--text-primary); }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.modal-info { font-size: 12px; color: var(--text-secondary); background: var(--surface-2); border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; line-height: 1.5; }

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  max-width: 360px;
  pointer-events: all;
  transform: translateX(120%);
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
}

.toast-visible { transform: translateX(0); opacity: 1; }
.toast-hiding  { transform: translateX(120%); opacity: 0; }

.toast-success { background: var(--green-bg);  color: var(--green);  border: 1px solid #A7F3D0; }
.toast-error   { background: var(--red-bg);    color: var(--red);    border: 1px solid #FECACA; }
.toast-warning { background: var(--amber-bg);  color: var(--amber);  border: 1px solid #FDE68A; }
.toast-info    { background: var(--blue-bg);   color: var(--blue);   border: 1px solid #BFDBFE; }

.toast-msg { flex: 1; }
.toast-close { background: none; border: none; font-size: 14px; cursor: pointer; opacity: 0.6; padding: 0; }
.toast-close:hover { opacity: 1; }

/* ── Error Banner ─────────────────────────────────────────── */
.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--red-bg);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--red);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Dashboard ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); border-color: var(--brand-mid); }
.kpi-icon { font-size: 24px; flex-shrink: 0; }
.kpi-num { font-size: 28px; font-weight: 700; color: var(--brand-dark); line-height: 1; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 4px 0 2px; }
.kpi-sub { font-size: 11px; color: var(--text-muted); }

.dash-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--amber);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dash-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.dash-card-header h4 { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.order-status-row { display: flex; gap: 10px; margin-bottom: 12px; }
.os-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}
.os-num { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.os-new { background: var(--blue-bg); color: var(--blue); }
.os-prod { background: var(--purple-bg); color: var(--purple); }

.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th { padding: 5px 8px; text-align: left; font-size: 10px; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); text-transform: uppercase; }
.mini-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.mini-table tbody tr:last-child td { border-bottom: none; }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.dot-create { background: var(--green); }
.dot-update { background: var(--brand-mid); }
.dot-delete { background: var(--red); }
.activity-body { flex: 1; min-width: 0; }
.activity-desc { display: block; font-size: 12px; color: var(--text-primary); }
.activity-meta { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.undone-label { font-size: 10px; color: var(--text-muted); background: var(--surface-2); border-radius: 4px; padding: 2px 6px; }

/* Dashboard view tabs */
.dash-view-tabs { display: flex; gap: 4px; }
.dash-view-tab {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.15s;
}
.dash-view-tab:hover { border-color: var(--brand-mid); color: var(--brand-mid); }
.dash-view-tab.active { background: var(--brand-mid); color: #fff; border-color: var(--brand-mid); }

/* Req banner */
.req-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--amber);
  margin-bottom: 14px;
}

/* Action log */
.log-undone td { opacity: 0.5; }
.strikethrough { text-decoration: line-through; }
.undone-meta { color: var(--text-muted); }

/* ── Warn text ─────────────────────────────────────────────── */
.warn-text { color: var(--red); }

/* ── Checkbox group ───────────────────────────────────────── */
.checkbox-group label { font-weight: 400 !important; }

/* ── Total row in tables ──────────────────────────────────── */
.total-row td { font-weight: 700; background: var(--surface-2); padding: 10px 8px; border-top: 2px solid var(--border); }

/* ── Misc utility ─────────────────────────────────────────── */
.no-type { color: var(--text-muted); font-size: 12px; }
.no-rate { color: var(--text-muted); font-size: 12px; }
.no-ing  { color: var(--text-muted); font-size: 12px; }
.page-info { color: var(--text-muted); font-size: 12px; }
.version-chip { font-size: 10px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 56px; --panel-w: 100vw; }

  .nav-label { display: none; }
  .sidebar-brand h2, .sidebar-brand span { display: none; }
  .sidebar-brand { padding: 14px 8px; }
  .nav-item { justify-content: center; padding: 12px 8px; }
  .user-info, .signout-btn { display: none; }
  #user-chip { justify-content: center; padding: 10px 8px; }

  .dash-row-2 { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-2 .full-span { grid-column: 1; }

  .search-input { width: 180px; }
  .module-toolbar { gap: 6px; }
}

@media (max-width: 600px) {
  #main-content { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .side-panel { top: 0; height: 100vh; }
}
