/* ═══════════════════════════════════════════════════════
   WMS — Design System  (tema viola moderno)
   ═══════════════════════════════════════════════════════ */

/* ── TOKENS ─────────────────────────────────────────── */
:root {
  /* Background */
  --c-bg:            #f4f2fa;
  --c-surface:       #ffffff;
  --c-surface-2:     #f9f7fd;
  --c-surface-raise: #ffffff;

  /* Borders */
  --c-border:        #e4dff2;
  --c-border-2:      #ede9f6;

  /* Text */
  --c-text:          #13111e;
  --c-text-2:        #4a4468;
  --c-text-3:        #9490b0;

  /* Accent — viola Apogeo */
  --c-accent:        #7c3aed;
  --c-accent-h:      #6d28d9;
  --c-accent-pale:   #f0e9ff;
  --c-accent-ring:   rgba(124, 58, 237, 0.2);

  /* Sidebar */
  --c-sidebar:       #0e0b1c;
  --c-sidebar-2:     #160f2e;
  --c-sidebar-3:     #1e1640;
  --c-sidebar-text:  #e8e3f8;
  --c-sidebar-muted: #6e6494;
  --c-sidebar-line:  #221a3e;

  /* Semantic */
  --c-ok:            #0d8a56;
  --c-ok-pale:       #e8f8f1;
  --c-warn:          #c27a00;
  --c-warn-pale:     #fef8e8;
  --c-danger:        #d63031;
  --c-danger-pale:   #ffeef0;
  --c-info:          #0969da;
  --c-info-pale:     #dff0ff;

  /* Movement types */
  --c-inbound:       #0d8a56;
  --c-inbound-pale:  #e8f8f1;
  --c-outbound:      #d63031;
  --c-outbound-pale: #ffeef0;
  --c-transfer:      #0969da;
  --c-transfer-pale: #dff0ff;
  --c-adjustment:    #7c3aed;
  --c-adjustment-pale: #f0e9ff;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Radius */
  --r-xs:   6px;
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   18px;
  --r-xl:   24px;
  --r-full: 9999px;

  /* Shadows */
  --sh-xs:   0 1px 3px rgba(30, 10, 60, 0.07);
  --sh-sm:   0 2px 8px rgba(30, 10, 60, 0.08), 0 0 0 1px rgba(30, 10, 60, 0.04);
  --sh-md:   0 4px 20px rgba(30, 10, 60, 0.10), 0 0 0 1px rgba(30, 10, 60, 0.04);
  --sh-lg:   0 8px 40px rgba(30, 10, 60, 0.14);
  --sh-drawer: -6px 0 48px rgba(14, 11, 28, 0.22);

  /* Layout */
  --sidebar-w:  252px;
  --topbar-h:   56px;

  /* Typography */
  --ff-sans:  "IBM Plex Sans", "Segoe UI", sans-serif;
  --ff-head:  "Space Grotesk", "IBM Plex Sans", sans-serif;
  --ff-mono:  "IBM Plex Mono", "Fira Code", monospace;

  /* Transitions */
  --t-fast:   100ms ease;
  --t-mid:    180ms ease;
  --t-slow:   280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--ff-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--c-text);
  background-color: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--ff-head);
  line-height: 1.15;
}

p { margin: 0; }
a { color: inherit; text-decoration: none; }

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

/* ── APP LAYOUT ──────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh;
  overflow: hidden;
}

.main-wrap {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  min-width: 0;
  overflow: hidden;
  background: var(--c-bg);
}

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--c-sidebar);
  height: 100dvh;
  overflow: hidden;
  position: relative;
  z-index: 100;
  transition: transform var(--t-slow);
  border-right: 1px solid var(--c-sidebar-line);
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--c-sidebar-line);
  flex-shrink: 0;
}

.sb-logomark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #9f5ffa 0%, var(--c-accent) 100%);
  color: #fff;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  letter-spacing: -0.02em;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.45);
}

.sb-logotype {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sb-logotype-main {
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 1rem;
  color: var(--c-sidebar-text);
  letter-spacing: 0.06em;
}

.sb-logotype-sub {
  font-size: 0.7rem;
  color: var(--c-sidebar-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sb-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--sp-3) var(--sp-2);
  gap: 2px;
  overflow-y: auto;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--c-sidebar-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
  position: relative;
  white-space: nowrap;
}

.sb-link:hover {
  color: var(--c-sidebar-text);
  background: var(--c-sidebar-3);
}

.sb-link.active {
  color: #fff;
  background: rgba(124, 58, 237, 0.18);
}

.sb-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--c-accent);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(124, 58, 237, 0.7);
}

.sb-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sb-badge {
  margin-left: auto;
  background: var(--c-accent);
  color: #fff;
  font-size: 0.68rem;
  font-family: var(--ff-head);
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-top: 1px solid var(--c-sidebar-line);
  flex-shrink: 0;
}

.sb-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #9f5ffa 0%, var(--c-accent) 100%);
  color: #fff;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-head);
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.sb-user-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sb-user-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-user-role {
  font-size: 0.7rem;
  color: var(--c-sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sb-user-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.sb-user-actions a {
  color: var(--c-sidebar-text);
  font-size: 0.74rem;
  text-decoration: none;
  opacity: 0.75;
  transition: opacity var(--t-fast);
}

.sb-user-actions a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Overlay (mobile) */
.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 11, 28, 0.6);
  z-index: 90;
  backdrop-filter: blur(4px);
}

/* ── TOPBAR ──────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  height: var(--topbar-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.topbar-menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  padding: 6px;
  border-radius: var(--r-xs);
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-menu span {
  display: block;
  height: 2px;
  background: var(--c-text);
  border-radius: 2px;
  transition: transform var(--t-mid), opacity var(--t-mid);
}

.topbar-title {
  flex: 1;
  font-family: var(--ff-head);
  font-weight: 600;
  font-size: 1rem;
  color: var(--c-text);
}

.topbar-cart {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 14px;
  border-radius: var(--r-full);
  background: var(--c-accent-pale);
  color: var(--c-accent);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  flex-shrink: 0;
}

.topbar-cart:hover {
  background: var(--c-accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.35);
}

/* ── VIEW ────────────────────────────────────────────── */
.view {
  overflow-y: auto;
  padding: var(--sp-6);
  scroll-behavior: smooth;
}

/* ── PAGE STRUCTURES ─────────────────────────────────── */
.page-header {
  margin-bottom: var(--sp-6);
}

.page-title {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--c-text);
}

.page-subtitle {
  margin-top: var(--sp-1);
  color: var(--c-text-3);
  font-size: 0.875rem;
}

/* ── KPI CARDS ───────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.kpi-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  box-shadow: var(--sh-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  transition: box-shadow var(--t-mid), transform var(--t-mid);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--c-accent) 0%, #a855f7 100%);
  opacity: 0;
  transition: opacity var(--t-mid);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.kpi-card:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-2px);
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-text-3);
}

.kpi-value {
  font-family: var(--ff-head);
  font-size: 2.3rem;
  font-weight: 700;
  line-height: 1;
  color: var(--c-text);
  letter-spacing: -0.03em;
}

.kpi-card[data-mod="warn"] .kpi-value    { color: var(--c-warn); }
.kpi-card[data-mod="danger"] .kpi-value  { color: var(--c-danger); }
.kpi-card[data-mod="ok"] .kpi-value      { color: var(--c-ok); }
.kpi-card[data-mod="accent"] .kpi-value  { color: var(--c-accent); }

.kpi-hint {
  font-size: 0.75rem;
  color: var(--c-text-3);
  margin-top: var(--sp-1);
}

/* ── PANELS ──────────────────────────────────────────── */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  margin-bottom: var(--sp-5);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border-2);
  background: var(--c-surface-2);
}

.panel-title {
  font-family: var(--ff-head);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.panel-body {
  padding: var(--sp-5);
}

.panel-body + .panel-body {
  border-top: 1px solid var(--c-border-2);
}

.two-col {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: var(--sp-5);
}

/* ── TABLES ──────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

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

thead th {
  padding: 10px var(--sp-4);
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--c-text-3);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface-2);
  white-space: nowrap;
}

tbody td {
  padding: 11px var(--sp-4);
  border-bottom: 1px solid var(--c-border-2);
  vertical-align: middle;
  font-size: 0.875rem;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--c-accent-pale); }

tbody tr.clickable { cursor: pointer; }

.mono {
  font-family: var(--ff-mono);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

/* ── PILLS / BADGES ──────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pill-inbound    { background: var(--c-inbound-pale);    color: var(--c-inbound); }
.pill-outbound   { background: var(--c-outbound-pale);   color: var(--c-outbound); }
.pill-transfer   { background: var(--c-transfer-pale);   color: var(--c-transfer); }
.pill-adjustment { background: var(--c-adjustment-pale); color: var(--c-adjustment); }

.pill-ok      { background: var(--c-ok-pale);     color: var(--c-ok); }
.pill-warn    { background: var(--c-warn-pale);   color: var(--c-warn); }
.pill-danger  { background: var(--c-danger-pale); color: var(--c-danger); }
.pill-neutral { background: var(--c-surface-2);  color: var(--c-text-2); border: 1px solid var(--c-border); }

.stock-qty {
  font-family: var(--ff-head);
  font-weight: 600;
  font-size: 0.9rem;
}
.stock-qty.ok     { color: var(--c-ok); }
.stock-qty.warn   { color: var(--c-warn); }
.stock-qty.danger { color: var(--c-danger); }

/* ── FORMS ───────────────────────────────────────────── */
.form-grid {
  display: grid;
  gap: var(--sp-4);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--sp-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-text-2);
  letter-spacing: 0.02em;
}

.field-label .req {
  color: var(--c-accent);
  margin-left: 2px;
}

.field-hint {
  font-size: 0.72rem;
  color: var(--c-text-3);
}

input[type="text"],
input[type="number"],
input[type="search"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 9px var(--sp-3);
  background: var(--c-surface-raise);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text);
  font: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-ring);
}

input[required]:valid:not(:placeholder-shown) {
  border-color: var(--c-border);
}

input.error,
select.error {
  border-color: var(--c-danger);
  box-shadow: 0 0 0 3px rgba(214, 48, 49, 0.15);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239490b0' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

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

/* Ticket field transition */
.ticket-field {
  transition: opacity var(--t-mid), max-height var(--t-mid);
  overflow: hidden;
}

.ticket-field.hidden-field {
  opacity: 0;
  max-height: 0;
  pointer-events: none;
}

.ticket-field.visible-field {
  opacity: 1;
  max-height: 100px;
}

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 9px var(--sp-4);
  border-radius: var(--r-sm);
  border: 1.5px solid transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform 80ms ease;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--c-accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
  background: var(--c-accent-h);
  box-shadow: 0 3px 12px rgba(124, 58, 237, 0.4);
}

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text-2);
  border-color: var(--c-border);
}

.btn-secondary:hover {
  background: var(--c-accent-pale);
  border-color: var(--c-accent);
  color: var(--c-accent);
}

.btn-ghost {
  background: transparent;
  color: var(--c-text-3);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}

.btn-danger {
  background: var(--c-danger-pale);
  color: var(--c-danger);
  border-color: transparent;
}

.btn-danger:hover {
  background: var(--c-danger);
  color: #fff;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: var(--r-xs);
}

.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  flex-shrink: 0;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Search bar */
.search-bar {
  display: flex;
  gap: var(--sp-2);
  align-items: stretch;
}

.search-bar input {
  flex: 1;
}

/* ── EMPTY STATES ────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-8);
  text-align: center;
  gap: var(--sp-3);
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--c-accent);
  opacity: 0.35;
}

.empty-title {
  font-family: var(--ff-head);
  font-weight: 600;
  font-size: 1rem;
  color: var(--c-text-2);
}

.empty-text {
  font-size: 0.85rem;
  color: var(--c-text-3);
  max-width: 36ch;
}

/* ── LOADING ─────────────────────────────────────────── */
.view-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--c-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.inline-loading {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--c-text-3);
  font-size: 0.85rem;
  padding: var(--sp-4);
}

/* ── ALERT BANDS ─────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-5);
  font-size: 0.875rem;
}

.alert-warn  { background: var(--c-warn-pale);   color: var(--c-warn);   border: 1px solid rgba(194, 122, 0, 0.2); }
.alert-danger{ background: var(--c-danger-pale); color: var(--c-danger); border: 1px solid rgba(214, 48, 49, 0.2); }
.alert-ok    { background: var(--c-ok-pale);     color: var(--c-ok);     border: 1px solid rgba(13, 138, 86, 0.2); }
.alert-info  { background: var(--c-info-pale);   color: var(--c-info);   border: 1px solid rgba(9, 105, 218, 0.2); }

.alert svg { flex-shrink: 0; margin-top: 1px; }

/* ── DRAWER ──────────────────────────────────────────── */
.drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(620px, 100vw);
  background: var(--c-surface);
  box-shadow: var(--sh-drawer);
  transform: translateX(100%);
  transition: transform var(--t-slow);
  z-index: 200;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

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

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 11, 28, 0.5);
  backdrop-filter: blur(4px);
  z-index: 190;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow);
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.drawer-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.drawer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  background: var(--c-surface);
  z-index: 10;
}

.drawer-topbar-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-accent);
}

.drawer-section {
  padding: var(--sp-5) var(--sp-5) 0;
}

.drawer-section + .drawer-section {
  padding-top: var(--sp-5);
  border-top: 1px solid var(--c-border-2);
  margin-top: var(--sp-5);
}

.drawer-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-text-3);
  margin-bottom: var(--sp-3);
}

.product-hero {
  padding: var(--sp-6) var(--sp-5);
  border-bottom: 1px solid var(--c-border);
  background: linear-gradient(160deg, var(--c-accent-pale) 0%, var(--c-surface) 100%);
}

.product-hero-pn {
  font-family: var(--ff-mono);
  font-size: 0.78rem;
  color: var(--c-accent);
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-2);
  background: var(--c-accent-pale);
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-full);
}

.product-hero-name {
  font-family: var(--ff-head);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.2;
  margin-bottom: var(--sp-3);
}

.product-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  font-size: 0.82rem;
  color: var(--c-text-2);
}

.product-hero-meta span { display: flex; gap: 5px; align-items: center; }
.product-hero-meta strong { color: var(--c-text); font-weight: 600; }

.product-stock-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.product-total-qty {
  font-family: var(--ff-head);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.product-total-qty.ok     { color: var(--c-ok); }
.product-total-qty.warn   { color: var(--c-warn); }
.product-total-qty.danger { color: var(--c-danger); }

/* Accordion for serials */
.accordion-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  color: var(--c-text-2);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
}

.accordion-toggle svg {
  transition: transform var(--t-mid);
}

.accordion-toggle.open svg {
  transform: rotate(90deg);
}

.accordion-body {
  display: none;
  margin-top: var(--sp-3);
}

.accordion-body.open {
  display: block;
}

/* Movement type tabs */
.type-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--c-bg);
  border-radius: var(--r-md);
  border: 1.5px solid var(--c-border);
}

.type-tab {
  flex: 1;
  padding: 8px var(--sp-3);
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text-3);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  text-align: center;
  white-space: nowrap;
}

.type-tab:hover {
  background: var(--c-surface);
  color: var(--c-text);
}

.type-tab.active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--sh-xs);
  font-weight: 600;
}

.type-tab[data-type="outbound"].active  { color: var(--c-outbound); }
.type-tab[data-type="inbound"].active   { color: var(--c-inbound); }
.type-tab[data-type="transfer"].active  { color: var(--c-transfer); }
.type-tab[data-type="adjustment"].active { color: var(--c-accent); }

/* Cart rows */
.cart-rows {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.cart-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 80px 120px 36px;
  gap: var(--sp-2);
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  transition: box-shadow var(--t-fast), border-color var(--t-fast);
}

.cart-row:hover {
  box-shadow: var(--sh-xs);
  border-color: var(--c-accent);
}

.cart-row-num {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text-3);
  margin-bottom: var(--sp-1);
}

/* Cart row labels (mobile) */
.row-label {
  display: none;
  font-size: 0.7rem;
  color: var(--c-text-3);
  margin-bottom: 2px;
}

.cart-confirm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  margin-top: var(--sp-5);
}

.cart-summary-text {
  font-size: 0.875rem;
  color: var(--c-text-2);
}

.cart-summary-text strong {
  color: var(--c-text);
  font-family: var(--ff-head);
  font-size: 1.05rem;
}

/* Warehouse filter tabs */
.wh-filter {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.wh-tab {
  padding: 5px 14px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-full);
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--c-text-2);
  cursor: pointer;
  transition: all var(--t-fast);
}

.wh-tab:hover {
  border-color: var(--c-accent);
  color: var(--c-accent);
  background: var(--c-accent-pale);
}

.wh-tab.active {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

/* Ticket validation state */
.ticket-validate-status {
  font-size: 0.78rem;
  margin-top: var(--sp-1);
}

.ticket-validate-status.ok     { color: var(--c-ok); }
.ticket-validate-status.error  { color: var(--c-danger); }
.ticket-validate-status.loading{ color: var(--c-text-3); }

/* Form feedback (success) */
.form-success {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--c-ok-pale);
  border: 1px solid rgba(13, 138, 86, 0.2);
  border-radius: var(--r-md);
  color: var(--c-ok);
  font-size: 0.875rem;
  font-weight: 500;
}

/* ── TOAST ───────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  z-index: 500;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  min-width: 260px;
  max-width: 380px;
  background: var(--c-sidebar);
  color: var(--c-sidebar-text);
  box-shadow: 0 6px 24px rgba(14, 11, 28, 0.3), 0 0 0 1px rgba(124, 58, 237, 0.15);
  font-size: 0.85rem;
  pointer-events: all;
  animation: toastIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.toast.toast-ok      { border-left: 3px solid var(--c-ok); }
.toast.toast-error   { border-left: 3px solid var(--c-danger); }
.toast.toast-warn    { border-left: 3px solid var(--c-warn); }
.toast.toast-info    { border-left: 3px solid var(--c-accent); }

.toast-msg { flex: 1; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(4px); height: 0; margin: 0; padding: 0; }
}

.toast.removing {
  animation: toastOut 0.2s ease forwards;
}

/* ── DIVIDER ─────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--c-border-2);
  margin: var(--sp-5) 0;
}

/* ── UTIL ────────────────────────────────────────────── */
.flex-gap { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.ml-auto  { margin-left: auto; }
.mt-4     { margin-top: var(--sp-4); }
.mt-5     { margin-top: var(--sp-5); }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }

  .cart-row {
    grid-template-columns: 1fr 1fr 80px 36px;
    grid-template-rows: auto auto;
  }
}

@media (max-width: 768px) {
  /* Sidebar goes off-screen */
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    z-index: 300;
  }

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

  .sb-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-slow);
  }

  .sb-overlay.open {
    opacity: 1;
    pointer-events: all;
  }

  .topbar-menu { display: flex; }

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

  .view { padding: var(--sp-4); }

  .cart-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "pn pn"
      "wh loc"
      "qty serial"
      "del del";
    gap: var(--sp-2);
  }

  .row-label { display: block; }

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

  .cart-confirm-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .type-tabs {
    flex-wrap: wrap;
  }
}

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