:root {
  --brand-navy: #111827;
  --brand-navy-2: #0b1220;
  --brand-orange: #e8942a;
  --brand-teal: #0d9488;
  --jet-sidebar: #111827;
  --jet-sidebar-2: #0b1220;
  --indigo-50: #f0fdfa;
  --indigo-100: #ccfbf1;
  --indigo-300: #5eead4;
  --indigo-500: #14b8a6;
  --indigo-600: #0d9488;
  --indigo-700: #0f172a;
  --slate-50: #f4f4f5;
  --slate-100: #e4e4e7;
  --slate-200: #e4e4e7;
  --slate-300: #d4d4d8;
  --slate-400: #a1a1aa;
  --slate-500: #71717a;
  --slate-600: #52525b;
  --slate-700: #3f3f46;
  --slate-800: #27272a;
  --slate-900: #18181b;
  --white: #fff;
  --amber-100: #fef3c7;
  --amber-800: #92400e;
  --blue-100: #dbeafe;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --purple-100: #f3e8ff;
  --purple-600: #7c3aed;
  --purple-700: #6d28d9;
  --purple-800: #5b21b6;
  --red-100: #fee2e2;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --red-800: #991b1b;
  --emerald-100: #d1fae5;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;
  --teal-100: #ccfbf1;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --rose-100: #ffe4e6;
  --rose-700: #be123c;
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.06);
  --radius: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--slate-900);
  background: var(--slate-50);
}
a {
  color: var(--teal-700);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button,
input,
select,
textarea {
  font-family: inherit;
}
img {
  max-width: 100%;
}

/* Layout */
.app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  display: none;
  width: 260px;
  flex-shrink: 0;
  flex-direction: column;
  background: var(--jet-sidebar);
  border-right: 1px solid #1f2937;
  color: #fff;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 16px;
  border-bottom: 1px solid var(--slate-200);
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-navy);
  text-decoration: none;
}
.brand:hover {
  text-decoration: none;
  color: var(--brand-navy);
}
.sidebar .brand {
  color: #fff;
  background: transparent;
  border-bottom-color: rgba(255, 255, 255, 0.06);
  height: 64px;
}
.sidebar .brand:hover {
  color: #fff;
}
.brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 2px;
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.brand-text strong {
  font-size: 14px;
  font-weight: 700;
}
.brand-text em {
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  color: var(--brand-teal);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--brand-navy);
  color: var(--white);
  font-weight: 700;
  font-size: 14px;
}
.nav {
  flex: 1;
  padding: 8px 10px 16px;
  overflow-y: auto;
}
.nav-group-label {
  margin: 16px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate-400);
}
.nav-group-label:first-child {
  margin-top: 4px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--slate-600);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav a:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}
.nav a.active {
  background: var(--indigo-50);
  color: var(--teal-800);
}
.sidebar .nav-group-label {
  color: rgba(255, 255, 255, 0.35);
}
.sidebar .nav a {
  color: rgba(255, 255, 255, 0.78);
}
.sidebar .nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.sidebar .nav a.active {
  background: rgba(13, 148, 136, 0.18);
  color: #fff;
  box-shadow: none;
}
.sidebar-foot {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.42);
}
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
}
.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--brand-navy);
  letter-spacing: -0.02em;
}
.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
}
.userbox .meta {
  text-align: right;
}
.userbox .meta strong {
  display: block;
  font-size: 14px;
}
.userbox .meta span {
  font-size: 12px;
  color: var(--slate-500);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--brand-teal);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.main {
  flex: 1;
  padding: 24px;
}
.mobile-nav {
  display: block;
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
}
.mobile-nav summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 16px;
  cursor: pointer;
}
.mobile-nav summary::-webkit-details-marker {
  display: none;
}
.mobile-nav .who {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-500);
}

@media (min-width: 1024px) {
  .sidebar {
    display: flex;
  }
  .mobile-nav {
    display: none;
  }
}

/* Cards / tables */
.card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-900);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
}
.card-head h3 {
  margin: 0;
}
.card-head .actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.grid-6 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.stat {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stat .n {
  font-size: 24px;
  font-weight: 700;
}
.stat p {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-500);
}
a.stat-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
a.stat-link:hover {
  text-decoration: none;
  border-color: var(--brand-teal);
  box-shadow: 0 4px 12px rgba(43, 54, 66, 0.1);
  transform: none;
}
.admin-dialog {
  width: min(420px, calc(100% - 32px));
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}
.admin-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.admin-dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.admin-dialog-head h3 {
  margin: 0;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--slate-500);
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 720px;
}
th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-500);
  padding: 12px 16px;
  background: transparent;
  border-bottom: 1px solid var(--slate-200);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-700);
}
tr:hover td {
  background: #fafafa;
}
.muted {
  color: var(--slate-500);
}
.empty {
  text-align: center;
  color: var(--slate-400);
  padding: 40px 16px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-amber {
  background: var(--amber-100);
  color: var(--amber-800);
  border-color: #fde68a;
}
.badge-blue {
  background: var(--blue-100);
  color: var(--blue-800);
  border-color: #bfdbfe;
}
.badge-purple {
  background: var(--purple-100);
  color: var(--purple-800);
  border-color: #e9d5ff;
}
.badge-red {
  background: var(--red-100);
  color: var(--red-800);
  border-color: #fecaca;
}
.badge-green {
  background: var(--emerald-100);
  color: var(--emerald-800);
  border-color: #a7f3d0;
}
.badge-teal {
  background: var(--teal-100);
  color: var(--teal-800);
  border-color: #99f6e4;
}
.badge-slate {
  background: var(--slate-100);
  color: var(--slate-600);
  border-color: var(--slate-200);
}
.badge-rose {
  background: var(--rose-100);
  color: var(--rose-700);
  border-color: #fecdd3;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--white);
}
.btn:hover {
  text-decoration: none;
  filter: brightness(0.95);
}
.btn-indigo {
  background: var(--brand-navy);
}
.btn-slate {
  background: var(--slate-900);
}
.btn-blue {
  background: var(--blue-600);
}
.btn-purple {
  background: var(--purple-600);
}
.btn-green {
  background: var(--emerald-600);
}
.btn-red {
  background: var(--red-600);
}
.btn-teal {
  background: var(--teal-600);
}
.btn-ghost {
  background: transparent;
  color: var(--slate-600);
  border: 1px solid var(--slate-200);
  font-size: 12px;
  padding: 6px 12px;
}
.btn-block {
  width: 100%;
}
.btn-sm {
  font-size: 12px;
  padding: 8px 12px;
}

/* Forms */
.field {
  display: block;
}
.field span.label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--slate-500);
}
.input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--slate-900);
  background: var(--white);
}
.input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}
.file {
  width: 100%;
  border: 1px dashed var(--slate-300);
  background: var(--slate-50);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--slate-600);
}
.form-grid {
  display: grid;
  gap: 16px;
}
.form-grid.cols-2 {
  grid-template-columns: 1fr;
}
.form-grid.cols-3 {
  grid-template-columns: 1fr;
}
.checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  background: var(--white);
  user-select: none;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--indigo-600);
}
.check:has(input:checked) {
  border-color: var(--brand-teal);
  background: var(--indigo-50);
  color: var(--brand-navy);
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.chips a {
  display: inline-block;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-600);
  background: var(--white);
  border: 1px solid var(--slate-200);
  text-decoration: none;
}
.chips a.on {
  background: var(--brand-navy);
  color: var(--white);
  border-color: var(--brand-navy);
}
.param-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 20px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
}
.param-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-600);
  text-decoration: none;
}
.param-tabs a:hover {
  background: var(--slate-50);
  color: var(--brand-navy);
  text-decoration: none;
}
.param-tabs a.on {
  background: var(--brand-navy);
  color: #fff;
}

.ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
}
.nav a .ico {
  width: 20px;
  height: 20px;
  opacity: 0.92;
}
.sidebar .nav a.active .ico {
  color: #5eead4;
  opacity: 1;
}
.param-tabs a .ico {
  width: 16px;
  height: 16px;
}
.param-tabs a.on .ico {
  color: #fff;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.choice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  cursor: pointer;
  background: #fff;
}
.choice input {
  accent-color: var(--brand-teal);
  margin-bottom: 4px;
}
.choice strong {
  font-size: 15px;
}
.choice small {
  color: var(--slate-500);
  font-size: 12px;
  font-weight: 400;
}
.choice:has(input:checked) {
  border-color: var(--brand-teal);
  background: var(--indigo-50);
  box-shadow: 0 0 0 3px rgba(43, 191, 168, 0.18);
}

/* Login */
.login-bg {
  min-height: 100vh;
  background: #f4f4f5;
  padding: 48px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  margin: 0 auto 14px;
  display: block;
  box-shadow: var(--shadow);
  border: 1px solid var(--slate-200);
}
.login-hero h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.02em;
}
.login-wrap {
  max-width: 960px;
  margin: 0 auto;
}
.login-hero {
  text-align: center;
  margin-bottom: 24px;
  color: var(--slate-900);
}
.login-hero p {
  color: var(--slate-500);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 10px 40px rgba(24, 24, 27, 0.08);
  border: 1px solid var(--slate-200);
}
.role-grid {
  display: grid;
  gap: 24px;
  margin-top: 32px;
}
.role-box {
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  padding: 20px;
}
.role-box h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-teal);
}
.role-box p {
  margin: 6px 0 12px;
  font-size: 12px;
  color: var(--slate-500);
}
.profile-btn {
  width: 100%;
  text-align: left;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.profile-btn:hover {
  border-color: var(--indigo-300);
  background: var(--indigo-50);
  color: var(--indigo-700);
}
.profile-btn small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--slate-400);
}

/* Detail */
.cols-3 {
  display: grid;
  gap: 24px;
}
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  font-size: 14px;
}
.info-grid .k {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--slate-400);
}
.notes {
  margin-top: 16px;
  background: var(--slate-50);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--slate-600);
}
.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
}
.file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--slate-100);
}
.file-list li:last-child {
  border-bottom: 0;
}
.file-list li.folder-row {
  background: var(--slate-50);
  font-weight: 600;
}
.file-list li.in-folder {
  padding-left: 28px;
}
.notify-matrix th.center,
.notify-matrix td.center {
  text-align: center;
}
.notify-matrix td.center input[type="checkbox"] {
  width: 16px;
  height: 16px;
}
.file-empty {
  border: 1px dashed var(--slate-200);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: var(--slate-400);
  font-size: 14px;
}
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.timeline li {
  position: relative;
  padding: 0 0 16px 16px;
  border-left: 2px solid var(--slate-100);
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--indigo-500);
}
.comment {
  background: var(--slate-50);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 8px;
}
.flash {
  margin: 12px 24px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
}
.flash-ok {
  background: var(--emerald-100);
  color: var(--emerald-800);
}
.flash-err {
  background: var(--red-100);
  color: var(--red-800);
}
.flash-warn {
  background: var(--amber-100);
  color: var(--amber-800);
}

@media (min-width: 640px) {
  .form-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
  .form-grid.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .role-grid {
    grid-template-columns: 1fr 1fr;
  }
  .grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 1024px) {
  .cols-3 {
    grid-template-columns: 2fr 1fr;
  }
  .info-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}
@media (min-width: 1280px) {
  .grid-6 {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* File list extras */
.file-list li .actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
}

/* Viewer studio */
.viewer-body {
  background: #070b14;
  color: #e2e8f0;
  min-height: 100vh;
}
.viewer-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.viewer-top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
}
.viewer-brand {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
}
.viewer-brand .back {
  color: #a5b4fc;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.viewer-brand strong {
  font-size: 14px;
}
.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.viewer-toolbar .btn-ghost {
  color: #e2e8f0;
  border-color: #334155;
  background: #1e293b;
}
.viewer-toolbar .btn-ghost.on {
  background: #4f46e5;
  border-color: #4f46e5;
}
.viewer-body-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 0;
}
.viewer-side {
  overflow: auto;
  padding: 16px;
  background: #0b1220;
  border-right: 1px solid #1e293b;
}
.side-label {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}
.file-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
  margin-bottom: 6px;
  border: 1px solid transparent;
}
.file-chip:hover {
  background: #1e293b;
  text-decoration: none;
}
.file-chip.on {
  background: #1e1b4b;
  border-color: #4f46e5;
  color: #fff;
}
.file-chip strong {
  display: block;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
}
.file-chip small {
  display: block;
  font-size: 11px;
  color: #64748b;
}
.layer {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: #cbd5e1;
  margin-bottom: 8px;
  cursor: pointer;
}
.layer .dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  display: inline-block;
}
.viewer-main {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #070b14;
}
.viewer-stage {
  position: absolute;
  inset: 0;
}
.gl-canvas {
  touch-action: none;
  cursor: grab;
}
.gl-canvas:active {
  cursor: grabbing;
}
.gl-canvas,
.pdf-frame,
.img-stage {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.img-stage {
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  background: #020617;
}
.img-stage img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  user-select: none;
  pointer-events: none;
}
.viewer-hint {
  position: absolute;
  left: 16px;
  bottom: 12px;
  font-size: 12px;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.75);
  padding: 6px 10px;
  border-radius: 8px;
  pointer-events: none;
}
.swatches {
  display: inline-flex;
  gap: 6px;
  margin-left: 6px;
}
.swatch {
  width: 18px;
  height: 18px;
  border-radius: 99px;
  border: 2px solid #475569;
  cursor: pointer;
  padding: 0;
}
.swatch.ivory { background: #f2e2c9; }
.swatch.pink { background: #e8b4b8; }
.swatch.gray { background: #cbd5e1; }
.swatch.scan { background: conic-gradient(#f2e2c9, #c4b5a5, #a5b4fc, #f2e2c9); }
.viewer-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 16px;
  background: #0f172a;
  color: #e2e8f0;
}
.viewer-banner p { margin: 0; font-size: 13px; color: #cbd5e1; }
.viewer-banner strong { color: #fff; }

@media (max-width: 860px) {
  .viewer-body-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .viewer-side {
    border-right: 0;
    border-bottom: 1px solid #1e293b;
    max-height: 160px;
  }
}

body.upload-busy {
  overflow: hidden;
}
.upload-overlay[hidden] {
  display: none;
}
.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 28, 51, 0.62);
  backdrop-filter: blur(6px);
}
.upload-dialog {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(8, 28, 51, 0.35);
}
.upload-dialog .brand-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: block;
}
.upload-dialog h2 {
  margin: 16px 0 8px;
  font-size: 20px;
  color: var(--brand-navy);
}
.upload-dialog p {
  margin: 0;
  font-size: 14px;
  color: var(--slate-600);
}
#upload-overlay-status {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #0d2b4a;
  word-break: break-word;
}
.upload-progress {
  margin: 16px auto 0;
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0d2b4a, #2dd4bf);
  border-radius: 999px;
  transition: width 0.2s ease;
}
#upload-overlay-pct {
  margin-top: 10px;
  font-size: 20px;
  font-weight: 700;
  color: #0d2b4a;
}
.upload-dialog p.muted {
  margin-top: 8px;
  font-size: 12px;
}
.upload-spinner {
  width: 40px;
  height: 40px;
  margin: 8px auto 0;
  border-radius: 999px;
  border: 3px solid var(--slate-200);
  border-top-color: var(--brand-teal);
  animation: upload-spin 0.8s linear infinite;
}
@keyframes upload-spin {
  to {
    transform: rotate(360deg);
  }
}
.pay-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-navy);
  margin-top: 4px;
}
.pay-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.login-bg {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-panel {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}
.login-title {
  margin: 0;
  font-size: 20px;
}
.login-lead {
  margin: 6px 0 20px;
  font-size: 14px;
}
.login-card .flash {
  margin: 0 0 16px;
}
.pwd-wrap {
  position: relative;
  display: block;
}
.pwd-wrap .input {
  padding-right: 88px;
}
.pwd-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--slate-500);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}
.otp-input {
  letter-spacing: 0.35em;
  font-size: 22px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.totp-qr {
  display: flex;
  justify-content: center;
  margin: 0 auto 16px;
  background: #fff;
  border-radius: 16px;
  padding: 12px;
  width: 220px;
  height: 220px;
  box-shadow: 0 0 0 1px var(--slate-200);
}
.totp-qr svg {
  width: 100%;
  height: 100%;
}
.totp-secret {
  text-align: center;
  font-size: 12px;
  color: var(--slate-500);
  margin: 0 0 8px;
}
.totp-secret code {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--brand-navy);
  word-break: break-all;
}
.backup-codes {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.backup-codes li {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.backup-codes code {
  font-size: 14px;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.hamburger {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  flex-shrink: 0;
}
.hamburger span,
.hamburger span::before,
.hamburger span::after {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--slate-800);
  border-radius: 1px;
  position: relative;
}
.hamburger span::before,
.hamburger span::after {
  content: "";
  position: absolute;
  left: 0;
}
.hamburger span::before { top: -6px; }
.hamburger span::after { top: 6px; }
.mobile-page-title {
  display: none;
}

@media (max-width: 1023px) {
  html,
  body {
    overflow-x: hidden;
  }
  .topbar {
    display: none;
  }
  .main {
    padding: 14px 12px 28px;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }
  .flash {
    margin: 10px 12px 0;
    font-size: 13px;
  }
  .mobile-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #fff;
  }
  .mobile-nav summary {
    height: 58px;
    padding: 0 10px 0 12px;
    gap: 10px;
  }
  .mobile-nav .brand-text strong {
    font-size: 13px;
  }
  .brand-text em.mobile-page-title {
    display: block;
    font-style: normal;
    text-transform: none;
    letter-spacing: 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--slate-500);
    max-width: 52vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-nav details[open] summary {
    border-bottom: 1px solid var(--slate-200);
  }
  .mobile-nav details[open] .hamburger span {
    background: transparent;
  }
  .mobile-nav details[open] .hamburger span::before {
    top: 0;
    transform: rotate(45deg);
  }
  .mobile-nav details[open] .hamburger span::after {
    top: 0;
    transform: rotate(-45deg);
  }
  .mobile-nav .nav {
    padding: 10px 10px 20px;
    background: #111827;
    max-height: calc(100vh - 58px);
    overflow-y: auto;
  }
  .mobile-nav .nav-group-label {
    color: rgba(255, 255, 255, 0.38);
  }
  .mobile-nav .nav a {
    color: rgba(255, 255, 255, 0.9);
    padding: 12px 12px;
    min-height: 44px;
    font-size: 15px;
  }
  .mobile-nav .nav a:hover,
  .mobile-nav .nav a.active {
    background: rgba(13, 148, 136, 0.2);
    color: #fff;
  }
  .mobile-nav .nav .btn-ghost {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.18);
    min-height: 44px;
    margin: 8px 4px 4px;
  }
  .mobile-nav .brand-logo {
    width: 32px;
    height: 32px;
  }

  .card {
    padding: 14px;
  }
  .stat .n {
    font-size: 20px;
  }
  .grid-6 {
    gap: 10px;
  }
  .section-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  table {
    min-width: 640px;
  }
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
  }
  table.table-cards {
    min-width: 0;
  }
  table.table-cards thead {
    display: none;
  }
  table.table-cards tbody,
  table.table-cards tr,
  table.table-cards td {
    display: block;
    width: 100%;
  }
  table.table-cards tr {
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--slate-200);
  }
  table.table-cards tr:hover td {
    background: transparent;
  }
  table.table-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border: 0;
    text-align: right;
  }
  table.table-cards td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--slate-500);
    text-align: left;
    flex-shrink: 0;
  }
  table.table-cards td.empty {
    display: block;
    text-align: center;
    padding: 28px 8px;
  }
  table.table-cards td.empty::before {
    content: none;
  }

  .file-list li {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
  }
  .file-list li .actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .file-list li .actions .btn {
    flex: 1 1 auto;
    min-height: 40px;
  }

  .param-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .param-tabs::-webkit-scrollbar {
    display: none;
  }
  .param-tabs a {
    flex-shrink: 0;
    min-height: 40px;
  }
  .chips {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    padding-bottom: 4px;
  }
  .chips a {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }
  .info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .row {
    gap: 8px;
  }
  .btn {
    min-height: 40px;
  }
  .input,
  select,
  textarea {
    font-size: 16px;
    max-width: 100%;
  }
  .login-bg {
    padding: 24px 12px;
    align-items: flex-start;
  }
  .login-card {
    padding: 20px 16px;
  }
  .login-hero h1 {
    font-size: 24px;
  }
  .login-logo {
    width: 64px;
    height: 64px;
  }
  .backup-codes {
    grid-template-columns: 1fr 1fr;
  }
  .otp-input {
    font-size: 20px;
  }
  .admin-dialog {
    width: calc(100% - 24px);
    max-height: 90vh;
    overflow: auto;
  }
  .cols-3 {
    gap: 14px;
  }
}
