/* -----------------------------------------------------------------------------
   Boot / loading
----------------------------------------------------------------------------- */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 30%, var(--primary-soft), transparent 45%),
    var(--bg);
  color: var(--text-muted);
  transition: opacity var(--transition), visibility var(--transition);
}

.boot-screen.is-leaving {
  opacity: 0;
  visibility: hidden;
}

.boot-screen p {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.boot-mark {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: var(--shadow-md);
}

.boot-mark svg {
  width: 38px;
  height: 38px;
}

.boot-error {
  position: fixed;
  inset: 0;
  z-index: 9100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.boot-error-card {
  width: min(100%, 560px);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.boot-error-card h1 {
  font-size: 22px;
  margin-bottom: 10px;
}

.boot-error-card p {
  color: var(--text-muted);
  margin-bottom: 18px;
}

.boot-error-card pre {
  max-height: 220px;
  overflow: auto;
  padding: 14px;
  margin: 0 0 18px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* -----------------------------------------------------------------------------
   Buttons
----------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  user-select: none;
}

.btn:hover {
  filter: brightness(0.98);
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn-primary {
  --btn-bg: var(--primary);
  --btn-fg: var(--primary-contrast);
  --btn-border: var(--primary);
  box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--primary) 75%, transparent);
}

.btn-primary:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  filter: none;
}

.btn-secondary {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--text-muted);
  --btn-border: transparent;
}

.btn-ghost:hover {
  --btn-fg: var(--text);
  background: var(--surface-3);
}

.btn-danger {
  --btn-bg: var(--danger);
  --btn-fg: #fff;
  --btn-border: var(--danger);
}

.btn-danger:hover {
  filter: brightness(0.92);
}

.btn-warning {
  --btn-bg: var(--warning-soft);
  --btn-fg: var(--warning);
  --btn-border: var(--warning-border);
}

.btn-sm {
  min-height: 34px;
  padding: 6px 11px;
  font-size: 13px;
  border-radius: var(--radius-xs);
}

.btn-lg {
  min-height: 50px;
  padding: 12px 22px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.62;
  pointer-events: none;
}

.btn.is-loading .btn-label {
  opacity: 0.8;
}

.btn.is-loading::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

/* -----------------------------------------------------------------------------
   Forms
----------------------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field > label,
.field-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.field-hint.is-ok {
  color: var(--success);
}

.field-hint.is-error,
.field-error {
  color: var(--danger);
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.input-shell:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}

.input-shell.is-invalid {
  border-color: var(--danger);
}

.input-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--text-soft);
  flex: none;
}

.input-icon svg {
  width: 19px;
  height: 19px;
}

.input-shell input,
.input-shell select,
.input-shell textarea {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px 0 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
}

.input-shell textarea {
  min-height: 110px;
  padding: 12px;
  resize: vertical;
}

.input-shell select {
  appearance: none;
  cursor: pointer;
  padding-right: 36px;
}

.input-shell.has-select::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-soft);
  border-bottom: 2px solid var(--text-soft);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.input-action {
  width: 42px;
  height: 42px;
  margin-right: 2px;
  border-radius: var(--radius-xs);
}

.input-shell input::placeholder,
.input-shell textarea::placeholder {
  color: var(--text-soft);
  opacity: 0.85;
}

.input-plain {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 0;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-plain:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}

.input-plain.is-invalid {
  border-color: var(--danger);
}

textarea.input-plain {
  min-height: 120px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid .field-full {
  grid-column: 1 / -1;
}

.char-count {
  align-self: flex-end;
  font-size: 11px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

/* -----------------------------------------------------------------------------
   Alerts / notices
----------------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.45;
}

.alert svg {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
}

.alert-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.alert-warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: var(--warning-border);
}

.alert-success {
  color: var(--success);
  background: var(--success-soft);
  border-color: var(--success-border);
}

.alert-info {
  color: var(--info);
  background: var(--info-soft);
  border-color: var(--info-border);
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 13px;
}

/* -----------------------------------------------------------------------------
   Badges
----------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.015em;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge-critico {
  color: #b91c1c;
  background: #fee2e2;
  border-color: #fecaca;
}

.badge-urgente {
  color: #c2410c;
  background: #ffedd5;
  border-color: #fed7aa;
}

.badge-alta {
  color: #a16207;
  background: #fef9c3;
  border-color: #fef08a;
}

.badge-media {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #bfdbfe;
}

.badge-normal {
  color: #475569;
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.badge-primary {
  background: var(--primary-soft);
  border-color: var(--border);
  color: var(--primary);
}

.badge-status-n {
  color: var(--info);
  background: var(--info-soft);
  border-color: var(--info-border);
}

.badge-status-d {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: var(--warning-border);
}

.badge-status-e {
  color: var(--text-muted);
  background: var(--surface-3);
  border-color: var(--border);
}

.badge-soft {
  color: var(--text-muted);
  background: var(--surface-3);
  border-color: var(--border);
}

[data-theme="dark"] .badge-critico {
  color: #fca5a5;
  background: #3b1216;
  border-color: #57222a;
}

[data-theme="dark"] .badge-urgente {
  color: #fdba74;
  background: #3a1d09;
  border-color: #5a2e0d;
}

[data-theme="dark"] .badge-alta {
  color: #fde047;
  background: #352b06;
  border-color: #55460a;
}

[data-theme="dark"] .badge-media {
  color: #93c5fd;
  background: #12233f;
  border-color: #1e3a63;
}

[data-theme="dark"] .badge-normal {
  color: #cbd5e1;
  background: #1e293b;
  border-color: #334155;
}

[data-theme="gray"] .badge-critico {
  color: #991b1b;
  background: #efd2d2;
  border-color: #dba9a9;
}

[data-theme="gray"] .badge-urgente {
  color: #9a3412;
  background: #f0dcc9;
  border-color: #dcc0a2;
}

[data-theme="gray"] .badge-alta {
  color: #854d0e;
  background: #ede4c4;
  border-color: #dbcd9e;
}

[data-theme="gray"] .badge-media {
  color: #1e40af;
  background: #d6deef;
  border-color: #b4c2df;
}

/* -----------------------------------------------------------------------------
   Header
----------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.header-inner {
  width: min(100% - 32px, var(--container));
  min-height: var(--header-height);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: var(--shadow-sm);
  flex: none;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-mark-lg {
  width: 52px;
  height: 52px;
  border-radius: 17px;
}

.brand-mark-lg svg {
  width: 30px;
  height: 30px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.brand-name {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.09em;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--text-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-link svg {
  width: 16px;
  height: 16px;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-3);
  text-decoration: none;
}

.nav-link.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

.header-spacer {
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
}

.user-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  flex: none;
  text-transform: uppercase;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
  padding-right: 4px;
}

.user-name {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.user-unit {
  font-size: 10.5px;
  color: var(--text-soft);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.theme-btn {
  position: relative;
}

/* -----------------------------------------------------------------------------
   Toasts
----------------------------------------------------------------------------- */
.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in 0.22s var(--transition);
}

.toast.is-leaving {
  animation: toast-out 0.18s ease forwards;
}

.toast svg {
  width: 19px;
  height: 19px;
  flex: none;
  margin-top: 1px;
}

.toast-message {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.45;
}

.toast-close {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  padding: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
}

.toast-close:hover {
  background: var(--surface-3);
  color: var(--text);
}

.toast-success {
  border-color: var(--success-border);
}

.toast-success svg {
  color: var(--success);
}

.toast-error {
  border-color: var(--danger-border);
}

.toast-error svg {
  color: var(--danger);
}

.toast-warning {
  border-color: var(--warning-border);
}

.toast-warning svg {
  color: var(--warning);
}

.toast-info svg {
  color: var(--info);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

/* -----------------------------------------------------------------------------
   Dialogs / modal
----------------------------------------------------------------------------- */
dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.login-dialog {
  width: min(980px, calc(100vw - 32px));
  max-width: 980px;
  max-height: calc(100dvh - 32px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-login);
  overflow: hidden;
}

.login-dialog[open] {
  animation: dialog-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-shell {
  display: grid;
  grid-template-columns: 0.92fr 1.08fr;
  min-height: 610px;
  max-height: calc(100dvh - 32px);
  background: var(--surface);
  overflow: auto;
}

.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 38px 34px;
  background: var(--login-brand-bg);
  color: var(--login-brand-text);
  overflow: hidden;
}

.login-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 75%);
  pointer-events: none;
}

.login-brand > * {
  position: relative;
  z-index: 1;
}

.login-brand-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand .brand-mark {
  background: rgba(255, 255, 255, 0.12);
  color: #5eead4;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

.login-brand .eyebrow {
  color: var(--login-brand-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  margin-bottom: 4px;
}

.login-brand h1 {
  color: var(--login-brand-text);
  font-size: 27px;
  letter-spacing: 0.16em;
  font-weight: 800;
}

.login-brand-copy {
  color: var(--login-brand-muted);
  font-size: 15px;
  line-height: 1.65;
  max-width: 34ch;
}

.login-brand-list {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-top: auto;
}

.login-brand-list li {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13px;
  color: var(--login-brand-muted);
}

.login-brand-list li span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2dd4bf;
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.16);
  flex: none;
}

.login-brand-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--login-brand-muted);
  font-size: 11.5px;
  letter-spacing: 0.03em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.16);
  flex: none;
}

.login-panel {
  display: flex;
  flex-direction: column;
  padding: 34px clamp(24px, 5vw, 58px) 30px;
  background: var(--surface);
  overflow: auto;
}

.login-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 30px;
}

.login-topbar-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.login-heading {
  margin-bottom: 24px;
}

.login-heading h2 {
  font-size: clamp(24px, 3vw, 30px);
  margin-bottom: 8px;
}

.login-heading p {
  color: var(--text-muted);
  font-size: 14px;
}

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

.login-form .btn-block {
  margin-top: 6px;
}

.login-footnote {
  margin-top: auto;
  padding-top: 30px;
  color: var(--text-soft);
  font-size: 11.5px;
  line-height: 1.5;
  max-width: 46ch;
}

.login-dialog .icon-btn {
  border-color: var(--border);
  background: var(--surface-2);
}

/* Generic application modal */
.app-modal {
  width: min(680px, calc(100vw - 28px));
  max-width: 680px;
  max-height: calc(100dvh - 28px);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.app-modal.modal-lg {
  width: min(920px, calc(100vw - 28px));
  max-width: 920px;
}

.app-modal[open] {
  animation: dialog-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal-layout {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 28px);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal-head-text {
  flex: 1;
  min-width: 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 750;
  line-height: 1.25;
}

.modal-subtitle {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.modal-close {
  flex: none;
  margin: -4px -4px 0 0;
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 22px;
  overscroll-behavior: contain;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.modal-foot-split {
  justify-content: space-between;
}

/* small confirm modal */
.confirm-message {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/* -----------------------------------------------------------------------------
   Empty / skeleton
----------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: clamp(36px, 8vw, 70px) 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  text-align: center;
}

.empty-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: 4px;
}

.empty-icon svg {
  width: 27px;
  height: 27px;
}

.empty-state h3 {
  font-size: 17px;
}

.empty-state p {
  max-width: 46ch;
  color: var(--text-muted);
  font-size: 13.5px;
}

.empty-state .btn {
  margin-top: 8px;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: var(--radius-xs);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--skeleton);
  background-size: 400% 100%;
  animation: shimmer 1.25s ease-in-out infinite;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

.skeleton-card {
  min-height: 178px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-line {
  height: 12px;
  border-radius: 999px;
}

.skeleton-line.w-30 {
  width: 30%;
}

.skeleton-line.w-50 {
  width: 50%;
}

.skeleton-line.w-75 {
  width: 75%;
}

.skeleton-line.w-90 {
  width: 90%;
}

.skeleton-line.h-16 {
  height: 16px;
}

/* -----------------------------------------------------------------------------
   Tabs
----------------------------------------------------------------------------- */
.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.tab svg {
  width: 16px;
  height: 16px;
}

.tab:hover {
  color: var(--text);
  background: var(--surface-3);
}

.tab.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

/* -----------------------------------------------------------------------------
   Lists / cards / logs
----------------------------------------------------------------------------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.card-pad {
  padding: 18px;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.admin-item-main {
  flex: 1;
  min-width: 0;
}

.admin-item-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.admin-item-sub {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.admin-item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  font-size: 13px;
  flex: none;
  text-transform: uppercase;
}

.admin-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-group-title {
  font-size: 15px;
  font-weight: 750;
}

.admin-group-sub {
  color: var(--text-muted);
  font-size: 12.5px;
}

.log-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.log-item:last-child {
  border-bottom: 0;
}

.log-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-3);
  color: var(--text-muted);
}

.log-icon svg {
  width: 17px;
  height: 17px;
}

.log-text {
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.log-meta {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 11.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
}

.log-time {
  color: var(--text-soft);
  font-size: 11.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

/* -----------------------------------------------------------------------------
   Photos
----------------------------------------------------------------------------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}

.photo-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  padding: 0;
}

.photo-tile:hover {
  border-color: var(--primary);
}

.photo-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-3);
  overflow: hidden;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb .spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  color: var(--text-soft);
}

.photo-tile-info {
  padding: 7px 9px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
}

.photo-tile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-soft);
  font-size: 12.5px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

.uploader {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.uploader-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.uploader-drop:hover,
.uploader-drop.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.uploader-drop svg {
  width: 26px;
  height: 26px;
  color: var(--primary);
}

.uploader-drop strong {
  color: var(--text);
  font-size: 13.5px;
}

.uploader-drop span {
  font-size: 11.5px;
}

.uploader-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.uploader-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 9px;
}

.preview-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.preview-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.preview-meta {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-soft);
}

.preview-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(7, 13, 24, 0.72);
  color: #fff;
}

.preview-remove:hover {
  background: rgba(7, 13, 24, 0.9);
}

.preview-remove svg {
  width: 14px;
  height: 14px;
}

.preview-card.is-uploading::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Lightbox */
.lightbox {
  width: min(1100px, calc(100vw - 20px));
  max-width: 1100px;
  max-height: calc(100dvh - 20px);
  border-radius: var(--radius-md);
  background: #05080f;
  color: #fff;
  overflow: hidden;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
}

.lightbox-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.82);
}

.lightbox-body {
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: auto;
  max-height: calc(100dvh - 90px);
}

.lightbox-body img {
  max-width: 100%;
  max-height: calc(100dvh - 120px);
  object-fit: contain;
  border-radius: 6px;
}

.lightbox .icon-btn {
  color: #fff;
}

.lightbox .icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* -----------------------------------------------------------------------------
   Misc
----------------------------------------------------------------------------- */
.status-dot-inline {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 0;
}

.kv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.kv-item {
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  min-width: 0;
}

.kv-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 3px;
}

.kv-value {
  font-size: 13px;
  font-weight: 600;
  word-break: break-word;
}

.progress {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width var(--transition);
}

@media (max-width: 880px) {
  :root {
    --header-height: 64px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .login-brand {
    padding: 26px 24px;
    gap: 18px;
  }

  .login-brand-copy,
  .login-brand-list {
    display: none;
  }

  .login-brand-foot {
    padding-top: 14px;
  }

  .login-panel {
    padding: 26px 24px 28px;
  }

  .login-topbar {
    margin-bottom: 20px;
  }

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

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

  .toast-root {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
  }
}

@media (max-width: 520px) {
  .app-modal,
  .app-modal.modal-lg,
  .login-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .modal-layout,
  .login-shell {
    max-height: 100dvh;
    min-height: 100dvh;
  }

  .modal-head {
    padding: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-foot {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .login-panel {
    padding: 22px 18px calc(24px + env(safe-area-inset-bottom));
  }

  .login-brand {
    padding: 20px 18px;
  }

  .login-brand-foot {
    display: none;
  }

  .login-dialog .login-brand h1 {
    font-size: 23px;
  }

  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .log-item {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .log-time {
    grid-column: 2;
    padding-top: 0;
  }
}
