/* ═══════════════════════════════════════════════════════════════════
   Material & Container Management — Web UI Stylesheet
   ═══════════════════════════════════════════════════════════════════ */

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

html {
  color-scheme: light;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f4f6f8;
  color: #333;
  min-height: 100vh;
}

/* ── Portal page ───────────────────────────────────────────────── */

.portal-body {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.site-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.2rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.site-card:hover {
  border-color: #57aa42;
  box-shadow: 0 2px 8px rgba(87,170,66,0.15);
}

.site-card h3 {
  margin: 0 0 0.4rem 0;
  font-size: 1.1rem;
}

.site-card .site-slug {
  color: #888;
  font-size: 0.8rem;
  font-family: monospace;
}

.site-card.inactive {
  opacity: 0.5;
  border-style: dashed;
  cursor: default;
}

.site-card.inactive h3::after {
  content: ' (inactive)';
  color: #e74c3c;
  font-size: 0.8rem;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 2rem 0 0.5rem;
  border-bottom: 2px solid #57aa42;
  padding-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.audit-table th,
.audit-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #eee;
  text-align: left;
}

.audit-table th {
  background: #f5f7fa;
}

.audit-action {
  font-family: monospace;
  font-size: 0.8rem;
  background: #eef3f8;
  padding: 2px 6px;
  border-radius: 3px;
}

.portal-empty-state {
  color: #7f8c8d;
}

.portal-pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.portal-pager-grid {
  grid-column: 1 / -1;
  margin-top: 12px;
}

.portal-page-indicator {
  font-size: 0.85rem;
}

.site-card-materials {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #555;
}

.site-card-actions {
  margin-top: 0.5rem;
}

.security-event-fail {
  color: #c0392b;
  font-weight: 600;
}
.security-event-warning {
  color: #a04400;
  font-weight: 600;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* ── Header ────────────────────────────────────────────────────── */

header {
  background: #57aa42;
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header h1 { font-size: 1.3rem; }
.home-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  text-decoration: none;
  color: white;
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 4px;
  margin-right: 0.4rem;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.home-btn:hover { opacity: 1; }
.home-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Tabs ──────────────────────────────────────────────────────── */

.main-tabs, .sub-tabs {
  display: flex;
  padding: 0 16px;
}
.main-tabs { background: #489636; }
.sub-tabs  { background: #3d8230; }

.tab-btn, .subtab-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 10px 20px;
  cursor: pointer;
  font-size: 0.95rem;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.tab-btn:hover, .subtab-btn:hover { color: white; }
.tab-btn.active, .subtab-btn.active {
  color: white;
  border-bottom-color: white;
}

.tab-content, .subtab-content {
  display: none;
  padding: 16px 24px;
}
.tab-content.active, .subtab-content.active { display: block; }

/* ── Toolbar ───────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 0;
}
.toolbar label { font-weight: 500; }
.toolbar select {
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #bdc3c7;
  font-size: 0.9rem;
}
.spacer { flex: 1; }

/* ── Buttons ───────────────────────────────────────────────────── */

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  color: white;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-primary   { background: #57aa42; }
.btn-primary:hover { background: #489636; }
.btn-secondary { background: #7f8c8d; }
.btn-secondary:hover { background: #6c7a7b; }
.btn-danger    { background: #c0392b; }
.btn-danger:hover { background: #e74c3c; }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn-small { padding: 4px 10px; font-size: 0.8rem; }

.theme-toggle {
  min-width: 82px;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: 4px;
  background: transparent;
  color: white;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.12);
}
.login-theme-toggle {
  width: auto !important;
  margin-top: 12px;
  border-color: #7f8c8d;
  color: #555;
}
.login-theme-toggle:hover {
  background: #eef3f8;
}

/* ── Table ─────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  background: #f7f7f5;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
th, td { padding: 10px 14px; text-align: left; }
th { background: #ecf0f1; font-weight: 600; }
td { border-top: 1px solid #ecf0f1; }
tr:hover td { background: #f9f9f9; }

.mat-browse-table { margin-top: 12px; }
.mat-browse-table .mat-row-editable { cursor: pointer; }
.mat-browse-table .mat-row-editable:hover td { background: #eaf5e7; }

/* ── Robot cards ───────────────────────────────────────────────── */

.robot-card {
  background: #f7f7f5;
  border-radius: 6px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow: hidden;
}
.robot-header {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ecf0f1;
  font-weight: 500;
}
.robot-header:hover { background: #e0e4e7; }
.robot-header .arrow { transition: transform 0.2s; }
.robot-header.expanded .arrow { transform: rotate(90deg); }

.robot-body { padding: 12px 16px; display: none; }
.robot-body.expanded { display: block; }

.robot-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin-bottom: 12px;
}
.robot-info dt { font-weight: 500; color: #7f8c8d; }

.robot-material-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.data-unavailable {
  color: #bdc3c7;
}

.hazardous-badge {
  display: inline-block;
  background: #e67e22;
  color: white;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.8rem;
  margin-left: 4px;
}

/* ── Robot overview table ──────────────────────────────────────── */

.robots-table { margin-top: 8px; }
.robot-name-cell { font-weight: 600; }
.robots-table .sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.robots-table .sortable-th:hover { background: #e0e4e7; }
.robots-table .sortable-th.sort-active { color: #2c3e50; }

.robot-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: capitalize;
}
.status-idle     { background: #dfe6e9; color: #636e72; }
.status-working  { background: #dff9fb; color: #0984e3; }
.status-charging { background: #ffeaa7; color: #d68910; }
.status-error    { background: #fab1a0; color: #d63031; }

.battery-high { color: #27ae60; font-weight: 500; }
.battery-mid  { color: #f39c12; font-weight: 500; }
.battery-low  { color: #e74c3c; font-weight: 600; }

/* ── Battery bar widget ────────────────────────────────────────── */
.bat-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bat-body {
  display: flex;
  gap: 2px;
  border: 2px solid #555;
  border-radius: 3px;
  padding: 2px;
  height: 18px;
}
.bat-tip {
  width: 4px;
  height: 10px;
  background: #555;
  border-radius: 0 2px 2px 0;
  margin-left: -2px;
}
.bat-seg {
  width: 6px;
  border-radius: 1px;
  background: #dfe6e9;
}
.bat-seg.bat-green  { background: #27ae60; }
.bat-seg.bat-yellow { background: #f39c12; }
.bat-seg.bat-red    { background: #e74c3c; }
.bat-label {
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 32px;
}
.bat-wrap .bat-label { color: inherit; }
.bat-wrap:has(.bat-green) .bat-label  { color: #27ae60; }
.bat-wrap:has(.bat-yellow) .bat-label { color: #d68910; }
.bat-wrap:has(.bat-red) .bat-label    { color: #e74c3c; }

.orphan-badge {
  display: inline-block;
  background: #e74c3c;
  color: white;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 600;
}

.orphan-warning {
  background: #fdf2e9;
  border: 2px solid #e67e22;
  border-radius: 8px;
  padding: 20px 24px;
  text-align: center;
  color: #7d4e00;
  margin: 24px auto;
  max-width: 500px;
}
.orphan-warning p { margin: 4px 0; }

/* ── Ramp top-down view ────────────────────────────────────────── */

#ramp-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
}

.ramp-layout {
  display: grid;
  grid-template-areas:
    ".     south  .    "
    "east  ramp   west "
    ".     north  .    ";
  grid-template-columns: 260px 280px 260px;
  grid-template-rows: 240px 240px 60px;
  gap: 6px;
  justify-items: stretch;
  align-items: stretch;
}

.ramp-slot {
  border: 2px solid #bdc3c7;
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 0.85rem;
  position: relative;
}
.ramp-slot.south { grid-area: south; }
.ramp-slot.west  { grid-area: west; }
.ramp-slot.east  { grid-area: east; }

.ramp-center {
  grid-area: ramp;
  background: #e2f0dc;
  border: 2px solid #57aa42;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: #2c3e50;
}
.ramp-entrance {
  grid-area: north;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  padding-top: 4px;
}
.ramp-door {
  width: 28px;
  height: 48px;
  background: #95a5a6;
  border-radius: 4px;
}

.slot-empty {
  background: repeating-linear-gradient(
    45deg, #f9f9f9, #f9f9f9 8px, #eee 8px, #eee 16px
  );
  color: #c0392b;
  font-weight: 500;
}
.slot-occupied {
  background: #e8f4e2;
  border-color: #57aa42;
}
.slot-payload-green {
  background: #e8f4e2;
  border-color: #57aa42;
}
.slot-payload-yellow {
  background: #fef9e7;
  border-color: #f39c12;
}
.slot-payload-red {
  background: #fdedec;
  border-color: #e74c3c;
}
.slot-hazardous {
  /* marker class kept for JS selection — no extra border styling */
}

.slot-label {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 0.75rem;
  color: #7f8c8d;
  font-weight: 600;
  text-transform: uppercase;
}
.slot-title  { font-weight: 600; margin-bottom: 4px; }
.slot-detail { font-size: 0.8rem; color: #555; line-height: 1.5; }

.entrance-label {
  font-size: 0.85rem;
  color: #7f8c8d;
  text-align: center;
  margin-top: 8px;
}

.ramp-info {
  font-size: 0.82rem;
  color: #666;
  padding: 2px 0 4px;
}

/* ── Modal ─────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-overlay[hidden] { display: none; }

.modal-content {
  background: #f7f7f5;
  border-radius: 8px;
  padding: 24px;
  min-width: 380px;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.modal-content h2 {
  margin-bottom: 16px;
  font-size: 1.2rem;
}
.modal-content h3 {
  margin-bottom: 12px;
  font-size: 1.1rem;
}
.modal-content label {
  display: block;
  margin-bottom: 10px;
  font-weight: 500;
  font-size: 0.9rem;
}
.modal-content input[type="text"],
.modal-content input[type="password"],
.modal-content select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-size: 0.9rem;
  margin-top: 2px;
}
.modal-content > .btn:first-of-type { margin-top: 12px; }

.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 0.9rem;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-size: 0.9rem;
}
.form-group input[type="checkbox"] { width: auto; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.dialog-section-heading {
  margin: 10px 0 4px;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.form-feedback {
  color: #c0392b;
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 1.2em;
}

.ramp-remove-intro {
  margin: 8px 0;
}

.ramp-remove-container-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.ramp-remove-table {
  font-size: 0.85rem;
}

.dialog-danger-warning {
  color: #c0392b;
  font-weight: 600;
  margin: 8px 0;
}

.dialog-confirmation {
  margin: 12px 0;
}

/* ── Payload color coding ─────────────────────────────────────── */

.payload-green  { color: #57aa42; font-weight: 600; }
.payload-yellow { color: #f39c12; font-weight: 600; }
.payload-red    { color: #e74c3c; font-weight: 600; }

/* ── Payload legend ─────────────────────────────────────────── */

.payload-legend {
  display: flex;
  gap: 18px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: #555;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.legend-dot-green { background: #27ae60; }
.legend-dot-yellow { background: #f39c12; }
.legend-dot-red { background: #e74c3c; }

.material-hazardous {
  color: #e74c3c;
  font-weight: 600;
}

/* ── Container list row payload coloring ───────────────────── */

tr.row-payload-green td  { background: #e8f4e2; }
tr.row-payload-yellow td { background: #fef9e7; }
tr.row-payload-red td    { background: #fdedec; }

/* ── Logs table ────────────────────────────────────────────── */

.logs-table {
  margin-top: 12px;
  font-size: 0.88rem;
}
.logs-table th {
  font-size: 0.82rem;
  white-space: nowrap;
}
.sortable th {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 18px;
}
.sortable th::after {
  content: '\2195';
  position: absolute;
  right: 4px;
  opacity: 0.3;
  font-size: 0.7rem;
}
.sortable th.sort-asc::after {
  content: '\25B2';
  opacity: 0.8;
}
.sortable th.sort-desc::after {
  content: '\25BC';
  opacity: 0.8;
}
.logs-table td {
  font-size: 0.85rem;
}

/* ── Login overlay ───────────────────────────────────────────── */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 40, 55, 0.92);
  backdrop-filter: blur(6px);
}

.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 360px;
  max-width: 92vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  text-align: center;
}

.login-box h2 { margin-bottom: 1rem; font-size: 1.35rem; }

.login-box input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}
.login-box input:focus {
  outline: none;
  border-color: #57aa42;
  box-shadow: 0 0 0 3px rgba(87,170,66,0.18);
}
.login-box button { width: 100%; padding: 0.65rem; font-size: 1rem; }

.login-error {
  color: #d32f2f;
  background: #fdecea;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.is-hidden {
  display: none !important;
}

.portal-loading {
  color: #7f8c8d;
  padding: 24px;
}

.content-loading {
  color: #7f8c8d;
  text-align: center;
  padding: 24px;
}

.content-error {
  color: #c0392b;
  text-align: center;
  padding: 24px;
}

.content-empty-compact {
  color: #7f8c8d;
  text-align: center;
  padding: 16px;
}

.material-safe {
  color: #27ae60;
}

.admin-pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.admin-page-indicator {
  font-size: 0.85rem;
}

.event-added {
  color: #27ae60;
  font-weight: 600;
}

.event-removed {
  color: #c0392b;
  font-weight: 600;
}

.dialog-intro {
  margin-bottom: 0.5rem;
}

.dialog-muted {
  color: #666;
  font-size: 0.85rem;
}

.material-summary {
  padding: 8px 12px;
  background: #ecf0f1;
  border-radius: 4px;
  margin-bottom: 12px;
}

/* ── Header user bar ─────────────────────────────────────────── */

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.account-menu {
  position: relative;
}
.account-menu-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 4px;
  background: transparent;
  color: white;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}
.account-menu-button:hover,
.account-menu-button[aria-expanded="true"] {
  background: rgba(255,255,255,0.12);
}
.account-menu-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.account-menu-button .account-menu-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.15s;
}
.account-menu-button[aria-expanded="true"] .account-menu-chevron {
  transform: rotate(180deg);
}
.account-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1100;
  min-width: 175px;
  padding: 5px;
  border: 1px solid #d5dadd;
  border-radius: 5px;
  background: white;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.account-menu-dropdown[hidden] {
  display: none;
}
.account-menu-dropdown button {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #2f3437;
  cursor: pointer;
  font-size: 0.85rem;
  text-align: left;
}
.account-menu-dropdown button:hover,
.account-menu-dropdown button:focus {
  background: #eef3ef;
  outline: none;
}
.account-menu-dropdown .account-menu-logout {
  color: #b42318;
}

.session-table code {
  white-space: nowrap;
}
#sessions-view {
  overflow-x: auto;
}
.session-table {
  min-width: 1050px;
}
.session-role {
  margin-top: 2px;
  color: #667078;
  font-size: 0.75rem;
}
.session-ip-warning {
  background: #fff4e5;
}
.session-warning-text {
  margin-top: 3px;
  color: #a04400;
  font-size: 0.75rem;
  font-weight: 600;
}
.session-actions {
  min-width: 130px;
}
.session-actions .btn {
  width: 100%;
  margin-bottom: 4px;
}
.session-actions .btn:last-child {
  margin-bottom: 0;
}

/* ── Admin table ─────────────────────────────────────────────── */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}
.admin-table th, .admin-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e0e0e0;
  text-align: left;
}
.admin-table th { background: #f5f5f5; font-size: 0.85rem; }

.key-display {
  font-family: monospace;
  font-size: 0.95rem;
  background: #f5f5f5;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  word-break: break-all;
  user-select: all;
  margin: 0.75rem 0;
}

/* ── Password field helpers ────────────────────────────────────── */

.pw-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
}
.pw-wrap input { width: 100%; padding-right: 2.2rem !important; }
.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  min-width: 42px;
  font-size: 0.75rem;
  padding: 3px 5px;
  color: #555;
  opacity: 0.8;
}
.pw-toggle:hover { opacity: 1; }

.pw-rules {
  list-style: none;
  padding: 0;
  margin: 2px 0 6px 0;
  font-size: 0.82rem;
}
.pw-rules li {
  color: #c0392b;
  transition: color 0.15s;
}
.pw-rules li::before {
  content: 'Required: ';
}
.pw-rules li.ok {
  color: #27ae60;
}
.pw-rules li.ok::before {
  content: 'OK: ';
}

/* ── Dark theme ────────────────────────────────────────────────── */

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="dark"] body {
  background: #171a1d;
  color: #e7e9ea;
}

html[data-theme="dark"] header {
  background: #2f7d32;
}

html[data-theme="dark"] .main-tabs {
  background: #286b2b;
}

html[data-theme="dark"] .sub-tabs {
  background: #225c25;
}

html[data-theme="dark"] .site-card,
html[data-theme="dark"] table,
html[data-theme="dark"] .robot-card,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .login-box {
  background: #22272b;
  border-color: #3b4349;
  color: #e7e9ea;
}

html[data-theme="dark"] .site-card:hover {
  border-color: #69b96b;
  box-shadow: 0 2px 8px rgba(105,185,107,0.18);
}

html[data-theme="dark"] .section-title {
  border-bottom-color: #69b96b;
}

html[data-theme="dark"] th,
html[data-theme="dark"] .audit-table th,
html[data-theme="dark"] .admin-table th,
html[data-theme="dark"] .robot-header,
html[data-theme="dark"] .material-summary {
  background: #2a3035;
  color: #f2f4f5;
}

html[data-theme="dark"] td,
html[data-theme="dark"] .audit-table td,
html[data-theme="dark"] .admin-table td {
  border-color: #3b4349;
}

html[data-theme="dark"] tr:hover td,
html[data-theme="dark"] .mat-browse-table .mat-row-editable:hover td,
html[data-theme="dark"] .robot-header:hover,
html[data-theme="dark"] .robots-table .sortable-th:hover {
  background: #30373c;
}

html[data-theme="dark"] .audit-action,
html[data-theme="dark"] .key-display {
  background: #30373c;
  color: #d9dddf;
}

html[data-theme="dark"] .site-card .site-slug,
html[data-theme="dark"] .site-card-materials,
html[data-theme="dark"] .portal-empty-state,
html[data-theme="dark"] .content-loading,
html[data-theme="dark"] .content-empty-compact,
html[data-theme="dark"] .robot-info dt,
html[data-theme="dark"] .slot-label,
html[data-theme="dark"] .slot-detail,
html[data-theme="dark"] .entrance-label,
html[data-theme="dark"] .ramp-info,
html[data-theme="dark"] .payload-legend,
html[data-theme="dark"] .dialog-muted {
  color: #aeb5ba;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #191d20;
  color: #f2f4f5;
  border-color: #4a545b;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] .login-box input:focus {
  border-color: #69b96b;
  box-shadow: 0 0 0 3px rgba(105,185,107,0.18);
  outline: none;
}

html[data-theme="dark"] .btn-primary {
  background: #347d37;
}

html[data-theme="dark"] .btn-primary:hover {
  background: #3f9142;
}

html[data-theme="dark"] .btn-secondary {
  background: #566169;
}

html[data-theme="dark"] .btn-secondary:hover {
  background: #66737c;
}

html[data-theme="dark"] .login-theme-toggle {
  border-color: #69747c;
  color: #d9dddf;
}

html[data-theme="dark"] .login-theme-toggle:hover {
  background: #30373c;
}

html[data-theme="dark"] .account-menu-dropdown {
  background: #22272b;
  border-color: #4a545b;
}

html[data-theme="dark"] .account-menu-dropdown button {
  color: #e7e9ea;
}

html[data-theme="dark"] .account-menu-dropdown button:hover,
html[data-theme="dark"] .account-menu-dropdown button:focus {
  background: #30373c;
}

html[data-theme="dark"] .account-menu-dropdown .account-menu-logout {
  color: #ff8a80;
}

html[data-theme="dark"] .session-role {
  color: #aeb5ba;
}

html[data-theme="dark"] .session-ip-warning {
  background: #453b1d;
}

html[data-theme="dark"] .session-warning-text {
  color: #ffd166;
}

html[data-theme="dark"] .ramp-slot {
  border-color: #566169;
}

html[data-theme="dark"] .ramp-center {
  background: #244128;
  border-color: #4da650;
  color: #e7e9ea;
}

html[data-theme="dark"] .slot-empty {
  background: repeating-linear-gradient(
    45deg, #202529, #202529 8px, #292f34 8px, #292f34 16px
  );
  color: #ff8a80;
}

html[data-theme="dark"] .slot-occupied,
html[data-theme="dark"] .slot-payload-green,
html[data-theme="dark"] tr.row-payload-green td {
  background: #203c27;
  border-color: #4da650;
}

html[data-theme="dark"] .slot-payload-yellow,
html[data-theme="dark"] tr.row-payload-yellow td {
  background: #453b1d;
}

html[data-theme="dark"] .slot-payload-red,
html[data-theme="dark"] tr.row-payload-red td {
  background: #482727;
}

html[data-theme="dark"] .orphan-warning {
  background: #3f321f;
  color: #ffd08a;
}

html[data-theme="dark"] .login-overlay {
  background: rgba(10, 12, 14, 0.94);
}

html[data-theme="dark"] .login-error {
  color: #ffaaa2;
  background: #482727;
}

html[data-theme="dark"] .material-safe,
html[data-theme="dark"] .event-added,
html[data-theme="dark"] .payload-green,
html[data-theme="dark"] .battery-high {
  color: #76cf79;
}

html[data-theme="dark"] .security-event-fail,
html[data-theme="dark"] .content-error,
html[data-theme="dark"] .event-removed,
html[data-theme="dark"] .payload-red,
html[data-theme="dark"] .battery-low,
html[data-theme="dark"] .material-hazardous {
  color: #ff8a80;
}

html[data-theme="dark"] .security-event-warning {
  color: #ffd166;
}

html[data-theme="dark"] .pw-toggle {
  color: #c6cbce;
}

html[data-theme="dark"] .robots-table .sortable-th.sort-active {
  color: #e7e9ea;
}

html[data-theme="dark"] .status-idle {
  background: #3a4248;
  color: #d9dddf;
}

html[data-theme="dark"] .status-working {
  background: #243c4d;
  color: #7dc4f5;
}

html[data-theme="dark"] .status-charging {
  background: #453b1d;
  color: #ffd166;
}

html[data-theme="dark"] .status-error {
  background: #482727;
  color: #ffaaa2;
}

@media (max-width: 760px) {
  header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
  }

  .header-right {
    flex-wrap: wrap;
    width: 100%;
  }

  .main-tabs,
  .sub-tabs {
    overflow-x: auto;
  }

  .tab-btn,
  .subtab-btn {
    flex: 0 0 auto;
  }
}
