:root {
  --bg: #0f1115;
  --card: #151923;
  --text: #e6e6e6;
  --muted: #9aa3b2;
  --accent: #4cc9f0;
  --ok: #2ecc71;
  --warn: #f39c12;
  --bad: #e74c3c;
  --border: #232a36;
  --sidebar-pad: 20px;
  --header-h: 44px;
  --collapsed-logo-h: 24px;
  /* Device row group layout variables (unused widths removed) */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Roboto, ui-sans-serif, system-ui, -apple-system, Segoe UI, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.app-header .title { font-size: 24px; font-weight: 700; }
.app-header .status { color: var(--muted); font-size: 14px; }
.sep { opacity: 0.5; margin: 0 8px; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot-connected { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot-disconnected { background: var(--bad); box-shadow: 0 0 8px var(--bad); }

.controls { display: flex; align-items: center; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.controls input {
  background: #0d1117;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
}
.controls button {
  background: var(--accent);
  color: #001018;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.controls button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.controls .hint { color: var(--muted); margin-left: auto; }

/* New dashboard layout */
.ndt-root { display: grid; grid-template-columns: 800px 1fr; height: 100vh; gap: 12px; padding: 20px 20px 20px 20px; }
.ndt-sidebar { background: #666666; border: none; border-radius: 14px; overflow: hidden; position: relative; transition: width 0.25s ease; }
.ndt-sidebar-inner { position: absolute; top: var(--sidebar-pad); bottom: var(--sidebar-pad); left: 0; right: 0; display: flex; flex-direction: column; }
.ndt-sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 0 12px; height: var(--header-h); }
.ndt-sidebar-header .left { display: flex; align-items: center; gap: 10px; }
.logo-expanded { height: 24px; width: auto; display: inline-block; margin-left: 5px; }
.app-version { margin-left: 10px; color: #999999; font: 400 14px Roboto, ui-sans-serif, system-ui; position: relative; top: 2px; }
.mqtt-status { width: 10px; height: 10px; border-radius: 50%; display: inline-block; position: relative; top: 2px; }
.mqtt-status--success { background: #00B200; }
.mqtt-status--pending { background: #F5BA00; }
.mqtt-status--failure { background: #BB0000; }
.icon-btn { background: transparent; border: none; color: var(--text); font-size: 18px; cursor: pointer; padding: 6px 8px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn, a.icon-btn { text-decoration: none; }
.icon-btn:hover { background: rgba(255,255,255,0.06); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.icon-img { width: 18px; height: 18px; display: block; pointer-events: none; }
.link-btn { color: #ffffff; text-decoration: none; font: 600 14px Roboto, sans-serif; padding: 6px 10px; border-radius: 6px; margin-right: 6px; display: inline-block; }
.link-btn:hover { background: rgba(255,255,255,0.06); }

/* Sync status chip */
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); font: 500 12px Roboto, sans-serif; opacity: 0.9; margin-left: 8px; background: transparent; white-space: nowrap; overflow: hidden; width: 250px; flex-shrink: 0; justify-content: center; position: relative; cursor: pointer; }
.status-chip .dot { width: 8px; height: 8px; margin: 0; position: absolute; left: 8px; top: 50%; transform: translateY(-50%); }
.status-chip .dot-connected, .status-chip .dot-disconnected { box-shadow: none; }
.status-chip.ok { border-color: rgba(46, 204, 113, 0.35); background: transparent; }
.status-chip.err { border-color: rgba(231, 76, 60, 0.4); background: transparent; }
.status-chip.syncing { border-color: #F5BA00; background: transparent; }
.status-chip .dot-sync { background: #F5BA00; }

/* Pandora modal toolbar */
.pandora-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pandora-radios { display: inline-flex; align-items: center; gap: 12px; }
.pandora-dates { display: inline-flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.pandora-date-field { display: flex; flex-direction: column; gap: 4px; font: 500 12px Roboto, ui-sans-serif, system-ui; color: var(--muted); }
.pandora-date-field input[type="date"] { background: #0d1117; border: 1px solid var(--border); color: var(--text); padding: 6px 8px; border-radius: 6px; font: 500 14px Roboto, ui-sans-serif, system-ui; }
.radio-inline input { margin-right: 6px; }

.ndt-sidebar-list { flex: 1; overflow: hidden; position: relative; padding: 8px; }
.ndt-sidebar-footer { height: 0; }

.ndt-row { display: grid; align-items: center; background: #333333; border-radius: 12px; margin: 6px 8px; padding: 0 20px; height: var(--row-h, 48px); max-height: 75px; color: #ffffff; grid-template-columns: 1fr auto 1fr; position: relative; }
.ndt-row.ndt-row--undeployed { background: #444444; }
.ndt-row .mono { font-family: "Roboto Mono", monospace; }
.ndt-row .item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ndt-row .col-left, .ndt-row .col-center, .ndt-row .col-right { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.ndt-row .col-left { justify-self: start; padding-left: var(--device-content-shift, 0px); }
.ndt-row .col-center { justify-self: center; text-align: center; }
.ndt-row .col-right { justify-self: end; gap: 5px; }
/* Add extra after battery so Battery ↔ Version = 15px (gap 5 + margin 10) */
.ndt-row .col-right .bat { margin-right: 10px; }
.ndt-row .serial { font-weight: 700; font-size: 16px; }
.ndt-row .text { font-weight: 700; font-size: 16px; }
.ndt-row .col-right .ver { color: #cccccc; font-weight: 400; font-size: 14px; }
.ndt-row .col-right .bat { color: #cccccc; }
.ndt-row .rssi, .ndt-row .bat { display: inline-flex; align-items: center; gap: 8px; }
.ndt-row img.icon { height: 20px; width: 20px; }
.ndt-row .rssi img.icon { height: 20px; width: 30px; }
.ndt-row .io img.icon { height: 20px; width: 30px; }
.ndt-row .bat img.icon { height: 20px; width: 30px; }
.ndt-row .row-avatar {
  position: absolute;
  left: var(--device-avatar-offset, 28px);
  top: 50%;
  transform: translateY(-50%);
  width: calc(var(--row-h, 48px) - 2 * var(--device-avatar-offset, 20px));
  height: calc(var(--row-h, 48px) - 2 * var(--device-avatar-offset, 20px));
  min-width: 28px;
  min-height: 28px;
  border-radius: 12px;
  overflow: hidden;
  background: #555555;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.08);
}
.ndt-row .row-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Upload count badge overlay */
.ndt-row .upload-badge {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  font: 700 9px Roboto, sans-serif;
  padding: 2px 4px;
  border-radius: 10px;
  white-space: nowrap;
  width: 90%;
  pointer-events: none;
  z-index: 2;
  text-align: center;
  line-height: 1.2;
}

/* Pin location 50px from device block's left edge (row has 20px padding) */
.ndt-row .loc {
  position: absolute;
  left: calc(180px + var(--device-content-shift, 0px)); /* shifted 5px to the right + tweakable */
  text-align: left;
  max-width: calc(100% - 60px);
}

/* Pin user 30px from device block's left edge (row has 20px padding) */
.ndt-row .user {
  position: absolute;
  left: calc(80px + var(--device-content-shift, 0px)); /* 20px row padding + 10px = 30px from outer edge */
  text-align: left;
  max-width: calc(100% - 40px);
  color: #90C5FC;
}

.ndt-content { position: relative; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: #0c0f14; }
.map-toolbar { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 5; }
.search { background: rgba(255,255,255,0.9); border-radius: 10px; border: none; padding: 8px 12px; min-width: 300px; }
.ndt-map { position: absolute; inset: 0; }
.map-reset { position: absolute; top: 12px; right: 16px; z-index: 6; background: #333333; border: 1px solid #333333; color: #ffffff; padding: 6px 12px; border-radius: 8px; font: 600 13px Roboto, sans-serif; cursor: pointer; }
.map-reset:hover { background: #444444; }

body.sidebar-collapsed .ndt-root { grid-template-columns: 58px 1fr; transition: grid-template-columns 0.25s ease; }
body.sidebar-collapsed .ndt-sidebar { width: 58px; }
body.sidebar-collapsed .ndt-sidebar-header .right, body.sidebar-collapsed .ndt-sidebar-list { display: none; }
body.sidebar-collapsed .logo-expanded { display: none; }
body.sidebar-collapsed .app-version, body.sidebar-collapsed .mqtt-status { display: none; }

.collapsed-tab { display: none; position: absolute; left: 13px; top: calc(var(--sidebar-pad) + (var(--header-h) - var(--collapsed-logo-h)) / 2 - 4px); z-index: 6; cursor: pointer; padding: 4px; border-radius: 6px; }
.collapsed-tab img { height: 24px; width: auto; display: block; }
body.sidebar-collapsed .collapsed-tab { display: block; }

/* Menu popover */
.menu-popover { position: fixed; top: 0; left: 0; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.menu-popover#xlsxPopover { background: #333333; width: 520px; }
.menu-popover#mqttExportPopover { background: #2f2f2f; width: min(640px, 90vw); }
.xlsx-file-row { display: flex; align-items: center; gap: 10px; width: 100%; }
.xlsx-file-row .filename-display { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #e6e6e6; font: 400 13px Roboto, sans-serif; }
.menu-popover .toggle { display: flex; align-items: center; gap: 8px; }
/* Override Code popover styles */
.menu-popover .mono { font-family: "Roboto Mono", monospace; }
.menu-popover#overridePopover { background: #AAAAAA; }
.menu-popover .override-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.menu-popover .override-close { background: transparent; border: none; color: var(--text); font-size: 18px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.menu-popover .override-close:hover { background: rgba(255,255,255,0.06); }
.menu-popover .override-body { display: flex; align-items: flex-start; gap: 12px; }
.menu-popover .override-body .field { display: flex; flex-direction: column; gap: 4px; }
.menu-popover .override-body label { font: 500 11px Roboto, ui-sans-serif, system-ui; color: var(--muted); margin-left: 8px; }
#overridePopover .override-body label { color: #666666; }
.menu-popover .code-input, .menu-popover .override-result { font: 600 16px "Roboto Mono", monospace; }
.menu-popover .code-input { background: #0d1117; border: 1px solid var(--border); color: var(--text); padding: 6px 8px; border-radius: 6px; width: 95px; }
.menu-popover .override-result { display: inline-block; width: 95px; padding: 6px 8px; color: var(--text); }
#overridePopover .code-input, #overridePopover .override-result { position: relative; top: 2px; }
#overridePopover .override-header strong { color: #333333; }
#overridePopover .override-result { color: #275AAB; }
#overridePopover .code-input { background: #333333; }
#overridePopover .override-close { color: #333333; position: relative; top: -2px; }
#overridePopover .override-result-wrap { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; width: 140px; }

/* MQTT export popover */
.mqtt-export-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mqtt-export-dates { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.mqtt-export-field { display: flex; flex-direction: column; gap: 4px; font: 500 12px Roboto, ui-sans-serif, system-ui; color: var(--muted); }
.mqtt-export-field input[type="date"] { background: #0d1117; border: 1px solid var(--border); color: var(--text); padding: 6px 8px; border-radius: 6px; font: 500 14px Roboto, ui-sans-serif, system-ui; }
.mqtt-export-topics { border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: #262626; }
.mqtt-export-topics-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font: 600 12px Roboto, ui-sans-serif, system-ui; color: var(--muted); }
.mqtt-export-topics-list { max-height: min(50vh, 320px); overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.mqtt-export-group { border: 1px solid #333333; border-radius: 8px; padding: 8px; background: #1f1f1f; }
.mqtt-export-group-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; font: 600 12px Roboto, ui-sans-serif, system-ui; color: #f1f1f1; }
.mqtt-export-group-check { display: inline-flex; align-items: center; gap: 8px; }
.mqtt-export-group-toggle { background: #2a2a2a; color: #e6e6e6; border: 1px solid #3a3a3a; border-radius: 6px; width: 24px; height: 24px; font: 700 14px Roboto, ui-sans-serif, system-ui; cursor: pointer; }
.mqtt-export-group-toggle:hover { background: #333333; }
.mqtt-export-group-list { margin-left: 18px; margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.mqtt-export-group-list[hidden] { display: none; }
.mqtt-export-topic { display: flex; align-items: center; gap: 8px; color: #e6e6e6; font: 400 12px "Roboto Mono", monospace; }
.mqtt-export-empty { color: var(--muted); font: 400 12px Roboto, ui-sans-serif, system-ui; }
.mqtt-export-actions { margin-top: 10px; display: flex; gap: 8px; }
.mqtt-export-msg { margin-top: 6px; font-size: 12px; color: #cfcfcf; min-height: 16px; }

/* Tooltip */
.ndt-tooltip { position: fixed; background: rgba(20,20,20,0.95); color: #e6e6e6; border: 1px solid #444; border-radius: 10px; z-index: 100; font: 400 12px Roboto, sans-serif; white-space: pre-wrap; pointer-events: auto; display: inline-block; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.ndt-tooltip .tooltip-header { display: flex; justify-content: flex-end; padding: 4px 6px 0 6px; }
.ndt-tooltip .tooltip-header button { background: transparent; border: none; color: #f8f1f1; font-size: 14px; cursor: pointer; pointer-events: auto; }
.ndt-tooltip .tooltip-header button:hover { color: #f5ba00; }
.ndt-tooltip .tooltip-body { padding: 0px 10px; font-size: 13px; line-height: 1.0; margin: 0; }
/* Device map tooltip sizing and vertical centering (restored) */
#devTooltip { display: flex; align-items: center; width: max-content; max-width: none; position: absolute; margin-left: -100px; }
#devTooltip .tooltip-body { padding: 6px 10px; font-size: 13px; line-height: 1.2; margin: 0; white-space: nowrap; }

.history-panel { position: fixed; top: 20px; bottom: 20px; right: 20px; min-width: 255px; max-width: 90vw; background: #666666; color: #ffffff; border-radius: 14px 0 0 14px; box-shadow: -12px 0 32px rgba(0,0,0,0.4); z-index: 200; display: flex; flex-direction: column; overflow: hidden; transform: translateX(calc(100% + 40px)); transition: transform 0.25s ease; }
.history-panel.open { transform: translateX(0); }
.history-panel-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font-weight: 600; white-space: nowrap; }
.history-panel-header button { background: transparent; border: none; color: #ffffff; font-size: 20px; cursor: pointer; }
.history-panel-header button:hover { color: #f5ba00; }
.history-panel pre { margin: 0; padding: 0 20px 16px 16px; font: 400 12px 'Roboto Mono', monospace; color: #ffffff; overflow-y: auto; white-space: pre-wrap; flex: 1; }
#historyContent { margin: 0; padding: 0 20px 16px 16px; font: 400 12px 'Roboto Mono', monospace; color: #ffffff; overflow-y: auto; flex: 1; }

/* History footer and Show More link */
.history-panel-footer { padding: 6px 16px 12px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.history-panel .history-more { color: #ffffff; text-decoration: underline; cursor: pointer; font: 600 13px Roboto, sans-serif; }
.history-panel .history-more:hover { color: #f5ba00; }
.history-panel .history-more.disabled { opacity: 0.6; pointer-events: none; }

/* History loading indicator */
.history-loading { margin: 0; padding: 0 20px 8px 16px; font: 600 12px Roboto, sans-serif; color: #ffffff; }

table.messages { width: 100%; border-collapse: collapse; }
table.messages th, table.messages td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.messages thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }
table.messages tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
table.messages code { background: #0d1117; padding: 2px 4px; border-radius: 4px; }
.muted { color: var(--muted); }

@media (min-aspect-ratio: 16/9) {
  .app-header .title { font-size: 28px; }
  .controls { font-size: 16px; }
  table.messages th, table.messages td { font-size: 15px; }
}

/* -------- Device detail page -------- */
.device-root { display: flex; flex-direction: column; height: 100vh; padding: 20px; gap: 20px; }
.device-topbar { background: #666666; border-radius: 10px; padding: 4px 10px; }
.device-topbar .ndt-sidebar-header { height: var(--header-h); }
.device-topbar .ndt-sidebar-header .center { flex: 1; text-align: center; font: 700 20px Roboto, sans-serif; color: #e6e6e6; }
.device-topbar .ndt-sidebar-header .right { display: inline-flex; align-items: center; gap: 20px; }
.device-topbar .io-stats { display: inline-flex; align-items: baseline; gap: 8px; }
.device-topbar .io-stats .io-label { color: #AAAAAA; font: 400 14px Roboto, sans-serif; }
.device-topbar .io-stats .io-up { color: #7FD87F; font: 900 20px 'Roboto Mono', monospace; }
.device-topbar .io-stats .io-down { color: #90C5FC; font: 900 20px 'Roboto Mono', monospace; }
.device-topbar .io-stats .io-sep { color: #AAAAAA; font: 400 14px Roboto, sans-serif; }
.device-topbar .io-stats .io-suffix { color: #AAAAAA; font: 400 14px Roboto, sans-serif; }
  .device-content { display: grid; grid-template-rows: auto 1fr; gap: 20px; min-height: 0; flex: 1; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-card { background: #333333; border: 1px solid #444444; border-radius: 12px; position: relative; color: #ffffff; }
.chart-title { font: 700 18px Roboto, sans-serif; text-align: center; color: #ffffff; padding: 10px 20px 0 20px; }
.chart-card canvas { display: block; width: calc(100% - 40px); height: 240px; margin: 20px; }
.chart-menu { position: absolute; top: 8px; right: 14px; background: transparent; border: none; color: #e6e6e6; cursor: pointer; font-size: 20px; }
.chart-nav { position: absolute; top: 10px; left: 10px; display: inline-flex; gap: 6px; z-index: 2; }
.chart-nav button { background: transparent; border: none; color: #e6e6e6; cursor: pointer; font-size: 16px; padding: 4px 6px; border-radius: 6px; }
.chart-nav button:hover { background: rgba(255,255,255,0.08); }
.chart-nav .chart-nav-now { font-size: 12px; letter-spacing: 0.3px; font-weight: 600; }
  .chart-nav button:disabled { opacity: 0.45; cursor: not-allowed; }

/* -------- Bulletins page -------- */
.bulletins-root { display: grid; grid-template-columns: 320px 1fr; height: 100vh; gap: 12px; padding: 20px; }
.bulletins-sidebar { background: #666666; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.bulletins-sidebar-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; height: var(--header-h); }
.bulletins-userlist { flex: 1; overflow: auto; padding: 8px; }
.bulletins-user { background: #333333; color: #ffffff; border-radius: 10px; padding: 10px 10px; margin: 6px 8px; cursor: pointer; font: 400 16px Roboto, sans-serif; height: var(--buser-h, 48px); max-height: 75px; display: flex; align-items: center; gap: 20px; position: relative; }
.bulletins-user.all { justify-content: center; text-align: center; box-shadow: inset 0 0 0 1px #F5BA00; }
.bulletins-user.all.active { box-shadow: inset 0 0 0 1px #FFFFFF; }
.bulletins-user .avatar { width: calc(var(--buser-h, 48px) - 20px); height: calc(var(--buser-h, 48px) - 20px); border-radius: 10px; object-fit: cover; flex: 0 0 auto; background: #555; }
.bulletins-user .name { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 30px; }
.bulletins-user .counter { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; pointer-events: none; opacity: 1; filter: brightness(0) saturate(100%) invert(60%); }
.bulletins-user .counter[data-count="0"] { filter: brightness(0) saturate(100%) invert(25%); }
.bulletins-user:hover { background: #3b3b3b; }
.bulletins-user.active { background: #F5BA00; color: #000000; }
.bulletins-user.active a, .bulletins-user.active span { color: #000000; }
.bulletins-content { background: transparent; display: flex; flex-direction: column; min-width: 0; }
.bulletins-toolbar { background: #666666; border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.bulletins-toolbar .left { justify-self: start; }
.bulletins-toolbar .center { justify-self: center; display: inline-flex; align-items: center; gap: 16px; }
.bulletins-toolbar .right { justify-self: end; display: inline-flex; align-items: center; gap: 10px; }
.bulletins-title { font: 700 20px Roboto, sans-serif; margin: 0; color: #e6e6e6; margin-left: 10px; }
.bulletins-title .bulletins-title-user { font-weight: 100; }
/* Enlarge icons in bulletins toolbar center */
.bulletins-toolbar .center .icon-img { width: 30px; height: 30px; }
.btn-primary { background: #f5ba00; color: #000; border: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; font: 700 14px Roboto, sans-serif; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-primary.btn-new { background: #3272D7; color: #fff; }
.btn-primary.btn-new:hover { filter: brightness(1.05); }
.btn-secondary { background: transparent; color: #ffffff; border: 1px solid #444444; padding: 8px 12px; border-radius: 8px; cursor: pointer; font: 600 14px Roboto, sans-serif; text-decoration: none; }
.btn-secondary:hover { background: rgba(255,255,255,0.06); }
#xlsxConvertGoogle { background: #00B200; color: #ffffff; border: none; }
#xlsxConvertGoogle:hover { filter: brightness(0.95); }
.bulletins-container { background: #AAAAAA; border-radius: 14px; margin-top: 12px; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.bulletins-actions { display: flex; justify-content: flex-start; padding: 10px 16px 0 16px; }
.bulletins-actions .btn-new { margin-left: 2px; margin-top: 20px;}
.bulletins-cards { display: flex; flex-direction: column; gap: 20px; padding: 16px; align-content: flex-start; overflow: visible; flex: 1; }
.bulletins-cards.empty { justify-content: center; align-items: center; }
.bulletin-card { width: 375px; height: 68px; background: #222222; border-radius: 10px; position: relative; display: flex; align-items: center; padding: 0 20px 0 10px; box-shadow: 0 10px 12px rgba(0,0,0,0.25); }
.bulletin-card .card-inner { display: flex; align-items: center; gap: 15px; width: 100%; }
.bulletin-card .icon-wrap { width: 33px; height: 28px; display: flex; align-items: center; justify-content: center; margin-left: 10px; margin-right: 15px; flex: 0 0 auto; }
.bulletin-card .icon-wrap img { width: 33.05px; height: 28.48px; display: block; }
.bulletin-card .text { color: #ffffff; font: 400 14px Roboto, sans-serif; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; }
.bulletin-card .text-input { color: #ffffff; font: 400 14px Roboto, sans-serif; line-height: 1.2; background: transparent; border: none; outline: none; }
/* Editing: mimic card text wrapping while typing (two lines); flex to fill remaining space */
.bulletin-card.editor .text-input { flex: 1 1 auto; height: 42px; resize: none; overflow: hidden; display: block; }

/* Toast notifications */
.toast {
  position: fixed;
  right: 30px;
  bottom: 30px;
  transform: translateY(10px);
  background: #222222;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  padding: 0 20px 0 10px;
  min-height: 68px;
  border-radius: 10px;
  box-shadow: 0 10px 12px rgba(0,0,0,0.25);
  font: 400 14px Roboto, sans-serif;
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 9999;
  border: 1px solid #444444;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #222222; color: #FFFFFF; border-color: #444444; }
.toast-error { background: #222222; color: #FFFFFF; border-color: #444444; }
/* Toast inner structure (match bulletin card proportions) */
.toast .icon-wrap { width: 33px; height: 28px; display: flex; align-items: center; justify-content: center; margin-left: 10px; margin-right: 15px; }
.toast .icon-wrap img { width: 33.05px; height: 28.48px; display: block; }
.toast .text { color: #FFFFFF; font: 400 14px Roboto, sans-serif; line-height: 1.2; flex: 1; }
.toast { width: 375px; }

/* Modal for push output */
.modal { position: fixed; inset: 0; display: none; }
.modal[hidden] { display: none; }
.modal:not([hidden]) { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-dialog { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--card); color: var(--text); width: min(900px, 90vw); max-height: 80vh; border-radius: 12px; border: 1px solid var(--border); display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font: 700 18px Roboto, sans-serif; }
.modal-close { background: transparent; border: none; color: var(--text); font-size: 22px; cursor: pointer; }
.modal-close:hover { color: #fff; }
.modal-body { margin: 0; padding: 12px 14px; background: var(--bg); color: var(--text); overflow: auto; white-space: pre-wrap; word-break: break-word; font: 400 12px "Roboto Mono", monospace; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); }
.bulletin-card .actions { position: absolute; left: calc(100% + 30px); top: 50%; transform: translateY(-50%); display: none; gap: 8px; z-index: 2; }
.bulletin-card .actions button { background: transparent; border: 1px solid #444; color: #e6e6e6; border-radius: 6px; padding: 4px 6px; cursor: pointer; }
.bulletin-card .actions button:hover { background: rgba(255,255,255,0.06); }
.bulletin-card:hover .actions, .bulletin-card .actions:hover, .bulletin-card .hover-bridge:hover { display: inline-flex; }
.bulletin-card .hover-bridge { position: absolute; left: 100%; top: 0; width: 30px; height: 100%; }
.bulletin-card .badge { position: absolute; top: 6px; left: 10px; background: #444; color: #fff; font: 700 10px Roboto, sans-serif; padding: 2px 6px; border-radius: 6px; }
.bulletin-card.editor { outline: 2px dashed #f5ba00; }
.bulletin-card .editor-actions { position: absolute; left: calc(100% + 30px); top: 50%; transform: translateY(-50%); display: inline-flex; gap: 8px; }
.bulletin-card .editor-actions button { background: #f5ba00; color: #000; border: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.bulletin-card .editor-actions .cancel { background: transparent; color: #fff; border: 1px solid #444; }
.bulletin-card .editor-actions .char-counter { color: #e6e6e6; font: 400 12px Roboto, sans-serif; opacity: 0.85; align-self: center; margin-left: 8px; }
.empty-bulletins { color: #000000; font: 300 24px Roboto, sans-serif; padding: 16px; white-space: nowrap; }

/* New Bulletin button icon color */
.btn-new .new-icon { color: #CCCCCC; font-weight: 900; margin-right: 6px; }
.icon-select { position: relative; }
.icon-select .icon-current { display: inline-flex; align-items: center; justify-content: center; background: transparent; border: none; color: #e6e6e6; border-radius: 6px; padding: 0; cursor: pointer; width: 33.05px; height: 28.48px; min-width: 33.05px; min-height: 28.48px; }
.icon-select .icon-menu { position: absolute; top: 110%; left: 0; background: #333; border: 1px solid #444; border-radius: 6px; padding: 4px; display: none; z-index: 100; }
.icon-select.open .icon-menu { display: block; }
.icon-select.up .icon-menu { top: auto; bottom: 110%; }
.icon-select .icon-option { display: flex; align-items: center; gap: 6px; color: #e6e6e6; cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.icon-select .icon-option:hover { background: rgba(255,255,255,0.08); }
.menu-popover .bulletin-editor { min-width: 420px; }
.bulletin-editor .editor-row { margin: 8px 0; }
.bulletin-editor label { display: block; font: 600 13px Roboto, sans-serif; color: #e6e6e6; margin-bottom: 4px; }
.bulletin-editor input[type="text"] { width: 100%; background: #333; border: 1px solid #444; color: #fff; padding: 8px; border-radius: 8px; }
.bulletin-editor .icon-choices label { margin-right: 12px; }
.bulletin-editor .editor-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.chart-nav .since-full-charge { margin-left: 10px; font: 400 11px Roboto, sans-serif; color: #e6e6e6; opacity: 0.85; position: relative; top: 7px; }
.chart-card .chart-toolbar.right { position: absolute; top: 8px; right: 47px; z-index: 2; background: rgba(0,0,0,0.35); padding: 6px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 8px; }
.device-map-wrap { position: relative; background: #0c0f14; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; min-height: 240px; height: 100%; }
.device-map-wrap .map-toolbar.right { position: absolute; top: 10px; right: 10px; left: auto; transform: none; z-index: 6; background: rgba(0,0,0,0.45); padding: 10px; border-radius: 8px; width: auto; height: auto; display: inline-flex; align-items: center; gap: 8px; }
.time-range { display: inline-flex; align-items: center; gap: 8px; color: #fff; }
.device-map-wrap .map-reset { position: absolute; bottom: 32px; right: 16px; top: auto; z-index: 6; }
.device-map-wrap .map-total { position: absolute; bottom: 14px; left: 16px; z-index: 6; color: #ffffff; font: 700 18px Roboto, sans-serif; pointer-events: none; /* heavier stroked look */ text-shadow: 0 0 3px #000, 0 0 2px #000, 2px 0 0 #000, -2px 0 0 #000, 0 2px 0 #000, 0 -2px 0 #000, 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000; }
.slide-in { animation: slideIn 240ms ease-out; }
@keyframes slideIn { from { transform: translateX(-12px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
:root {
  --device-avatar-offset: 8px;
  --device-content-shift: 60px;
}

/* Hamburger Menu */
.hamburger-wrapper { position: relative; }
.hamburger-btn { color: var(--text); }
.hamburger-btn svg { stroke: currentColor; }
.hamburger-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #2a2a2a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 0;
  min-width: 200px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.hamburger-menu[hidden] { display: none; }
.hamburger-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font: 400 14px Roboto, sans-serif;
  cursor: pointer;
  text-decoration: none;
  text-align: left;
}
.hamburger-item:hover { background: rgba(255,255,255,0.08); }
.hamburger-item .icon-img { width: 18px; height: 18px; opacity: 0.85; }
.hamburger-item svg { width: 18px; height: 18px; opacity: 0.85; }
.hamburger-item--danger { color: #ff6b6b; }
.hamburger-item--danger:hover { background: rgba(255,107,107,0.15); }
.hamburger-divider { height: 1px; background: var(--border); margin: 6px 0; }

/* Users Modal */
.users-modal-dialog { width: min(600px, 90vw); max-height: 85vh; }
.users-modal-body { display: flex; flex-direction: column; gap: 20px; padding: 16px; font-family: Roboto, sans-serif; white-space: normal; }
.users-modal-body h3 { margin: 0 0 12px 0; font: 600 15px Roboto, sans-serif; color: var(--text); }
.users-list { display: flex; flex-direction: column; gap: 8px; max-height: 200px; overflow-y: auto; }
.users-loading { color: var(--muted); font: 400 13px Roboto, sans-serif; padding: 12px; }
.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.user-item-info { display: flex; flex-direction: column; gap: 2px; }
.user-item-name { font: 500 14px Roboto, sans-serif; color: var(--text); }
.user-item-meta { font: 400 11px Roboto, sans-serif; color: var(--muted); }
.user-item-actions { display: flex; gap: 8px; }
.user-item .btn-icon {
  background: transparent;
  border: 1px solid #444;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.user-item .btn-icon:hover { background: rgba(255,255,255,0.08); }
.user-item .btn-icon.delete { color: #ff6b6b; border-color: #ff6b6b; }
.user-item .btn-icon.delete:hover { background: rgba(255,107,107,0.15); }
.user-item.current { border-color: #f5ba00; }
.user-item.current .user-item-name::after { content: ' (you)'; color: #f5ba00; font-size: 11px; }

.users-form { display: flex; flex-direction: column; gap: 12px; }
.users-form-field { display: flex; flex-direction: column; gap: 4px; }
.users-form-field label { font: 500 12px Roboto, sans-serif; color: var(--muted); }
.users-form-field input {
  background: #1e1e1e;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font: 400 14px Roboto, sans-serif;
}
.users-form-field input:focus { outline: none; border-color: #f5ba00; }
.users-form-field input::placeholder { color: var(--muted); opacity: 0.6; }
.users-form-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.users-msg { font: 400 12px Roboto, sans-serif; padding: 8px 0; }
.users-msg.success { color: #4caf50; }
.users-msg.error { color: #ff6b6b; }

/* 2FA Enrollment in Users Modal */
.users-2fa-toggle { margin-top: 8px; }
.users-2fa-toggle .checkbox-label {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font: 400 13px Roboto, sans-serif; color: var(--text);
}
.users-2fa-toggle input[type="checkbox"] { width: 16px; height: 16px; accent-color: #f5ba00; }
.users-2fa-section {
  background: #1a1a1a; border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin-top: 8px;
}
.users-2fa-qr { text-align: center; margin-bottom: 12px; }
.users-2fa-qr img { background: #fff; padding: 6px; border-radius: 6px; max-width: 140px; }
.users-2fa-secret { text-align: center; margin-bottom: 12px; }
.users-2fa-secret .secret-row { display: inline-flex; align-items: center; gap: 8px; }
.users-2fa-secret code { font: 600 13px 'Roboto Mono', monospace; color: #f5ba00; letter-spacing: 1px; }
.users-2fa-secret .secret-copy-btn {
  background: transparent; border: 1px solid #444; border-radius: 4px;
  padding: 4px 6px; cursor: pointer; color: #888;
  display: inline-flex; align-items: center; transition: all 0.2s;
}
.users-2fa-secret .secret-copy-btn:hover { background: #333; color: #fff; border-color: #555; }
.users-2fa-secret .secret-hint { color: #666; font-size: 11px; margin-top: 6px; }

/* Delete User Modal */
.delete-user-dialog { width: min(400px, 90vw); }
.delete-user-dialog .modal-body { font: 400 14px Roboto, sans-serif; white-space: normal; }
.delete-user-dialog .modal-body p { margin: 0 0 8px 0; }
.delete-user-dialog .text-muted { color: var(--muted); font-size: 13px; }
.btn-danger { background: #dc3545; color: #fff; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font: 500 14px Roboto, sans-serif; }
.btn-danger:hover { background: #c82333; }
