:root {
  --bg: #f5f5f5;
  --surface: #fff;
  --border: #ddd;
  --text: #222;
  --text-muted: #666;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #ca8a04;
  --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.5;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.logo { font-weight: 700; font-size: 16px; }
.header__user { margin-left: 16px; color: var(--text-muted); font-size: 13px; }

.nav { display: flex; gap: 8px; align-items: center; }

.nav__btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.nav__btn:hover { border-color: #aaa; }
.nav__btn--active { border-color: var(--accent); color: var(--accent); background: #eff6ff; }

/* Main */
.main { flex: 1; padding: 20px 24px; max-width: 1400px; margin: 0 auto; width: 100%; }

.page { display: none; }
.page--active { display: block; }

.page__header { margin-bottom: 20px; }
.page__title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.page__subtitle { color: var(--text-muted); }

/* Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.panel__title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

.badge--status { color: var(--success); border-color: #bbf7d0; background: #f0fdf4; }
.badge--status.offline { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.badge--status.emergency { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.badge--status.idle { color: var(--warning); border-color: #fef08a; background: #fefce8; }

/* Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: 240px 1fr 260px;
  gap: 16px;
  align-items: start;
}

.robot-list { display: flex; flex-direction: column; gap: 6px; }

.robot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.robot-item:hover { border-color: #aaa; }
.robot-item--active { border-color: var(--accent); background: #eff6ff; }

.robot-item__num {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  min-width: 32px;
  text-align: center;
}

.robot-item__name { font-weight: 600; font-size: 13px; }
.robot-item__type, .robot-item__mode { font-size: 11px; color: var(--text-muted); }

.robot-item__indicator {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.robot-item__indicator--online { background: var(--success); }
.robot-item__indicator--offline, .robot-item__indicator--emergency { background: var(--danger); }
.robot-item__indicator--idle { background: var(--warning); }

.robot-visual {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
  min-height: 80px;
  position: relative;
  background: #fafafa;
}

.robot-visual--night { background: #1e1b2e; color: #c4b5fd; border-color: #7c3aed; }
.robot-visual--emergency { background: #fef2f2; border-color: var(--danger); }
.robot-visual--standby { background: #fefce8; border-color: var(--warning); }

.robot-visual__id { font-size: 12px; color: var(--text-muted); }
.robot-visual__mode { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

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

.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
}

.stat-card__label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.stat-card__value { font-size: 16px; font-weight: 600; margin-top: 2px; }

.stat-card__bar {
  height: 3px;
  background: #eee;
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.stat-card__bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

.controls__title { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; text-transform: uppercase; }
.control-group { margin-bottom: 12px; }
.control-group--row { display: flex; gap: 20px; }

.control-label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.control-select, .form-field input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
}

.control-select:focus, .form-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.control-range { width: 100%; margin-top: 4px; }
.checkbox-label { font-size: 13px; display: flex; align-items: center; gap: 6px; cursor: pointer; }

.control-actions, .form-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
}

.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary:hover { border-color: #aaa; }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }

/* Log */
.log { max-height: 400px; overflow-y: auto; }
.log__entry { padding: 6px 8px; border-left: 2px solid var(--border); margin-bottom: 4px; font-size: 12px; }
.log__entry--success { border-left-color: var(--success); }
.log__entry--warning { border-left-color: var(--warning); }
.log__entry--info { border-left-color: var(--accent); }
.log__time { color: var(--text-muted); font-size: 11px; }

/* Profile */
.profile-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.profile-sessions { grid-column: 1 / -1; }

.profile-card__name { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.profile-card__email { color: var(--text-muted); margin-bottom: 16px; }

.profile-stats { display: flex; gap: 16px; }
.profile-stat { flex: 1; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; text-align: center; }
.profile-stat__label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.profile-stat__value { font-size: 24px; font-weight: 700; color: var(--accent); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field label { font-size: 12px; color: var(--text-muted); }

.sessions-list { display: flex; flex-direction: column; gap: 6px; }
.session-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}
.session-item__meta { color: var(--text-muted); margin-top: 4px; }

/* Auth */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 400px;
}

.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); margin-bottom: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-link { margin-top: 16px; text-align: center; font-size: 13px; color: var(--text-muted); }
.auth-link a { color: var(--accent); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 16px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
}

.toast--visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1000px) {
  .dashboard-grid, .profile-layout, .form-grid { grid-template-columns: 1fr; }
  .header { flex-direction: column; gap: 10px; align-items: flex-start; }
}
