:root {
  --bg: #0f172a;
  --panel: #111827;
  --card: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #38bdf8;
  --border: #334155;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body.theme-light {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --card: #f8fafc;
  --text: #0f172a;
  --muted: #475569;
  --accent: #111827;
  --border: #cbd5e1;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(160deg, #020617 0%, #0f172a 100%);
  color: var(--text);
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

body.theme-light {
  background: linear-gradient(160deg, #e5e7eb 0%, #f8fafc 100%);
}

button,
input,
select,
label.file-picker-label {
  font: inherit;
}

button {
  min-height: 34px;
  border-radius: 8px;
  transition: filter 0.15s ease, transform 0.05s ease;
}

button:hover {
  filter: brightness(1.06);
}

button:active {
  transform: translateY(1px);
}

input {
  min-height: 34px;
}

.layout {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 4px 8px 8px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 6px;
  padding: 4px 2px 6px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.55);
  flex: 0 0 auto;
}

.topbar h1 {
  margin: 0;
  font-size: 1.7rem;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.brand-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "logo title"
    "logo subtitle";
  align-items: start;
  column-gap: 8px;
  row-gap: 0;
  min-width: 0;
  flex: 1 1 auto;
  max-width: 100%;
}

#brand-logo {
  grid-area: logo;
  width: auto;
  max-width: min(100%, 240px);
  height: clamp(36px, 5.2dvh, 68px);
  object-fit: contain;
  border-radius: 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.brand-wrap h1 {
  grid-area: title;
  margin: 2px 0 0;
  font-size: clamp(1.35rem, 1.65vw, 1.85rem);
  line-height: 1.1;
}

.brand-wrap p {
  grid-area: subtitle;
  margin: 0;
  font-size: clamp(0.88rem, 1.05vw, 1rem);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-top: 2px;
  font-size: 0.88rem;
  max-width: 100%;
}

.banque-temps-snapshot-line {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

body.theme-light .banque-temps-snapshot-line {
  color: #475569;
}

.topbar-right button {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
  color: var(--text);
  cursor: pointer;
}

.theme-switch {
  position: relative;
  display: inline-flex;
  width: 54px;
  height: 30px;
  align-items: center;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-slider {
  position: absolute;
  inset: 0;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.theme-slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.2s ease;
}

.theme-switch input:checked + .theme-slider::before {
  transform: translateX(24px);
}

body.theme-light .theme-slider {
  background: #ffffff;
}

body.theme-light .topbar-right button,
body.theme-light .admin-actions button,
body.theme-light .embedded-actions button,
body.theme-light .file-picker-label,
body.theme-light .tab-btn,
body.theme-light .app-form input,
body.theme-light .app-form button,
body.theme-light .login-form input,
body.theme-light .login-form button,
body.theme-light .login-form select {
  background: #ffffff;
}

body.theme-light .drop-panel {
  background: #ffffff;
  border-color: #cbd5e1;
}

body.theme-light .apps-sidebar {
  background: #ffffff;
  border-color: #cbd5e1;
}

body.theme-light .apps-sidebar h3,
body.theme-light .apps-sidebar p,
body.theme-light .online-users,
body.theme-light #role-text,
body.theme-light #view-mode-text {
  color: #0f172a;
}

body.theme-light .app-card {
  background: #f8fafc;
  border-color: #cbd5e1;
}

body.theme-light .app-card h3,
body.theme-light .app-card p {
  color: #0f172a;
}

body.theme-light .app-card a,
body.theme-light .app-card button {
  background: #111827;
  color: #ffffff;
}

body.theme-light .drop-zone {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

body.theme-light .drop-zone strong,
body.theme-light .drop-zone p {
  color: #0f172a;
}

body.theme-light .drop-zone.is-dragging {
  background: #e2e8f0;
  border-color: #334155;
}

body.theme-light .embedded-panel {
  background: #ffffff;
  border-color: #cbd5e1;
}

body.theme-light .embedded-header {
  border-bottom-color: #cbd5e1;
}

body.theme-light .preview-wrap {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

body.theme-light .preview-list,
body.theme-light .preview-list li {
  color: #0f172a;
}

body.theme-light .message {
  color: #b91c1c;
}

.panel {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  min-height: 0;
  overflow: visible;
}

#hub-panel.panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  margin-bottom: 0;
  padding: 8px 10px 10px;
}

#settings-section {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.hub-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 8px;
  flex: 0 0 auto;
}

.hub-toolbar .section-tabs {
  margin-bottom: 0;
}

.hub-toolbar-message {
  margin: 0;
  flex: 1 1 200px;
  min-width: 0;
  text-align: right;
  font-size: 0.9rem;
  line-height: 1.3;
}

.section-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
  color: var(--text);
  cursor: pointer;
}

.tab-btn.is-active {
  background: var(--accent);
  color: #082032;
  font-weight: 700;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.panel-header p {
  margin: 5px 0 16px;
  color: var(--muted);
}

/* --- Ecran connexion (carte centree) --- */
.login-screen .topbar {
  padding-bottom: 10px;
  margin-bottom: 4px;
}

.login-screen .layout {
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: 32px;
}

.login-screen #login-panel.login-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px 32px;
  margin-bottom: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 28px 26px 22px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.1),
    0 28px 60px -20px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.login-card-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #0284c7, var(--accent), #22d3ee);
  opacity: 0.9;
}

.login-card-header {
  margin-bottom: 18px;
}

.login-card-header h2 {
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}

.login-card-header p {
  margin-bottom: 0;
}

.login-form-stacked {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field-label-text {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-form-stacked input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-form-stacked input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22);
}

.login-submit-btn {
  margin-top: 4px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #0ea5e9, var(--accent));
  color: #082032;
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.38);
}

body.theme-light .login-submit-btn {
  color: #f8fafc;
  background: linear-gradient(135deg, #0369a1, #0c4a6e);
  box-shadow: 0 4px 14px rgba(3, 105, 161, 0.28);
}

.login-footnote {
  margin: 18px 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

.login-message-slot {
  margin-top: 14px;
  text-align: center;
}

.force-password-panel {
  max-width: 440px;
  margin: 0 auto 12px;
}

.force-password-lead {
  margin-top: 4px;
  margin-bottom: 16px;
}

body.theme-light .login-card {
  background: #ffffff;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.06),
    0 22px 48px -18px rgba(15, 23, 42, 0.14);
}

body.theme-light .login-form-stacked input {
  background: #ffffff;
}

.app-form {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr 1fr auto 1.2fr auto;
}

.login-form {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr auto;
}

#create-user-form {
  grid-template-columns: 1fr 1fr 1fr auto;
}

.app-form input,
.app-form button,
.login-form input,
.login-form button,
.login-form select {
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
}

.app-form button,
.login-form button {
  cursor: pointer;
}

.message {
  color: #fb7185;
  margin: 8px 0 0;
}

.message:empty {
  display: none;
  margin: 0;
}

.inline-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.apps-shell {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 2px;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.apps-shell > * {
  min-height: 0;
}

.apps-sidebar {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1220;
  padding: 6px;
  align-self: stretch;
  overflow-x: hidden;
  overflow-y: auto;
}

.apps-sidebar h3 {
  margin: 0 0 4px;
}

.apps-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.apps-main > .drop-panel {
  flex: 0 0 auto;
}

.app-form {
  order: 1;
}

#drop-panel {
  order: 2;
}

#app-editor-panel {
  order: 3;
}

.apps-list {
  display: grid;
  gap: 6px;
  grid-auto-rows: auto;
}

.app-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.app-card[draggable="true"] {
  cursor: grab;
}

.app-card.is-dragging {
  opacity: 0.55;
}

.app-card.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.online-users {
  color: var(--muted);
  margin: 4px 0 6px;
}

.app-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  min-height: 1.35em;
}

.app-icon-wrap {
  margin: 0 0 6px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0b1220;
}

.app-icon {
  width: 100%;
  height: 78px;
  object-fit: cover;
  display: block;
  background: #ffffff;
}

.app-card.has-icon .app-icon-wrap {
  position: absolute;
  inset: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  z-index: 0;
  opacity: 0.22;
}

.app-card.has-icon .app-icon {
  width: 100%;
  height: 100%;
}

.app-card.has-icon h3,
.app-card.has-icon p,
.app-card.has-icon .app-actions {
  position: relative;
  z-index: 1;
}

.app-card p {
  margin: 0 0 10px;
  min-height: 2em;
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1 1 auto;
}

.app-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: auto;
}

.app-card a,
.app-card button {
  text-decoration: none;
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--accent);
  color: #082032;
  font-weight: 700;
  border: 0;
  cursor: pointer;
  justify-content: center;
  width: 100%;
  min-height: 30px;
}

.embedded-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.embedded-actions button {
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  padding: 7px 10px;
  cursor: pointer;
}

.drop-panel {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #0b1220;
}

.apps-main > .drop-panel {
  margin-top: 0;
}

.drop-panel h3 {
  margin: 0 0 8px;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
}

.file-picker-label {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.app-icon-upload-label {
  min-height: 34px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.file-picker-label input {
  display: none;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  width: 100%;
}

.editor-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  min-width: 0;
}

.editor-grid input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
}

.editor-footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

#app-editor-panel .admin-actions {
  margin-top: 10px;
}

#app-editor-panel .admin-actions button,
#app-editor-panel .admin-actions .file-picker-label {
  flex: 0 0 auto;
}

.editor-status {
  color: var(--muted);
  font-size: 0.85rem;
}

.editor-status.is-ok {
  color: #22c55e;
  font-weight: 600;
}

body.theme-light .editor-grid input {
  background: #ffffff;
}

.preview-wrap {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  max-height: 220px;
  overflow: auto;
}

.preview-list {
  margin: 0;
  padding-left: 18px;
}

.settings-intro {
  margin: 0 0 12px;
  max-width: 70ch;
}

.settings-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.12);
}

.settings-card h4 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.settings-card > .inline-help {
  margin: 0 0 10px;
}

body.theme-light .settings-card {
  background: rgba(0, 0, 0, 0.03);
}

.admin-users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.admin-user-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
}

body.theme-light .admin-user-row {
  background: #f8fafc;
}

.admin-user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.admin-user-name {
  font-weight: 600;
  word-break: break-word;
}

.admin-user-role {
  font-size: 0.82rem;
  color: var(--muted);
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-user-actions button {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  cursor: pointer;
  font-size: 0.88rem;
}

body.theme-light .admin-user-actions button {
  background: #fff;
}

.admin-user-actions .admin-user-delete-btn {
  border-color: rgba(251, 113, 133, 0.45);
  color: #fb7185;
}

.edit-user-dialog {
  max-width: min(480px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}

.edit-user-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.edit-user-form {
  padding: 18px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.edit-user-dialog-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.edit-user-form .field-label {
  margin: 0;
}

.edit-user-form input[type="text"],
.edit-user-form input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
}

body.theme-light .edit-user-form input[type="text"],
body.theme-light .edit-user-form input[type="password"] {
  background: #fff;
}

.edit-user-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.edit-user-dialog-actions button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.9rem;
}

.edit-user-dialog-actions button[type="submit"] {
  background: var(--accent);
  color: #082032;
  font-weight: 600;
  border-color: transparent;
}

#edit-user-cancel-btn {
  background: transparent;
  color: var(--text);
}

.create-user-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.create-user-credentials {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 560px) {
  .create-user-credentials {
    grid-template-columns: 1fr;
  }
}

.create-user-form input[type="text"],
.create-user-form input[type="password"],
.create-user-form button[type="submit"] {
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
}

.create-user-form button[type="submit"] {
  cursor: pointer;
  align-self: flex-start;
}

.role-choice-fieldset {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.role-choice-fieldset legend {
  padding: 0 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.role-radio-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.role-radio-label:first-of-type {
  margin-top: 4px;
}

.role-radio-label input[type="radio"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.role-radio-label strong {
  color: var(--text);
}

.role-radio-desc {
  color: var(--muted);
}

body.theme-light .create-user-form input[type="text"],
body.theme-light .create-user-form input[type="password"],
body.theme-light .create-user-form button[type="submit"] {
  background: #ffffff;
}

.create-user-toggle-btn {
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  margin-bottom: 4px;
}

.create-user-collapsible {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

body.theme-light .create-user-toggle-btn {
  background: #ffffff;
}

.create-user-apps-wrap {
  margin-top: 4px;
}

.create-user-apps-intro {
  margin: 0 0 8px;
}

.create-user-restrict-label {
  margin-bottom: 6px;
}

.create-user-app-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px 10px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
}

.create-user-app-pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text);
}

.create-user-app-pick-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

body.theme-light .create-user-app-checkboxes {
  background: rgba(0, 0, 0, 0.04);
}

.import-folder-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

.import-folder-form--card {
  border-top: none;
  margin-top: 0;
  padding: 0;
}

.import-folder-heading {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.import-folder-help {
  margin: 0;
}

.import-folder-main-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.import-folder-path-input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
}

.import-folder-main-row button {
  flex: 0 0 auto;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  cursor: pointer;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  user-select: none;
}

.checkbox-inline input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.import-folder-advanced {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.15);
}

.import-folder-advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
}

.import-folder-advanced-fields {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.import-folder-advanced-fields input {
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  min-width: 0;
}

body.theme-light .import-folder-path-input,
body.theme-light .import-folder-main-row button,
body.theme-light .import-folder-advanced-fields input {
  background: #ffffff;
}

.settings-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.settings-subnav-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
}

.settings-subnav-btn:hover {
  filter: brightness(1.06);
}

.settings-subnav-btn.is-active {
  background: var(--accent);
  color: #082032;
  font-weight: 700;
  border-color: rgba(56, 189, 248, 0.35);
}

.settings-panels {
  min-height: 60px;
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-compact-form {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  max-width: 420px;
  grid-template-columns: unset !important;
}

.settings-compact-form input,
.settings-compact-form button {
  width: 100%;
}

.settings-select {
  max-width: 280px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  font: inherit;
}

.admin-message-global {
  margin-top: 4px;
}

body.theme-light .settings-subnav-btn {
  background: #ffffff;
}

body.theme-light .settings-subnav-btn.is-active {
  color: #f8fafc;
  background: linear-gradient(135deg, #0369a1, #0c4a6e);
  border-color: #0369a1;
}

body.theme-light .settings-select {
  background: #ffffff;
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.activity-title {
  margin: 0;
  align-self: center;
}

.admin-actions button {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  cursor: pointer;
}

.automation-list {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.automation-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: #0b1220;
}

.automation-item p {
  margin: 3px 0 0;
  color: var(--muted);
}

.automation-item button {
  border: 1px solid var(--border);
  background: var(--accent);
  color: #082032;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.automation-output {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #020617;
  color: #cbd5e1;
  padding: 10px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
}

.activity-log-list {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 10px 10px 24px;
  max-height: 260px;
  overflow: auto;
  background: #020617;
}

body.theme-light .activity-log-list {
  background: #ffffff;
}

.embedded-panel {
  margin: 0;
  padding: 0;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  order: 4;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
}

.embedded-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 5px 8px;
  gap: 6px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.embedded-header h3 {
  display: block;
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.15;
}

#app-frame {
  flex: 1 1 auto;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #ffffff;
}

@media (max-width: 900px) {
  .app-form,
  .login-form {
    grid-template-columns: 1fr;
  }

  .apps-shell {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .apps-sidebar {
    flex: 0 1 auto;
    max-height: min(42dvh, 360px);
    overflow-y: auto;
  }

  .apps-main {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-top: 4px;
  }

  .topbar-right {
    justify-content: flex-start;
    width: 100%;
  }

  #brand-logo {
    max-width: min(100%, 260px);
    height: clamp(36px, 5.5dvh, 64px);
  }

  .panel {
    min-height: auto;
  }

  #app-frame {
    min-height: 0;
  }
}
