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

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── App Shell ─────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand .wordmark {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}

.sidebar-brand .wordmark span {
  color: var(--brand);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--nav-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s, color .12s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--nav-hover-bg);
  color: #e2e8f0;
}

.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-text);
}

.nav-item svg {
  flex-shrink: 0;
  opacity: .7;
}

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

.sidebar-footer {
  padding: 12px 10px 16px;
  border-top: 1px solid var(--sidebar-border);
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

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

.topbar-user {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

.role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: capitalize;
  letter-spacing: .02em;
}

.role-badge.admin     { background: var(--yellow-bg); color: #92400e; }
.role-badge.supervisor{ background: var(--blue-bg);   color: #1e40af; }

/* ── Content ───────────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
}

/* ── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}

.page-header-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Cards / Stats ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.5px;
  line-height: 1;
}

.stat-value.accent { color: var(--brand); }

.stat-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 20px;
}

/* ── Section Title ─────────────────────────────────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
  margin-top: 28px;
}

.section-title:first-child { margin-top: 0; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.data-table thead th {
  background: var(--surface-2);
  padding: 10px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.data-table tbody tr:hover td { background: var(--surface-2); }

.empty-row {
  color: var(--text-3);
  font-style: italic;
  text-align: center;
  padding: 32px 16px !important;
}

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .02em;
  white-space: nowrap;
}

.badge-pending          { background: var(--yellow-bg); color: #92400e; }
.badge-approved         { background: var(--green-bg);  color: #065f46; }
.badge-rejected         { background: var(--red-bg);    color: #991b1b; }
.badge-ordered          { background: var(--blue-bg);   color: #1e40af; }
.badge-received         { background: var(--green-bg);  color: #065f46; }
.badge-partially_received { background: var(--yellow-bg); color: #92400e; }
.badge-closed           { background: #f1f5f9;          color: #64748b; }

.badge-normal   { background: #f1f5f9; color: #64748b; }
.badge-urgent   { background: var(--yellow-bg); color: #92400e; }
.badge-critical { background: var(--red-bg); color: #991b1b; }

.badge-active    { background: var(--green-bg);  color: #065f46; }
.badge-on_hold   { background: var(--yellow-bg); color: #92400e; }
.badge-completed { background: #f1f5f9; color: #64748b; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  line-height: 1;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }

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

.btn-danger {
  background: var(--red-bg);
  border-color: #fca5a5;
  color: #991b1b;
}
.btn-danger:hover { background: #fecaca; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-wide { width: 100%; justify-content: center; }

.btn-icon {
  padding: 6px;
  border-radius: var(--r-sm);
  line-height: 0;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(245,158,11,.15);
}

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

.field-hint {
  font-size: 12px;
  color: var(--text-3);
}

.field-error {
  font-size: 12px;
  color: var(--red);
}

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--r);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

.alert-success { background: var(--green-bg); color: #065f46; border-color: #6ee7b7; }
.alert-error,
.alert-danger   { background: var(--red-bg);  color: #991b1b; border-color: #fca5a5; }
.alert-warning  { background: var(--yellow-bg); color: #92400e; border-color: #fcd34d; }
.alert-info     { background: var(--blue-bg); color: #1e40af; border-color: #93c5fd; }

.login-alert { margin-bottom: 16px; }

/* ── Urgency dot ───────────────────────────────────────────────────────────── */
.urgency-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  flex-shrink: 0;
}
.urgency-normal   { background: #94a3b8; }
.urgency-urgent   { background: var(--yellow); }
.urgency-critical { background: var(--red); }

/* ── Divider ───────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 480px;
}

.login-brand {
  background: var(--sidebar-bg)
    url('https://images.unsplash.com/photo-1504307651254-35680f356dfd?auto=format&fit=crop&w=1280&q=80')
    center center / cover no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px 56px;
  position: relative;
  overflow: hidden;
}

.login-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(5,8,14,.97) 0%, rgba(5,8,14,.80) 35%, rgba(5,8,14,.45) 65%, rgba(5,8,14,.25) 100%),
    radial-gradient(ellipse at 30% 70%, rgba(245,158,11,.15) 0%, transparent 55%);
  pointer-events: none;
}

.login-brand .wordmark {
  position: absolute;
  top: 40px; left: 56px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  text-shadow: 0 1px 8px rgba(0,0,0,.5);
  z-index: 1;
}

.login-brand .wordmark span { color: var(--brand); }

.login-brand .pitch {
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  display: inline-block;
  max-width: 520px;
  box-shadow: 0 8px 32px rgba(0,0,0,.28);
  position: relative;
  z-index: 1;
}

.login-brand .pitch h1 {
  font-size: 34px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.15;
  letter-spacing: -.6px;
  margin-bottom: 10px;
  text-shadow: none;
}

.login-brand .pitch p {
  font-size: 15px;
  font-weight: 500;
  color: #334155;
  line-height: 1.6;
  text-shadow: none;
}

.login-form-pane {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 48px;
  border-left: 1px solid var(--border);
}

.login-form-pane .eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 8px;
}

.login-form-pane .title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.4px;
  margin-bottom: 28px;
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.ml-auto     { margin-left: auto; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-16       { margin-bottom: 16px; }
.text-sm     { font-size: 12px; }
.text-muted  { color: var(--text-3); }
.text-right  { text-align: right; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-form-pane { padding: 40px 24px; border: none; }
}
