:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e4e6ea;
  --text: #1a1d21;
  --text-muted: #6b7280;
  --accent: #3457d5;
  --accent-soft: #eaeeff;
  --green: #0f9d58;
  --green-soft: #e6f6ec;
  --amber: #b06a00;
  --amber-soft: #fff3df;
  --red: #d0392b;
  --red-soft: #fdecec;
  --blue: #2b6fd6;
  --blue-soft: #e9f1fd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 30, 0.06), 0 1px 8px rgba(20, 24, 30, 0.04);
}
* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}
.sidebar .brand { font-weight: 700; font-size: 15px; padding: 8px 10px 18px; }
.sidebar .brand small { display: block; font-weight: 500; color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: var(--text-muted); font-weight: 500; margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.auth-screen {
  position: relative; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg);
}
.auth-card {
  width: 340px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 26px;
}
.auth-card .form-row { margin-bottom: 14px; }
.auth-card input {
  width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border); font-size: 13.5px;
}

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

.role-switcher { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.role-select { width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 12.5px; background: var(--panel); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; border-bottom: 1px solid var(--border); background: var(--panel);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px; flex-shrink: 0;
}
.topbar .page-title { font-weight: 600; font-size: 15px; }
.topbar .sync-badge { font-size: 11.5px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }

.content { flex: 1; overflow-y: auto; padding: 22px 26px 60px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.card-title { font-weight: 600; font-size: 13.5px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.card-title .muted-link { font-size: 12px; color: var(--accent); font-weight: 500; }

.stat-row { display: flex; gap: 10px; }
.stat-tile { flex: 1; border-radius: 8px; padding: 12px 14px; }
.stat-tile .num { font-size: 22px; font-weight: 700; }
.stat-tile .lbl { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.stat-tile.healthy { background: var(--green-soft); }
.stat-tile.healthy .num { color: var(--green); }
.stat-tile.warning { background: var(--amber-soft); }
.stat-tile.warning .num { color: var(--amber); }
.stat-tile.critical { background: var(--red-soft); }
.stat-tile.critical .num { color: var(--red); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.02em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 100px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.gray { background: #eef0f3; color: #565c66; }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.purple { background: #f1e9fd; color: #7c3aed; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search-input, .select-input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; background: var(--panel); color: var(--text);
}
.search-input { min-width: 240px; }
.qty-input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: var(--panel); color: var(--text); width: 90px; text-align: right; font-family: inherit; }
.lang-switcher { display: flex; gap: 4px; }
.lang-opt { padding: 3px 8px; border-radius: 5px; font-size: 11.5px; font-weight: 600; cursor: pointer; color: var(--text-muted); }
.lang-opt:hover { background: var(--bg); }
.lang-opt.active { background: var(--accent); color: white; }
.btn {
  padding: 7px 13px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel); font-weight: 600; font-size: 12.5px; color: var(--text);
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { opacity: 0.92; }
.btn.danger { background: var(--red); border-color: var(--red); color: white; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.spacer-v { height: 1px; background: var(--border); margin: 16px 0; }

.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.detail-header h1 { font-size: 20px; margin: 0 0 4px; }
.breadcrumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; }
.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field { }
.field .k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 3px; }
.field .v { font-size: 14px; font-weight: 500; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 16px; }
.tab { padding: 8px 14px; font-weight: 600; font-size: 12.5px; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent); border-color: var(--accent); }

.stepper { display: flex; align-items: center; gap: 4px; }
.step-dot { width: 9px; height: 9px; border-radius: 50%; background: #dfe2e7; }
.step-dot.done { background: var(--green); }
.step-dot.current { background: var(--accent); }
.step-line { width: 20px; height: 2px; background: #dfe2e7; }
.step-line.done { background: var(--green); }

.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment .meta { font-size: 11.5px; color: var(--text-muted); margin-bottom: 3px; }
.comment .meta b { color: var(--text); }
.comment .body { font-size: 13px; }
.comment-box { display: flex; gap: 8px; margin-top: 12px; }
.comment-box textarea { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-family: inherit; font-size: 13px; resize: vertical; min-height: 40px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(20,24,30,0.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--panel); border-radius: 12px; padding: 20px 22px; width: 560px; max-width: 92vw; max-height: 86vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 5px 11px; border-radius: 100px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); color: var(--text-muted); background: var(--panel); }
.chip.active { background: var(--accent); border-color: var(--accent); color: white; }

.supplier-banner {
  background: linear-gradient(90deg, #eef2ff, #f5f6f8); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 16px; display:flex; align-items:center; gap:8px;
}
.loading { padding: 40px; text-align: center; color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.mono { font-variant-numeric: tabular-nums; }
