:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --border: #e3e9e6;
  --text: #17211d;
  --muted: #67736d;
  --brand: #0d5a42;
  --brand-2: #0a4634;
  --brand-soft: #e8f3ee;
  --warning: #a96815;
  --danger: #a63f3f;
  --shadow: 0 16px 40px rgba(18, 45, 34, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 10%, rgba(13,90,66,.13), transparent 30%),
    linear-gradient(145deg, #f7f9f8, #edf2ef);
}
.login-card {
  width: min(440px, 100%);
  padding: 38px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(220,230,225,.9);
  border-radius: 26px;
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 24px;
  margin-bottom: 22px;
}
.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; margin: 0; }
.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--brand); }
.login-copy h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.login-copy > p:last-child { margin: 12px 0 28px; color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 8px; }
.login-form label span { font-size: 13px; font-weight: 600; }
input, select {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
}
input:focus, select:focus { border-color: #73a993; box-shadow: 0 0 0 3px rgba(13,90,66,.08); }
.button {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 700;
  transition: .18s ease;
}
.button.primary { color: #fff; background: var(--brand); }
.button.primary:hover { background: var(--brand-2); transform: translateY(-1px); }
.button.secondary { color: var(--text); background: var(--surface); border: 1px solid var(--border); }
.button.secondary:hover { border-color: #b8c8c0; }
.form-message { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: #11251e;
  color: #fff;
  display: flex;
  flex-direction: column;
}
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand strong { display: block; font-size: 14px; }
.sidebar-brand span { display: block; margin-top: 2px; font-size: 12px; color: rgba(255,255,255,.55); }
.nav { display: grid; gap: 6px; margin-top: 22px; }
.nav-item {
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  border: 0;
  border-radius: 11px;
  color: rgba(255,255,255,.70);
  background: transparent;
  font-weight: 600;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.09); color: #fff; }
.sidebar-user {
  margin-top: auto;
  padding: 16px 8px 2px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sidebar-user strong { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.sidebar-user span { display: block; color: rgba(255,255,255,.55); font-size: 11px; margin-top: 3px; text-transform: capitalize; }
.icon-button { border: 0; width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.08); color: #fff; }

.main { min-width: 0; padding: 28px 34px 48px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 26px; }
.topbar h2 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.sync-text { font-size: 12px; color: var(--muted); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.kpi-card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(18,45,34,.035);
}
.kpi-card { padding: 20px; min-height: 132px; display: flex; flex-direction: column; }
.kpi-card span { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi-card strong { margin-top: 14px; font-size: 25px; letter-spacing: -.035em; }
.kpi-card small { margin-top: auto; color: var(--muted); font-size: 11px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin-top: 14px; }
.panel { padding: 20px; min-width: 0; }
.panel.span-2 { grid-column: span 2; }
.panel-head { display: flex; justify-content: space-between; margin-bottom: 18px; }
.panel-head h3 { margin: 0; font-size: 16px; }
.loading-block { color: var(--muted); font-size: 13px; }

.bar-list { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 120px; gap: 12px; align-items: center; }
.bar-label { font-size: 12px; color: var(--muted); }
.bar-track { height: 9px; overflow: hidden; border-radius: 99px; background: #edf1ef; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--brand); }
.bar-value { text-align: right; font-size: 12px; font-weight: 700; }
.rank-list { display: grid; gap: 2px; }
.rank-row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid #edf1ef; }
.rank-row:last-child { border-bottom: 0; }
.rank-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.rank-row strong { white-space: nowrap; font-size: 12px; }
.stat-list { display: grid; gap: 12px; }
.stat-list > div { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #edf1ef; }
.stat-list > div:last-child { border-bottom: 0; }
.stat-list span { color: var(--muted); font-size: 12px; }
.stat-list strong { font-size: 13px; }

.toolbar { display: flex; gap: 12px; margin-bottom: 14px; }
.search-box { flex: 1; }
.toolbar select { width: 240px; }
.table-panel { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 980px; }
.data-table th { padding: 13px 14px; text-align: left; color: var(--muted); background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.data-table td { padding: 14px; border-top: 1px solid var(--border); vertical-align: top; font-size: 12px; }
.data-table td.description { min-width: 260px; max-width: 420px; line-height: 1.45; }
.status-pill { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 10px; font-weight: 700; white-space: nowrap; }
.empty-cell, .empty-state { padding: 30px !important; color: var(--muted); text-align: center; }

.supplier-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.supplier-card { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.supplier-card h3 { margin: 0 0 14px; font-size: 14px; line-height: 1.35; }
.supplier-meta { display: grid; gap: 8px; }
.supplier-meta div { display: grid; grid-template-columns: 72px 1fr; gap: 10px; font-size: 11px; }
.supplier-meta span { color: var(--muted); }
.supplier-meta strong { font-weight: 600; word-break: break-word; }

.toast { position: fixed; z-index: 50; right: 20px; top: 20px; max-width: 360px; padding: 12px 15px; border-radius: 12px; color: #fff; background: #1e332b; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(-8px); transition: .2s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #7f3131; }

@media (max-width: 1050px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .supplier-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .sidebar-brand { padding-bottom: 14px; }
  .nav { display: flex; overflow-x: auto; margin-top: 12px; }
  .nav-item { width: auto; white-space: nowrap; }
  .sidebar-user { margin-top: 14px; }
  .main { padding: 20px 14px 36px; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column; align-items: flex-end; }
  .kpi-grid, .dashboard-grid, .supplier-grid { grid-template-columns: 1fr; }
  .panel.span-2 { grid-column: span 1; }
  .toolbar { flex-direction: column; }
  .toolbar select { width: 100%; }
  .bar-row { grid-template-columns: 80px 1fr; }
  .bar-value { grid-column: 2; text-align: left; }
}
