:root {
  --bg: #1b1e22;
  --panel: #24282e;
  --panel-border: #333941;
  --text: #e8e6e1;
  --text-muted: #8b9099;
  --ok: #5fd97a;
  --printing: #f5a623;
  --stopped: #e5484d;
  --unknown: #5c6370;
  --accent-font: ui-sans-serif, "Segoe UI", system-ui, sans-serif;
  --mono-font: ui-monospace, "SF Mono", Consolas, monospace;
}

[hidden] {
  display: none !important;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--accent-font);
  -webkit-font-smoothing: antialiased;
}

.panel-frame {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.console-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 16px;
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding-top: 12px;
}

.console-header__title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.console-header__title h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.console-header__meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Status LEDs — the signature element: a small physical indicator light,
   echoing the LED on a real printer's control panel. Pulses while printing. */
.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  background: var(--unknown);
  box-shadow: 0 0 0 rgba(0,0,0,0);
}
.led--idle { background: var(--ok); box-shadow: 0 0 6px color-mix(in srgb, var(--ok) 60%, transparent); }
.led--printing { background: var(--printing); box-shadow: 0 0 6px color-mix(in srgb, var(--printing) 60%, transparent); animation: pulse 1.1s ease-in-out infinite; }
.led--stopped { background: var(--stopped); box-shadow: 0 0 6px color-mix(in srgb, var(--stopped) 60%, transparent); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .led--printing { animation: none; }
}

.banner {
  border: 1px solid var(--stopped);
  background: color-mix(in srgb, var(--stopped) 12%, var(--panel));
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.banner__hint { color: var(--text-muted); margin-top: 6px; font-size: 0.82rem; }

.printer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px;
}

.card__top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.card__name {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
  overflow-wrap: anywhere;
}

.tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bg);
  background: var(--text-muted);
  border-radius: 3px;
  padding: 2px 6px;
}

.card__facts {
  margin: 0;
  display: grid;
  gap: 8px;
}
.card__facts > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
}
.card__facts dt {
  color: var(--text-muted);
}
.card__facts dd {
  margin: 0;
  text-align: right;
}
.mono { font-family: var(--mono-font); font-size: 0.8rem; }

.empty-state {
  grid-column: 1 / -1;
  color: var(--text-muted);
  border: 1px dashed var(--panel-border);
  border-radius: 8px;
  padding: 32px;
  text-align: center;
}

/* --- Banner variants --- */
.banner--warn {
  border-color: var(--printing);
  background: color-mix(in srgb, var(--printing) 12%, var(--panel));
}
.banner--warn a { color: var(--printing); }
.banner--ok {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, var(--panel));
}

/* --- Header right side / nav --- */
.console-header__right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.console-header__nav {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}
.console-header__nav a {
  color: var(--text-muted);
  text-decoration: none;
}
.console-header__nav a:hover { color: var(--text); }

/* --- Buttons --- */
.btn {
  font-family: inherit;
  font-size: 0.85rem;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  border-radius: 5px;
  padding: 7px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--text-muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn--sm { padding: 4px 9px; font-size: 0.78rem; }
.btn--primary { background: var(--ok); border-color: var(--ok); color: #0d1a10; font-weight: 600; }
.btn--primary:hover { background: color-mix(in srgb, var(--ok) 85%, white); }
.btn--danger { border-color: var(--stopped); color: var(--stopped); }
.btn--danger:hover { background: color-mix(in srgb, var(--stopped) 14%, var(--panel)); }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.link-btn:hover { color: var(--text); }

/* --- Forms --- */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.field span { color: var(--text-muted); }
.field input, .field select {
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  padding: 8px 10px;
  color: var(--text);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--ok);
}
.field-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}
.field-row .field { flex: 1; }
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.form-error {
  color: var(--stopped);
  font-size: 0.8rem;
}
.card--form {
  margin-bottom: 20px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card--form .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card--form .field input,
.card--form .field select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.card--form .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* --- Add-printer section --- */
.add-printer { margin-bottom: 20px; }
#add-printer-form { margin-top: 12px; max-width: 640px; }

/* --- Card actions / edit form --- */
.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.edit-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
}

/* --- Jobs panel --- */
.card__jobs { margin-top: 10px; }
.jobs-empty { color: var(--text-muted); font-size: 0.8rem; margin: 8px 0 0; }
.jobs-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.jobs-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  padding: 6px 8px;
}
.jobs-list__title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobs-list__actions { display: flex; gap: 6px; }
.jobs-list__actions button {
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  border-radius: 4px;
  font-size: 0.72rem;
  padding: 2px 6px;
  cursor: pointer;
}
.jobs-list__actions button:hover { color: var(--text); border-color: var(--text-muted); }

.job-download { color: var(--text); text-decoration: underline; }
.job-download:hover { color: var(--ok); }

.status-badge {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
}
.status-badge--pending { background: color-mix(in srgb, var(--printing) 20%, transparent); color: var(--printing); }
.status-badge--success { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.status-badge--failed { background: color-mix(in srgb, var(--stopped) 20%, transparent); color: var(--stopped); }
.status-badge--unknown { background: color-mix(in srgb, var(--unknown) 25%, transparent); color: var(--text-muted); }

/* --- Auth pages (login / account) --- */
.auth-frame {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 28px;
}
.auth-card__title {
  font-size: 1.2rem;
  margin: 0 0 18px;
  text-align: center;
}

/* --- Tabs (settings page) --- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 20px;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 8px 4px;
  margin-right: 18px;
  cursor: pointer;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.is-active { color: var(--text); border-bottom-color: var(--ok); }

/* --- Checkbox list (admin access page) --- */
.checkbox-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.checkbox-item input { width: auto; }

/* --- Grouped printer/profile access list (admin access page) --- */
.printer-access-list { display: grid; gap: 12px; margin-bottom: 16px; }
.printer-access-group {
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 10px 12px;
}
.checkbox-item--printer { font-size: 0.9rem; }
.printer-access-group__profiles {
  margin: 8px 0 0 24px;
  padding-left: 12px;
  border-left: 2px solid var(--panel-border);
  display: grid;
  gap: 6px;
}

/* --- Shared app nav (Jobs/Files/Users/Guide/Settings tabs) --- */
.app-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--panel-border);
  padding: 12px 0;
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}
.app-nav__link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 5px;
}
.app-nav__link:hover { color: var(--text); background: var(--panel); }
.app-nav__link.is-active { color: var(--text); background: var(--panel); font-weight: 600; }
.app-nav__spacer { flex: 1; }
.app-nav__user { font-size: 0.8rem; color: var(--text-muted); margin-right: 4px; }

/* --- Footer (every page, via base.html) --- */
.app-footer {
  max-width: 1080px;
  margin: 40px auto 0;
  padding: 16px 20px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--panel-border);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.app-footer__links { display: flex; gap: 14px; }
.app-footer__links a { color: var(--text-muted); text-decoration: none; }
.app-footer__links a:hover { color: var(--text); }

/* --- Jobs & History table --- */
.jobs-table {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.jobs-table__row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.jobs-table__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 200px;
}
.jobs-table__meta { font-size: 0.78rem; color: var(--text-muted); }
.jobs-table__time { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.jobs-table__actions { display: flex; gap: 6px; }

/* --- Landing page (public, logged-out homepage) --- */
.landing {
  max-width: 960px;
  margin: 0 auto;
  padding: 60px 20px 80px;
}
.landing__hero {
  text-align: center;
  margin-bottom: 56px;
}
.landing__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 5px 14px;
  margin-bottom: 20px;
}
.landing__title {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}
.landing__tagline {
  color: var(--ok);
  font-size: 0.95rem;
  font-weight: 600;
  margin: -8px 0 18px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.landing__subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto 28px;
  line-height: 1.5;
}
.landing__cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.landing__cta .btn { padding: 10px 22px; font-size: 0.95rem; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 56px;
}
.feature-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 20px;
}
.feature-card img {
  width: 28px;
  height: 28px;
  margin-bottom: 14px;
}
.feature-card h3 {
  font-size: 0.95rem;
  margin: 0 0 8px;
}
.feature-card p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
}

.landing__section-title {
  font-size: 1.1rem;
  margin: 0 0 18px;
  text-align: center;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
}

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 56px;
}
.workflow-step {
  border-left: 2px solid var(--ok);
  padding-left: 14px;
}
.workflow-step__num {
  font-family: var(--mono-font);
  color: var(--ok);
  font-size: 0.8rem;
}
.workflow-step h4 { margin: 4px 0 6px; font-size: 0.9rem; }
.workflow-step p { margin: 0; color: var(--text-muted); font-size: 0.82rem; line-height: 1.5; }

.landing__footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--panel-border);
  padding-top: 24px;
}
.landing__footer a { color: var(--text-muted); }

/* --- Docs / guide page --- */
.docs {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  line-height: 1.65;
}
.docs h2 { margin-top: 40px; font-size: 1.15rem; }
.docs h3 { font-size: 1rem; color: var(--text-muted); }
.docs code {
  font-family: var(--mono-font);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.85em;
}
.docs .card__facts { margin-top: 8px; }
.docs-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}
.docs-nav a { color: var(--text-muted); text-decoration: none; font-size: 0.85rem; }
.docs-nav a:hover { color: var(--text); }

/* --- Print documents section --- */
.print-documents { margin-bottom: 36px; }
.profile-grid--big {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.profile-grid--big .card { padding: 24px; }
.profile-grid--big .card__name { font-size: 1.15rem; }
.profile-grid--big .card__facts { font-size: 0.95rem; margin: 14px 0; }
.profile-grid--big .card__actions .btn--primary {
  flex: 1;
  padding: 12px;
  font-size: 0.95rem;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-heading h2 { font-size: 1.05rem; margin: 0; }
.section-subheading {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 24px 0 10px;
}
#new-profile-form { margin-bottom: 16px; }
.profile-grid { margin-bottom: 4px; }
#quick-print-file {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Modal dialog (clone profile) --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--panel-border);
}
.modal__header h2 {
  margin: 0;
  font-size: 1rem;
}
.modal__close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal__close:hover {
  color: var(--text);
}
.modal__body {
  padding: 20px;
}

/* ============================================================
   Mobile Responsiveness & Dialog Overflow Fixes
   ============================================================ */

/* Mobile-first: stack layouts on small screens */
@media (max-width: 768px) {
  .panel-frame {
    padding: 16px 12px 40px;
  }

  .console-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .console-header__title h1 {
    font-size: 1.2rem;
  }

  .console-header__right {
    width: 100%;
    flex-direction: column;
    gap: 12px;
  }

  .console-header__meta {
    font-size: 0.8rem;
  }

  .printer-grid {
    grid-template-columns: 1fr;
  }

  .profile-grid--big {
    grid-template-columns: 1fr;
  }

  .field-row {
    flex-direction: column;
    gap: 8px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .modal {
    width: 95%;
    max-height: 95vh;
    border-radius: 8px;
  }

  .modal__header {
    padding: 16px;
  }

  .modal__body {
    padding: 16px;
    max-height: calc(95vh - 60px);
    overflow-y: auto;
  }

  .modal__header h2 {
    font-size: 0.95rem;
    max-width: calc(100% - 40px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .card__actions {
    gap: 4px;
  }

  .card__actions .btn {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.75rem;
    padding: 6px 8px;
  }

  .card--form {
    max-width: 100%;
    overflow-x: hidden;
  }

  .field input,
  .field select {
    min-width: 0;
    width: 100%;
  }

  .app-nav {
    flex-wrap: wrap;
  }

  .app-nav__link {
    font-size: 0.8rem;
    padding: 4px 8px;
  }

  .app-footer {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }

  .app-footer__links {
    justify-content: center;
    gap: 10px;
    width: 100%;
  }

  .landing {
    padding: 40px 16px 60px;
  }

  .landing__title {
    font-size: 1.6rem;
  }

  .landing__subtitle {
    font-size: 0.95rem;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .workflow-steps {
    grid-template-columns: 1fr;
  }

  .card__name {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .jobs-table__row {
    flex-direction: column;
    gap: 8px;
  }

  .jobs-table__main {
    width: 100%;
  }

  .jobs-table__time {
    width: 100%;
  }

  .jobs-table__actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 480px) {
  .panel-frame {
    padding: 12px 10px 30px;
  }

  .console-header__title h1 {
    font-size: 1.1rem;
  }

  .btn {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  .btn--sm {
    padding: 3px 7px;
    font-size: 0.7rem;
  }

  .field {
    font-size: 0.8rem;
  }

  .field input,
  .field select {
    font-size: 0.85rem;
    padding: 6px 8px;
  }

  .card {
    padding: 12px;
  }

  .card__facts {
    gap: 6px;
  }

  .card__facts > div {
    font-size: 0.78rem;
    flex-direction: column;
    justify-content: flex-start;
    gap: 2px;
  }

  .modal {
    width: 98%;
  }

  .modal__header {
    padding: 12px;
  }

  .modal__body {
    padding: 12px;
  }

  .card__actions .btn {
    font-size: 0.7rem;
    padding: 5px 6px;
  }

  .landing__title {
    font-size: 1.4rem;
  }

  .auth-card {
    max-width: 95%;
    padding: 20px;
  }
}



details {
  width: 100%;
  overflow: hidden;
}

details summary {
  cursor: pointer;
  user-select: none;
}

/* --- Toast notifications --- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 12px 16px;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s ease-out;
}
.toast--error { border-color: var(--stopped); color: var(--stopped); }
.toast--success { border-color: var(--ok); color: var(--ok); }
@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

