:root {
  --dms-navy: #07162f;
  --dms-navy-2: #0b2144;
  --dms-navy-3: #12305c;
  --dms-cyan: #4fb3e8;
  --dms-cyan-2: #7dd3fc;
  --dms-ink: #0f172a;
  --dms-muted: #64748b;
  --dms-label: #7b8aa3;
  --dms-bg: #eef2f7;
  --dms-card: #ffffff;
  --dms-border: #d7e0ec;
  --dms-field-bg: #f3f6fa;
  --dms-field-border: #d5dee9;
  --dms-sidebar-w: 280px;
  --dms-topbar-h: 42px;
  --dms-footer-h: 34px;
  --dms-radius: 14px;
  --dms-radius-sm: 10px;
  --dms-glow: 0 0 24px rgba(79, 179, 232, 0.35);
}

html, body {
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--dms-ink);
}

/* ========== Auth / Login ========== */
body.auth-body {
  min-height: 100vh;
  background: radial-gradient(1200px 700px at 50% -10%, #12305c 0%, transparent 55%),
              linear-gradient(160deg, #050a18 0%, #07162f 45%, #0a1d3a 100%);
  position: relative;
  overflow-x: hidden;
}

.starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.auth-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  --auth-tilt-x: 0deg;
  --auth-tilt-y: 0deg;
  --auth-glow-x: 50%;
  --auth-glow-y: 30%;
  position: relative;
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, rgba(12, 28, 58, 0.92), rgba(8, 18, 40, 0.96));
  border-radius: 22px;
  padding: 28px 28px 22px;
  border: 1px solid rgba(79, 179, 232, 0.45);
  box-shadow: 0 0 0 1px rgba(79, 179, 232, 0.08), var(--dms-glow), 0 24px 60px rgba(0, 0, 0, 0.45);
  color: #e2e8f0;
  transform: perspective(1000px) rotateX(var(--auth-tilt-x)) rotateY(var(--auth-tilt-y));
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  will-change: transform;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    380px circle at var(--auth-glow-x) var(--auth-glow-y),
    rgba(79, 179, 232, 0.22),
    transparent 55%
  );
  opacity: 0.55;
  transition: opacity 0.2s ease;
  z-index: 0;
}

.auth-card.is-moving {
  box-shadow: 0 0 0 1px rgba(79, 179, 232, 0.18), 0 0 36px rgba(79, 179, 232, 0.35), 0 28px 70px rgba(0, 0, 0, 0.5);
}

.auth-card.is-moving::before {
  opacity: 0.9;
}

.auth-card > * {
  position: relative;
  z-index: 1;
}

.auth-secure {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(79, 179, 232, 0.12);
  border: 1px solid rgba(79, 179, 232, 0.28);
  color: var(--dms-cyan-2);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 22px;
}

.auth-secure-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dms-cyan);
  box-shadow: 0 0 8px var(--dms-cyan);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.auth-mark {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #67e8f9, #3b82f6);
  color: #04111f;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  box-shadow: 0 0 18px rgba(79, 179, 232, 0.45);
}

.auth-brand-copy h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.25;
}

.auth-brand-copy p {
  margin: 2px 0 0;
  color: #94a3b8;
  font-size: 0.8rem;
}

.auth-subtitle {
  text-align: center;
  color: #7dd3fc;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 10px 0 22px;
}

.auth-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #93c5fd;
  margin-bottom: 6px;
}

.auth-input {
  background: rgba(2, 10, 24, 0.65) !important;
  border: 1px solid rgba(125, 211, 252, 0.35) !important;
  color: #f8fafc !important;
  border-radius: 8px !important;
  min-height: 34px;
  height: 34px;
  padding: 0.28rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.3;
  box-shadow: none !important;
}

.auth-input::placeholder {
  color: #64748b;
}

.auth-input:focus {
  border-color: var(--dms-cyan) !important;
  box-shadow: 0 0 0 2px rgba(79, 179, 232, 0.2) !important;
}

.auth-password-wrap {
  position: relative;
}

.auth-password-wrap .auth-input {
  padding-right: 40px;
}

.auth-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #93c5fd;
  padding: 4px 6px;
  line-height: 1;
  font-size: 0.9rem;
}

.auth-submit {
  min-height: 34px;
  height: 34px;
  padding: 0.32rem 1rem;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #04111f;
  background: linear-gradient(90deg, #67e8f9, #38bdf8 45%, #60a5fa);
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-submit:hover {
  color: #04111f;
  filter: brightness(1.05);
}

.auth-alert {
  border-radius: 12px;
  font-size: 0.9rem;
}

.auth-card-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  text-align: center;
  color: #64748b;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ========== App shell (sidebar + scrollable content) ========== */
body.app-shell {
  display: flex;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: var(--dms-bg);
}

.app-sidebar {
  width: var(--dms-sidebar-w);
  flex: 0 0 var(--dms-sidebar-w);
  background:
    radial-gradient(600px 280px at 20% -10%, rgba(79, 179, 232, 0.18), transparent 60%),
    linear-gradient(180deg, var(--dms-navy-2), var(--dms-navy));
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 14px 14px 0;
  z-index: 1040;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 16px;
  flex: 0 0 auto;
}

.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #67e8f9, #3b82f6);
  color: #04111f;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

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

.brand-text strong {
  font-size: 0.92rem;
  letter-spacing: 0.06em;
  color: #fff;
}

.brand-text small {
  color: #94a3b8;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--dms-ink);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 16px;
  flex: 0 0 auto;
}

.sidebar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, #38bdf8, #2563eb);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  flex: 0 0 auto;
}

.sidebar-user-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.sidebar-user-name {
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-id {
  color: var(--dms-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  color: #64748b;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px;
  flex: 0 0 auto;
}

.sidebar-logout:hover {
  color: #dc2626;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
}

.sidebar-link i {
  font-size: 1.05rem;
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-link.active {
  background: #fff;
  color: var(--dms-navy);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.sidebar-foot {
  flex: 0 0 var(--dms-footer-h);
  height: var(--dms-footer-h);
  margin: 8px -14px 0;
  padding: 0 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  align-items: center;
}

.sidebar-foot-meta {
  color: #64748b;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: var(--dms-bg);
}

.app-topbar {
  flex: 0 0 auto;
  height: var(--dms-topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--dms-border);
}

.topbar-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--dms-ink);
  line-height: 1;
}

.topbar-spacer {
  flex: 1 1 auto;
}

.sidebar-toggle {
  border: 1px solid var(--dms-border);
  background: #fff;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--dms-ink);
}

.app-content {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  padding: 20px;
}

.app-footer {
  flex: 0 0 var(--dms-footer-h);
  height: var(--dms-footer-h);
  background: #fff;
  border-top: 1px solid var(--dms-border);
  color: var(--dms-muted);
  text-align: center;
  font-size: 0.7rem;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 20, 0.45);
  z-index: 1035;
}

body.sidebar-open .sidebar-backdrop {
  display: block;
}

/* ========== Content components ========== */
.command-banner {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-radius: 18px;
  color: #fff;
  background:
    radial-gradient(2px 2px at 12% 28%, rgba(255,255,255,0.55), transparent 40%),
    radial-gradient(1.5px 1.5px at 28% 72%, rgba(255,255,255,0.4), transparent 40%),
    radial-gradient(2px 2px at 48% 18%, rgba(255,255,255,0.5), transparent 40%),
    radial-gradient(1.5px 1.5px at 68% 62%, rgba(255,255,255,0.35), transparent 40%),
    radial-gradient(2px 2px at 86% 30%, rgba(255,255,255,0.45), transparent 40%),
    radial-gradient(1.5px 1.5px at 92% 78%, rgba(255,255,255,0.3), transparent 40%),
    linear-gradient(135deg, #0b2144 0%, #12305c 55%, #0a1d3a 100%);
  box-shadow: 0 14px 30px rgba(7, 22, 47, 0.22);
}

.command-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #93c5fd;
  font-weight: 700;
  margin-bottom: 6px;
}

.command-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.command-sub {
  margin: 8px 0 0;
  color: #cbd5e1;
  font-size: 0.92rem;
}

.command-banner-side {
  display: flex;
  align-items: center;
}

.command-metric {
  text-align: center;
  min-width: 110px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.command-metric-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
}

.command-metric-label {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #93c5fd;
}

.stat-card,
.panel-card {
  --glow-x: 50%;
  --glow-y: 50%;
  --card-scale: 1;
  position: relative;
  background: var(--dms-card);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  padding: 18px 18px;
  transform: scale(var(--card-scale));
  transition: transform 0.18s ease, box-shadow 0.2s ease;
  will-change: transform;
  overflow: hidden;
}

.stat-card::before,
.panel-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    420px circle at var(--glow-x) var(--glow-y),
    rgba(59, 130, 246, 0.16),
    transparent 55%
  );
  opacity: 0;
  transition: opacity 0.2s ease;
}

.stat-card.is-growing,
.panel-card.is-growing {
  --card-scale: 1.012;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.12);
  z-index: 2;
}

.stat-card.is-growing::before,
.panel-card.is-growing::before {
  opacity: 1;
}

.stat-card > *,
.panel-card > * {
  position: relative;
  z-index: 1;
}

.stat-label {
  color: #74839e;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  margin-top: 6px;
  font-size: 2rem;
  font-weight: 800;
  color: #0b2144;
  line-height: 1.15;
}

.panel-card-head {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 14px;
  color: #0b2144;
}

.role-list {
  list-style: none;
  padding: 0;
}

.role-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--dms-border);
}

.role-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.role-name {
  font-weight: 600;
}

.role-code {
  background: #fce7f3;
  color: #be185d;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.8rem;
}

/* ========== Forms: labels, inputs, selects ========== */
.app-content .form-label,
.modal .form-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #74839e;
  margin-bottom: 6px;
}

.app-content .form-control,
.app-content .form-select,
.modal .form-control,
.modal .form-select,
.page-toolbar .form-control,
.page-toolbar .form-select {
  min-height: 34px;
  height: 34px;
  padding: 0.28rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.3;
  border-radius: 8px;
  border: 1px solid #c9d4e4;
  background: #f4f7fb;
  color: #0b2144;
  box-shadow: none;
}

.app-content textarea.form-control,
.modal textarea.form-control {
  height: auto;
  min-height: 68px;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.app-content .form-control::placeholder,
.modal .form-control::placeholder {
  color: #94a3b8;
}

.app-content .form-control:focus,
.app-content .form-select:focus,
.modal .form-control:focus,
.modal .form-select:focus,
.page-toolbar .form-control:focus,
.page-toolbar .form-select:focus {
  border-color: #0b2144;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(11, 33, 68, 0.1);
  color: #0b2144;
}

.app-content .form-select,
.modal .form-select,
.page-toolbar .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%230b2144' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 9px 6px;
  padding-right: 32px;
}

.app-content .form-select[multiple],
.modal .form-select[multiple] {
  height: auto;
  min-height: 110px;
  background-image: none;
  padding-right: 0.75rem;
}

.app-content .form-text,
.modal .form-text {
  color: #74839e;
  font-size: 0.75rem;
  margin-top: 4px;
}

/* ========== Buttons: primary / secondary + mouse glow ========== */
.btn {
  --btn-glow-x: 50%;
  --btn-glow-y: 50%;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1.25;
  letter-spacing: 0.01em;
  padding: 0.32rem 1rem;
  min-height: 34px;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    120px circle at var(--btn-glow-x) var(--btn-glow-y),
    rgba(255, 255, 255, 0.35),
    transparent 55%
  );
  opacity: 0;
  transition: opacity 0.15s ease;
}

.btn.is-glowing::after {
  opacity: 1;
}

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

.btn-dms,
.btn-primary {
  background: #0b2144 !important;
  border: 1px solid #0b2144 !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(11, 33, 68, 0.2);
}

.btn-dms:hover,
.btn-primary:hover,
.btn-dms:focus,
.btn-primary:focus {
  background: #12305c !important;
  border-color: #12305c !important;
  color: #fff !important;
  box-shadow: 0 12px 24px rgba(11, 33, 68, 0.28);
  transform: translateY(-1px);
}

.btn-outline-secondary,
.btn-secondary {
  background: #fff !important;
  border: 1px solid #c9d4e4 !important;
  color: #74839e !important;
  box-shadow: none;
}

.btn-outline-secondary:hover,
.btn-secondary:hover,
.btn-outline-secondary:focus,
.btn-secondary:focus {
  background: #f4f7fb !important;
  border-color: #0b2144 !important;
  color: #0b2144 !important;
  transform: translateY(-1px);
}

.btn-outline-primary {
  background: #fff !important;
  border: 1px solid #93c5fd !important;
  color: #1d4ed8 !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background: #eff6ff !important;
  border-color: #2563eb !important;
  color: #1d4ed8 !important;
}

.btn-outline-danger {
  background: #fff !important;
  border: 1px solid #fecaca !important;
  color: #b91c1c !important;
}

.btn-outline-danger:hover {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
}

.btn-sm {
  border-radius: 8px;
  padding: 0.26rem 0.85rem;
  min-height: 30px;
  font-size: 0.8125rem;
}

.modal-footer .btn-outline-secondary {
  margin-right: 0.35rem;
}

.page-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-toolbar .command-kicker {
  margin-bottom: 2px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-badge.tone-green { background: #dcfce7; color: #166534; }
.status-badge.tone-blue { background: #dbeafe; color: #1d4ed8; }
.status-badge.tone-gray { background: #e2e8f0; color: #475569; }
.status-badge.tone-gold { background: #fef3c7; color: #92400e; }

.dms-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2000;
  min-width: 220px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.2s ease;
  pointer-events: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.dms-toast.show { opacity: 1; transform: translateY(0); }
.dms-toast.ok { background: #15803d; }
.dms-toast.err { background: #b91c1c; }

.table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #74839e;
  border-bottom-width: 1px;
  background: #f4f7fb;
}

.panel-card .table {
  margin-bottom: 0;
}

.panel-card .table-responsive {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .stat-card,
  .panel-card,
  .btn,
  .auth-card {
    transform: none !important;
    transition: none !important;
  }
  .stat-card::before,
  .panel-card::before,
  .btn::after,
  .auth-card::before {
    display: none;
  }
}
