/* ── CSS CUSTOM PROPERTIES ───────────────────────────── */
:root {
  --bg-base:       #0a0c0f;
  --bg-surface:    #111418;
  --bg-panel:      #161b22;
  --bg-card:       #1a2030;
  --bg-input:      #0d1117;
  --bg-sidebar:    #0e1117;

  --border:        rgba(255, 255, 255, 0.07);
  --border-active: rgba(0, 188, 212, 0.35);

  --primary:       #00BCD4;
  --primary-dark:  #0097A7;

  --text-primary:  #f0f4f8;
  --text-secondary:#8b9ab0;
  --text-muted:    #4a5568;
  --text-data:     #c8d8e8;

  --green:         #22c55e;
  --red:           #ef4444;
  --red-dark:      #b91c1c;

  --sidebar-w:     220px;
  --header-h:      58px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;

  --font-ui:       'Space Grotesk', sans-serif;
  --font-mono:     'DM Mono', monospace;
}

/* ── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}
input, button, select { font-family: inherit; }
button { cursor: pointer; border: none; background: none; }
input  { outline: none; }
svg    { display: block; }

/* ── APP SHELL ───────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; }

/* ── HEADER ──────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 100;
}

.header__logo {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary);
  text-transform: uppercase;
  white-space: nowrap;
}

.header__status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.header__status.connected    { color: var(--green);  border: 1px solid rgba(34,197,94,0.3);  background: rgba(34,197,94,0.06);  }
.header__status.connecting   { color: #f59e0b;       border: 1px solid rgba(245,158,11,0.3); background: rgba(245,158,11,0.06); }
.header__status.disconnected { color: var(--red);    border: 1px solid rgba(239,68,68,0.3);  background: rgba(239,68,68,0.06);  }

.header__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.connected    .header__status-dot { background: var(--green); animation: pulse-green 2s ease-in-out infinite; }
.connecting   .header__status-dot { background: #f59e0b;      animation: pulse-amber 1s ease-in-out infinite; }
.disconnected .header__status-dot { background: var(--red); }

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 6px var(--green); }
  50%       { box-shadow: 0 0 14px var(--green); opacity: 0.6; }
}
@keyframes pulse-amber {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.header__spacer { flex: 1; }

.btn-start {
  padding: 8px 22px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.btn-start:hover {
  background: rgba(0, 188, 212, 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-emergency {
  padding: 8px 22px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--red);
  color: #fff;
  border: 1px solid var(--red);
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.35);
  transition: background 0.18s, box-shadow 0.18s, transform 0.1s;
}
.btn-emergency:hover  { background: var(--red-dark); box-shadow: 0 0 28px rgba(239,68,68,0.6); transform: scale(1.02); }
.btn-emergency:active { transform: scale(0.98); }

/* ── BODY ────────────────────────────────────────────── */
.body { display: flex; flex: 1; overflow: hidden; }

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar__operator {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar__avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary-dark), #0077b6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar__avatar svg { width: 22px; height: 22px; color: #fff; }

.sidebar__op-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}
.sidebar__op-role {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.sidebar__nav { padding: 12px 0; flex: 1; }

.sidebar__nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.sidebar__nav-item:hover  { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.sidebar__nav-item.active { background: rgba(0,188,212,0.1); color: var(--primary); border-right: 2px solid var(--primary); }
.sidebar__nav-item svg    { width: 16px; height: 16px; flex-shrink: 0; }

/* ── MAIN ────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── PANEL ───────────────────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

.panel__header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
}
.panel__header-icon { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }
.panel__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.panel__badge {
  margin-left: auto;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* ── FORMS ───────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-wrapper:focus-within {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.08);
}

.input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.input-wrapper input::placeholder { color: var(--text-muted); }
.input-wrapper input[readonly]    { cursor: default; color: var(--text-secondary); }

.input-unit {
  padding: 0 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  align-self: stretch;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

/* ── PANEL BUTTONS ───────────────────────────────────── */
.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.btn-add,
.btn-reset {
  padding: 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  transition: background 0.18s, border-color 0.18s, opacity 0.18s;
}
.btn-add:hover:not(:disabled),
.btn-reset:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-add:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── DASHBOARD LAYOUT ────────────────────────────────── */
.top-row {
  display: grid;
  grid-template-columns: 1fr 0.75fr;
  gap: 20px;
}

.metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ── METRIC CARDS ────────────────────────────────────── */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
}

.metric-card__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.metric-card__value {
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 18px;
}

.metric-card__current {
  font-size: 32px;
  font-weight: 500;
  color: var(--text-primary);
}

.metric-card__total {
  font-size: 26px;
  font-weight: 400;
  color: var(--primary);
}

/* ── PROGRESS BAR ────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  transition: width 0.5s ease;
}

/* ── ORDERS TABLE ────────────────────────────────────── */
.logs-table { width: 100%; border-collapse: collapse; }

.logs-table th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.logs-table td {
  padding: 13px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-data);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.logs-table tr:last-child td { border-bottom: none; }
.logs-table tr:hover td { background: rgba(255, 255, 255, 0.02); }

.batch-id { color: var(--primary); font-weight: 500; }

/* ── STATUS BADGES ───────────────────────────────────── */
.status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
}
.status-badge.completed   { color: var(--green);  background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.25);  }
.status-badge.processing  { color: var(--primary); background: rgba(0,188,212,0.1);  border: 1px solid rgba(0,188,212,0.25);  }
.status-badge.queued      { color: var(--text-muted); background: rgba(255,255,255,0.04); border: 1px solid var(--border);   }
.status-badge.manual-stop { color: var(--red);    background: rgba(239,68,68,0.1);   border: 1px solid rgba(239,68,68,0.25);  }

.status-badge.processing::before {
  content: '● ';
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

/* ── SCROLLBAR ───────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 1200px) {
  .top-row     { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 64px; }
  .sidebar__op-info,
  .sidebar__nav-item span { display: none; }
  .sidebar__nav-item { justify-content: center; padding: 12px; }
  .sidebar__operator { justify-content: center; padding: 14px 8px; }
  .main { padding: 16px; }
}
@media (max-width: 640px) {
  .btn-emergency { font-size: 10px; padding: 7px 12px; }
  .header__logo  { font-size: 13px; }
}
