:root {
  --bg: #0b0f16;
  --bg-sec: #303030;
  --panel: #111827;
  --border: #1f2937;
  --sidebar: #0e1422;
  /* new: left bar color (dark, not pure black) */
  --ac: #7c4dff;
  /* accent purple for logo + hovers */
  --fg: #e5e7eb;
  --muted: #9ca3af;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Layout */
#layout {
  display: flex;
  height: 100%;
}

/* #region Sidebar */

/* Sidebar: now 70px */
#sidebar {
  width: 70px;
  flex: 0 0 70px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 12px;
}

/* Logo */
#sidebar .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

#sidebar .logo img {
  width: 45px;
  /* good fit for 70px bar */
  height: 45px;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  /* crisper on some browsers */
  object-fit: contain;
  pointer-events: none;
  /* prevents accidental drag/select */
}

/* Spacer line (short, thin, bg-colored) */
#sidebar .spacer {
  width: 70%;
  height: 1.6px;
  background: var(--border);
  margin: 8px 0 6px 0;
  opacity: 0.9;
}

/* Buttons column */
#sidebar .sideButtons {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  overflow-y: auto;
  width: 100%;
  min-height: 0;
  scrollbar-width: none;
}

#sidebar .sideFooter {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  /* same spacing as buttons column */
  margin-top: auto;
  /* pushes this block to the bottom */
}

#sidebar .sideButtons::-webkit-scrollbar {
  display: none;
}

/* Button base */
#sidebar .sidebtn {
  background: transparent;
  border: 1px #1f2937;
  border-style: solid;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: #ffffff;
  /* default icon color (white) */
  width: 56px;
  /* < 70px bar, leaves side padding */
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  transition: color .18s ease, filter .18s ease, background .18s ease, transform .12s ease;
}

/* Icon sizing + inherit color */
#sidebar .sidebtn svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* Hover / active */
#sidebar .sidebtn:hover,
#sidebar .sidebtn.active {
  color: var(--ac);
  /* purple fill */
  filter: drop-shadow(0 0 8px rgba(124, 77, 255, .55));
  background: rgba(124, 77, 255, .08);
}

/* Optional subtle hover lift */
#sidebar .sidebtn:hover {
  transform: translateY(-0.6px);
}

/* #endregion */

/* Content area: only this scrolls */
#content {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow: auto;
  background: var(--bg);
  position: relative;
}

/* #region Loading Overlays */

#overlay_load,
#overlay_pw {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#overlay_load {
  background: rgba(0, 0, 0, .45);
}

#overlay_load>div.spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, .2);
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}

/* Page-scoped overlay (inside the page element) */
.overlay_content_load {
  position: absolute;
  /* positioned relative to #content */
  top: 0;
  left: 0;
  width: 0;
  /* set by JS */
  height: 0;
  /* set by JS */
  display: none;
  /* toggled by setLoading(true/false) */
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .45);
  z-index: 999;
  pointer-events: auto;
  /* block interaction when shown */
}

/* Spinner (reuses your @keyframes spin) */
.overlay_content_load .spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, .2);
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* #endregion */

/* #region Auth Overlay */

#overlay_pw {
  background: var(--bg);
  display: none;
}

#overlay_pw form {
  display: contents;
}

#overlay_pw>div {
  background: #fff;
  color: #111;
  border-radius: 12px;
  padding: 18px;
  width: min(90vw, 360px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}

#overlay_pw>div>h3 {
  margin: 0 0 10px;
  font: 600 16px system-ui;
}

#overlay_pw>div>div {
  display: flex;
  gap: 8px;
}

#authForm>input {
  flex: 1;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0 10px;
}

#authForm>button {
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #111827;
  color: #fff;
  cursor: pointer;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* #endregion */

/* #region Toast */

/* Host that stacks toasts bottom-right */
.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2147483647;
  /* on top */
  pointer-events: none;
  /* clicks pass through by default */
}

/* Base toast (matches your look) */
.toast {
  background: var(--bg-sec, #303030);
  color: var(--fg, #fff);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, .2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  max-width: min(420px, 80vw);
  pointer-events: none;
  /* keep non-blocking by default */
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease, box-shadow .15s ease, border-color .15s ease;
  will-change: opacity, transform;
  /* If your page uses small base font, you can bump it here:
     font: 14px/1.4 system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif; */
}

/* Shown/hidden via class (no inline styles) */
.toast--show {
  opacity: 1;
  transform: translateY(0);
}

/* Optional: allow interaction (links, close button) */
.toast--interactive {
  pointer-events: auto;
}

/* Variants (use whichever you like) */
.toast--important {
  border-color: var(--ac, #7c4dff);
  box-shadow: 0 8px 24px rgba(124, 77, 255, .22);
  background: rgba(124, 77, 255, .10);
}

.toast--error {
  background: #2b0a0a;
  border-color: #7f1d1d;
  box-shadow: 0 8px 24px rgba(127, 29, 29, .35);
  color: #fff;
}

.toast--ok {
  background: #0f2a1f;
  border-color: #065f46;
  box-shadow: 0 8px 24px rgba(6, 95, 70, .30);
  color: #e8fff7;
}


/* #endregion */

/* #region Message (with buttons) */
#overlay_msg {
  position: fixed;
  inset: 0;
  display: none;
  /* toggled by JS */
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .45);
  /* dim like #overlay_load */
  z-index: 10000;
}

#overlay_msg .box {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 16px 12px 16px;
  width: min(30vw, 560px);
  min-width: 100px;
  /* requested min width */
  max-width: 30%;
  /* hard cap per request */
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}

#overlay_msg .title {
  margin: 0 0 8px 0;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  /* “a bit bigger” */
}

#overlay_msg .msg {
  margin: 6px 4px 12px 4px;
  /* spacing under title */
  text-align: center;
  color: var(--fg);
  opacity: .95;
}

#overlay_msg .buttons {
  display: flex;
  flex-direction: column;
  /* vertical stack, top->bottom */
  align-items: center;
  /* horizontally centered */
  gap: 8px;
  padding-top: 4px;
}

#overlay_msg .buttons button {
  background: #111827;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 120px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .12s ease;
}

#overlay_msg .buttons button:hover {
  color: var(--ac);
  border-color: var(--ac);
  background: rgba(124, 77, 255, .10);
  transform: translateY(-0.4px);
}

#overlay_msg .buttons button:focus {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

/* #endregion */

/* #region Input */

/* Layout & backdrop (same vibe as #overlay_msg) */
#overlay_input {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .45);
  z-index: 10000;
}

#overlay_input .box {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  width: min(40vw, 640px);
  /* default; can be overridden */
  min-width: 260px;
  max-width: 90vw;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}

#overlay_input .title {
  margin: 0 0 6px;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
}

#overlay_input .desc {
  margin: 6px 4px 12px;
  text-align: center;
  opacity: .95;
}

/* Fields grid */
#overlay_input .fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 6px;
}

#overlay_input .field {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

#overlay_input label {
  font-size: 12px;
  opacity: .9;
}

#overlay_input label.error {
  color: #7f1d1d;
}

#overlay_input input,
#overlay_input select {
  background: #111827;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}

#overlay_input input:focus,
#overlay_input select:focus {
  border-color: var(--ac);
  box-shadow: 0 0 0 2px rgba(124, 77, 255, .15);
}

/* Actions: cancel left, ok right */
#overlay_input .actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}

#overlay_input .actions .btn-cancel,
#overlay_input .actions .btn-ok {
  background: #111827;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  min-width: 110px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .12s;
}

#overlay_input .actions .btn-cancel:hover,
#overlay_input .actions .btn-ok:hover {
  color: var(--ac);
  border-color: var(--ac);
  background: rgba(124, 77, 255, .10);
  transform: translateY(-0.4px);
}


/* #endregion */

/* Global dark scrollbars (no left spacer) */
html {
  /* Firefox */
  scrollbar-color: var(--border) var(--bg);
  /* thumb, track */
  scrollbar-width: thin;

  /* Reserve only on the scrollbar side (usually the right), not both */
  scrollbar-gutter: stable;
}

/* Optional: keep thin on body too, but no gutter here */
body {
  scrollbar-width: thin;
}

/* WebKit (Chromium/Edge/Safari) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 2px solid var(--bg);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ac);
}

::-webkit-scrollbar-corner {
  background: var(--bg);
}