:root {
  --ink: #171b26;
  --ink-soft: #5b6478;
  --paper: #f4f6f9;
  --panel: #ffffff;
  --line: #e5e8ee;
  --accent: #2f5d8a;
  --accent-2: #0f8b8d;
  --accent-soft: #eaf1f8;
  --good: #2e7d4f;
  --good-soft: #e8f5ec;
  --warn: #b3791a;
  --warn-soft: #fbf1e0;
  --bad: #b0392f;
  --bad-soft: #fdecea;
  --radius: 8px;
  --sidebar-w: 226px;
  --shadow: 0 1px 2px rgba(23,27,38,0.04), 0 8px 24px rgba(23,27,38,0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #24314a 0%, #131826 70%);
}
.login-card {
  background: var(--panel);
  width: 350px;
  padding: 38px 34px;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.login-card .logo-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  margin-bottom: 16px;
}
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card p.sub { color: var(--ink-soft); margin: 0 0 24px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin: 14px 0 5px; }
.login-card input {
  width: 100%; padding: 10px 11px; border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button {
  width: 100%; margin-top: 22px; padding: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.login-card button:hover { filter: brightness(1.05); }
.error-msg {
  background: var(--bad-soft); color: var(--bad); padding: 9px 12px;
  border-radius: var(--radius); font-size: 13px; margin-top: 16px;
}
.info-msg {
  background: var(--accent-soft); color: var(--accent); padding: 9px 12px;
  border-radius: var(--radius); font-size: 13px; margin-top: 16px;
}

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #171b26 0%, #1f2537 100%);
  color: #cfd5e2;
  padding: 22px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: #fff; padding: 0 20px 20px; font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 12px;
}
.sidebar .brand .logo-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex-shrink: 0;
}
.sidebar nav { flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 20px; color: #b7bfd1; font-size: 13.5px;
}
.sidebar nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.sidebar nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar nav a.active svg { opacity: 1; }
.sidebar .user-box {
  margin-top: 16px; padding: 14px 20px 0;
  border-top: 1px solid rgba(255,255,255,0.08); font-size: 12.5px;
}
.sidebar .user-box form { margin-top: 8px; }
.sidebar .user-box button { background: none; border: none; color: #9fb2cc; cursor: pointer; font-size: 12.5px; padding: 0; }
.sidebar .user-box button:hover { color: #fff; }

.main { flex: 1; padding: 28px 34px; min-width: 0; }
.main h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.01em; }
.main .page-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 22px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.panel h2.section-title { font-size: 13.5px; font-weight: 700; margin: 0 0 14px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=text], .toolbar input[type=search], .toolbar select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 13.5px;
}
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 15px; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: #24486b; text-decoration: none; color: #fff; }
.btn.secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--paper); }
.btn.danger { background: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--ink-soft); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: var(--paper); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.neutral { background: var(--accent-soft); color: var(--accent); }

.empty-state { text-align: center; padding: 44px 20px; color: var(--ink-soft); }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.stat-card .stat-value.good { color: var(--good); }
.stat-card .stat-value.bad { color: var(--bad); }
.stat-card .stat-sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-row .bar-label { width: 160px; flex-shrink: 0; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.bar-row .bar-track { flex: 1; background: var(--paper); border-radius: 20px; height: 10px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar-row .bar-count { width: 30px; text-align: right; font-size: 12.5px; color: var(--ink-soft); flex-shrink: 0; }

/* ---------- Product cards ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.product-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--panel); }
.product-card .prow { display: flex; gap: 12px; align-items: flex-start; }
.product-card .pinfo { flex: 1; min-width: 0; }
.product-card .pname { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.product-card .psku { font-size: 12px; color: var(--ink-soft); }
.product-card .pmeta { margin-top: 10px; display: flex; justify-content: space-between; align-items: center; }
.product-card .pprice { font-weight: 700; }
.product-card .pactions { margin-top: 12px; display: flex; gap: 12px; font-size: 12.5px; }

.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(20,24,34,0.5);
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; width: 440px; max-width: 100%; max-height: 90vh; overflow-y: auto; }
.modal h2 { margin: 0 0 16px; font-size: 16px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin: 12px 0 5px; }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 13.5px; font-family: inherit;
}
.modal input[type=file] { padding: 6px; border: 1px dashed var(--line); }
.modal-actions { margin-top: 20px; display: flex; gap: 10px; justify-content: flex-end; }

.helper-text { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.upload-box {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px;
  text-align: center; color: var(--ink-soft); background: var(--paper);
}
