/* ═══════════════════════════════════════════════════════════════════════════
   AEROMYX ERP — DESIGN SYSTEM
   Fonts: Syne (headings) · DM Sans (body) · JetBrains Mono (data)
═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --bg:          #080F18;
  --surface:     #0D1825;
  --surface-2:   #121F30;
  --surface-3:   #172438;
  --sidebar:     #0E1C2B;
  --sidebar-2:   #132233;

  /* Borders */
  --border:      #182840;
  --border-2:    #1E3050;
  --border-3:    #243858;

  /* Brand */
  --teal:        #00897B;
  --teal-light:  #00BFA5;
  --teal-bright: #1DE9B6;
  --teal-dim:    rgba(0,137,123,0.12);
  --teal-dim2:   rgba(0,137,123,0.22);
  --teal-glow:   rgba(0,191,165,0.08);

  /* Text */
  --text:        #DCE9F5;
  --text-2:      #7A9CB8;
  --text-3:      #3D5E7A;
  --text-4:      #263D52;

  /* Status */
  --danger:      #F44336;
  --danger-dim:  rgba(244,67,54,0.12);
  --warning:     #FF8F00;
  --warning-dim: rgba(255,143,0,0.12);
  --success:     #43A047;
  --success-dim: rgba(67,160,71,0.12);
  --info:        #1E88E5;
  --info-dim:    rgba(30,136,229,0.12);

  /* Geometry */
  --radius:      7px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --shadow:      0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:   0 12px 48px rgba(0,0,0,0.7);

  /* Type */
  --font-head:   'Syne', sans-serif;
  --font-body:   'DM Sans', sans-serif;
  --font-mono:   'JetBrains Mono', monospace;

  /* Layout */
  --sidebar-w:   248px;
  --topbar-h:    54px;

  /* Motion */
  --t:           150ms ease;
  --t-slow:      280ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
strong { font-weight: 600; }
.hidden { display: none !important; }

/* ═══ SCROLLBARS ════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--teal-dim2); }

/* ═══ LAYOUT ════════════════════════════════════════════════════════════════ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ═══ SIDEBAR ═══════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform var(--t-slow);
  position: relative;
}

/* Faint vertical accent line */
.sidebar::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--teal-dim2) 30%, var(--teal-dim2) 70%, transparent);
  pointer-events: none;
}

.sidebar-header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-wordmark {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-3);
  padding: 4px;
  border-radius: 4px;
}
.sidebar-close:hover { color: var(--text-2); }

/* NAV */
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 14px 10px 5px;
  font-family: var(--font-mono);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 0.845rem;
  font-weight: 400;
  transition: all var(--t);
  margin-bottom: 1px;
  position: relative;
  border-left: 2px solid transparent;
}
.nav-item svg { flex-shrink: 0; opacity: 0.55; transition: opacity var(--t); }
.nav-item:hover { background: var(--teal-dim); color: var(--text); border-left-color: var(--teal-dim2); }
.nav-item:hover svg { opacity: 0.8; }
.nav-item.active {
  background: var(--teal-dim2);
  color: var(--teal-light);
  border-left-color: var(--teal);
  font-weight: 500;
}
.nav-item.active svg { opacity: 1; }

/* SIDEBAR FOOTER */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--teal-dim2);
  border: 1px solid var(--teal-dim2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--teal-light);
  flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-name {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: 0.68rem; color: var(--text-3); }
.logout-btn:hover { color: var(--danger) !important; background: var(--danger-dim) !important; }

/* ═══ MAIN AREA ══════════════════════════════════════════════════════════════ */
.main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  flex-shrink: 0;
}
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-3);
  padding: 6px;
  border-radius: var(--radius);
}
.hamburger:hover { background: var(--teal-dim); color: var(--teal-light); }

.breadcrumb {
  flex: 1;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
  background: var(--bg);
}

/* ═══ LOGIN SCREEN ═══════════════════════════════════════════════════════════ */
.login-screen {
  position: fixed; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: var(--bg);
}
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 60% at 20% 50%, rgba(0,137,123,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 80% 30%, rgba(0,191,165,0.04) 0%, transparent 60%);
  pointer-events: none;
}
.login-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,137,123,0.08);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.brand-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--text);
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--text-3);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  margin-top: 1px;
}
.login-heading {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}
.login-sub { color: var(--text-2); font-size: 0.84rem; margin-bottom: 28px; }

/* ═══ FORM ELEMENTS ══════════════════════════════════════════════════════════ */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}

.field input,
.field select,
.field textarea,
select.f-select,
input.f-input {
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 8px 11px;
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font-body);
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
  line-height: 1.4;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-dim);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-4); }
.field textarea { resize: vertical; min-height: 72px; }
.field select { appearance: none; cursor: pointer; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-error {
  color: var(--danger);
  font-size: 0.78rem;
  margin-bottom: 12px;
  padding: 8px 11px;
  background: var(--danger-dim);
  border-radius: var(--radius);
  border: 1px solid rgba(244,67,54,0.2);
}

/* ═══ BUTTONS ════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.845rem;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  transition: all var(--t);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,137,123,0.3);
}
.btn-primary:hover { background: var(--teal-light); box-shadow: 0 4px 16px rgba(0,191,165,0.4); }
.btn-secondary {
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { border-color: var(--border-3); color: var(--text); background: var(--surface-2); }
.btn-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(244,67,54,0.25); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: none; color: var(--text-2); border: none; }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-full { width: 100%; }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-3);
  padding: 5px;
  border-radius: 5px;
  transition: all var(--t);
}
.btn-icon:hover { background: var(--teal-dim); color: var(--teal-light); }

/* ═══ CARD ═══════════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

/* ═══ STATS ══════════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--t);
}
.stat-card:hover { border-color: var(--border-3); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--teal-dim2), transparent);
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
  margin-bottom: 5px;
}
.stat-sub { font-size: 0.72rem; color: var(--text-3); }
.stat-teal .stat-value { color: var(--teal-light); }
.stat-warn .stat-value { color: var(--warning); }

/* ═══ TABLE ══════════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
}
thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius) 0 0; }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--teal-glow); }
tbody td {
  padding: 11px 14px;
  font-size: 0.845rem;
  color: var(--text);
  vertical-align: middle;
}
.td-mono { font-family: var(--font-mono); font-size: 0.8rem; }
.table-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ═══ BADGES ═════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-teal    { background: var(--teal-dim);    color: var(--teal-light); }
.badge-success { background: var(--success-dim); color: #66BB6A; }
.badge-warning { background: var(--warning-dim); color: #FFA726; }
.badge-danger  { background: var(--danger-dim);  color: #EF5350; }
.badge-info    { background: var(--info-dim);    color: #42A5F5; }
.badge-neutral { background: rgba(61,94,122,0.2); color: var(--text-2); }
.badge-dot::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ═══ TOOLBAR ════════════════════════════════════════════════════════════════ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.search-wrap input { padding-left: 32px; }
.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.filter-select {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 8px 11px;
  color: var(--text-2);
  font-size: 0.84rem;
  font-family: var(--font-body);
  cursor: pointer;
  outline: none;
  appearance: none;
  transition: border-color var(--t);
}
.filter-select:focus { border-color: var(--teal); }

/* ═══ MODAL ══════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,137,123,0.06);
  animation: slideUp 0.18s ease;
}
.modal-lg { max-width: 720px; }
.modal-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.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;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ═══ EMPTY + LOADING ════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-3);
}
.empty-state svg { width: 44px; height: 44px; margin: 0 auto 14px; display: block; opacity: 0.2; }
.empty-state h3 { font-family: var(--font-head); font-size: 0.95rem; color: var(--text-2); margin-bottom: 4px; }
.empty-state p { font-size: 0.82rem; }
.loading-state { display: flex; align-items: center; justify-content: center; padding: 80px; }
.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border-2);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ═══ TOAST ══════════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 11px 16px;
  font-size: 0.845rem;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  min-width: 240px;
  max-width: 340px;
  pointer-events: all;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger);  }
.toast-info    { border-left: 3px solid var(--info);    }
.toast-warn    { border-left: 3px solid var(--warning); }
.toast-icon { font-size: 0.8rem; font-weight: 700; font-family: var(--font-mono); flex-shrink: 0; }
@keyframes toastIn { from { transform: translateX(16px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ═══ PAGE HEADER ════════════════════════════════════════════════════════════ */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.page-title {
  font-family: var(--font-head);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.page-sub { color: var(--text-2); font-size: 0.78rem; margin-top: 3px; }

/* ═══ SECTION DIVIDER ════════════════════════════════════════════════════════ */
.section-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ═══ SIDEBAR OVERLAY ════════════════════════════════════════════════════════ */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 99;
  backdrop-filter: blur(3px);
}

/* ═══ RESPONSIVE ═════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar-close { display: block; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 32px rgba(0,0,0,0.6); }
  .field-row { grid-template-columns: 1fr; }
  .field-3 { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 14px 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-wrap { max-width: none; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .field-3 { grid-template-columns: 1fr; }
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; margin-top: auto; margin-bottom: 0; max-height: 95vh; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
}
