:root {
  --bg:        #1a1d23;
  --bg-panel:  #22262e;
  --bg-raised: #2a2f38;
  --border:    #383e48;
  --text:      #e4e7eb;
  --text-dim:  #9aa2ad;
  --accent:    #4a9eff;
  --green:     #2d8a4e;
  --green-hi:  #37a35d;
  --yellow:    #facc15;
  --red:       #c0392b;
  --red-hi:    #d9483a;
  --gray:      #5b6472;
  --in-stock:  #4ade80;
  --low-stock: #facc15;
  --out-stock: #6b7280;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

.topbar nav a {
  color: var(--text-dim);
  text-decoration: none;
  margin-left: 18px;
  font-size: 13px;
}

.topbar nav a:hover, .topbar nav a.active { color: var(--text); }

.topbar .user-info {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: 18px;
}

.role-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  margin-left: 6px;
}
.role-badge.operator { background: var(--green); color: #fff; }
.role-badge.viewer { background: var(--gray); color: #fff; }

.flash {
  padding: 10px 20px;
  font-size: 13px;
}
.flash.error { background: var(--red); color: #fff; }
.flash.success { background: var(--green); color: #fff; }

.layout {
  display: flex;
  min-height: calc(100vh - 49px);
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.main {
  flex: 1;
  padding: 16px;
  min-width: 0;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 16px 0 8px;
}
.section-label:first-child { margin-top: 0; }

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

textarea { font-family: "SF Mono", Consolas, "Courier New", monospace; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field { margin-bottom: 12px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}
.checkbox-row input { width: auto; }
.auth-tag { color: var(--yellow); font-size: 11px; }

button, .btn {
  display: inline-block;
  width: 100%;
  padding: 9px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  text-align: center;
  text-decoration: none;
  color: #fff;
  background: var(--bg-raised);
}
button:hover, .btn:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-start { background: var(--green); }
.btn-stop { background: var(--gray); }
.btn-stop.active { background: var(--red); }
.btn-primary { background: var(--accent); }
.btn-inline { width: auto; }
.btn-danger { background: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12px; margin-bottom: 0; }

.progress-track {
  height: 8px;
  background: var(--bg-raised);
  border-radius: 4px;
  overflow: hidden;
  margin: 6px 0;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s ease;
}
.progress-label { font-size: 12px; color: var(--text-dim); }
.stats-block { font-size: 12px; color: var(--text-dim); line-height: 1.6; white-space: pre-line; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.filter-bar input[type="text"] { width: 260px; }
.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.segmented button {
  width: auto;
  margin: 0;
  border-radius: 0;
  background: var(--bg-raised);
  padding: 6px 12px;
}
.segmented button.active { background: var(--accent); }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.tab-btn {
  width: auto;
  margin: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 16px;
}
.tab-btn.active { background: var(--bg-panel); color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th:hover { color: var(--text); }
tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
tbody tr:hover { background: var(--bg-raised); }
tbody tr.in_stock td:first-child { color: var(--in-stock); }
tbody tr.low_stock td:first-child { color: var(--low-stock); }
tbody tr.out_stock td:first-child { color: var(--out-stock); }

.log-box {
  background: #000;
  color: #d0d0d0;
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
  padding: 10px;
  height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.log-box.verbose { color: #a0c4ff; white-space: pre; overflow-x: auto; }

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card { width: 320px; }
.login-card h1 { text-align: center; font-size: 22px; margin-bottom: 20px; }

.hint { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

.empty-state { color: var(--text-dim); font-size: 13px; padding: 30px; text-align: center; }

.badge-count {
  display: inline-block;
  background: var(--bg-raised);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-dim);
}
