
:root {
  color-scheme: dark;
  --ink-strong: #f4f8fb;
  --ink: #cfdae4;
  --ink-muted: #7892a8;
  --page: #030d17;
  --shell: #06111d;
  --panel: #081725;
  --raised: #0c2031;
  --selected: #102d43;
  --line: #163a52;
  --line-strong: #285974;
  --blue: #168ff0;
  --cyan: #4fd5ff;
  --healthy: #3dd6a1;
  --warning: #ffb642;
  --critical: #ff5964;
  --focus: #9ee8ff;
  --auth-scene-image: url('/auth-ui/login-command-center.png');
  font-family: "Segoe UI Variable", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--page); }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }

button, a, input, select { -webkit-tap-highlight-color: transparent; }

button, a { touch-action: manipulation; }

a { color: inherit; text-underline-offset: 3px; }

::selection { background: rgba(79, 213, 255, .28); color: var(--ink-strong); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.auth-threshold {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  position: relative;
  isolation: isolate;
  overflow-x: clip;
  background: var(--shell);
}

.auth-scene {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background-color: #06111d;
  background-image: var(--auth-scene-image);
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}

.auth-scene-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(3, 13, 23, .22) 0%, rgba(3, 13, 23, .48) 46%, rgba(3, 13, 23, .78) 100%),
    linear-gradient(180deg, rgba(3, 13, 23, .08) 0%, rgba(3, 13, 23, .46) 100%);
}

.auth-scene-content {
  min-height: 100%;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(28px, 3.8vw, 72px);
}

.icc-mark {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-strong);
  text-decoration: none;
}

.icc-mark-symbol {
  padding-right: 14px;
  border-right: 1px solid rgba(158, 232, 255, .35);
  font-size: 32px;
  font-weight: 760;
  letter-spacing: -.035em;
  line-height: 1;
}

.icc-mark-copy { display: grid; gap: 1px; }
.icc-mark-copy strong { font-size: 14px; line-height: 1.25; }
.icc-mark-copy small { color: #a6bfce; font-size: 11px; }

.auth-scene-statement {
  display: grid;
  justify-items: start;
  gap: 12px;
  max-width: 36ch;
  padding-bottom: clamp(8px, 2vw, 32px);
}

.auth-scene-context {
  margin: 0;
  color: #d8e7f0;
  font-size: clamp(16px, 1.2vw, 20px);
  font-weight: 680;
  letter-spacing: -.01em;
  line-height: 1.35;
}

.auth-demo-badge {
  width: fit-content;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid rgba(158, 232, 255, .46);
  border-radius: 999px;
  background: rgba(3, 13, 23, .72);
  color: #d8eff9;
  font-size: 12px;
  font-weight: 680;
  line-height: 1.25;
}

.auth-panel {
  width: clamp(400px, 28vw, 456px);
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-self: center;
  justify-self: start;
  margin-left: clamp(640px, calc(70vw - 228px), 1560px);
  border: 1px solid rgba(79, 213, 255, .42);
  border-radius: 14px;
  background: rgba(5, 18, 30, .97);
}

.mobile-brand { display: none; }
.auth-panel-demo-badge { display: none; }

.auth-panel-body {
  width: 100%;
  padding: 36px clamp(30px, 3vw, 42px) 32px;
}

.auth-heading { margin-bottom: 26px; }

.auth-heading h1,
.admin-heading h1 {
  margin: 0 0 12px;
  color: var(--ink-strong);
  font-size: clamp(27px, 2.2vw, 34px);
  font-weight: 730;
  letter-spacing: -.025em;
  line-height: 1.1;
}

.auth-heading p,
.admin-heading p,
.policy-strip p { margin: 0; color: var(--ink-muted); }

form { display: grid; gap: 20px; }

.form-field { display: grid; gap: 8px; }

.form-field > label {
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 680;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--raised);
  color: var(--ink-strong);
  caret-color: var(--focus);
}

input { padding: 10px 13px; }
select { padding: 9px 36px 9px 12px; }

input::placeholder { color: #829bad; opacity: 1; }

input:hover,
select:hover { border-color: #3c6d88; }

input:focus,
select:focus {
  border-color: var(--focus);
  outline: none;
  box-shadow: 0 4px 18px rgba(79, 213, 255, .12);
}

input[aria-invalid="true"],
select[aria-invalid="true"] { border-color: var(--critical); }

.password-control { position: relative; }
.password-control input { padding-right: 100px; }

.password-toggle {
  min-height: 44px;
  position: absolute;
  right: 2px;
  top: 1px;
  padding: 0 12px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 5px 5px 0;
  background: var(--raised);
  color: #a9c8d9;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.password-toggle:hover { color: var(--ink-strong); background: var(--selected); }

.field-help,
.field-error { margin: 0; font-size: 12px; }
.field-help { color: var(--ink-muted); }
.field-error { color: #ffabb1; }

.form-error-summary,
.notice,
.admin-feedback {
  border: 1px solid #74454c;
  border-radius: 8px;
  background: #24151c;
  color: #ffd4d7;
}

.form-error-summary { padding: 12px 14px; }
.form-error-summary strong { color: var(--ink-strong); }
.form-error-summary ul { margin: 6px 0 0; padding-left: 20px; }

.notice {
  display: grid;
  gap: 3px;
  margin-bottom: 22px;
  padding: 12px 14px;
}

.notice-warning { border-color: #725a2a; background: #211b10; color: #f6dca8; }
.notice-success { border-color: #29684f; background: #0e211a; color: #a8ead2; }

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink-strong);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 680;
  line-height: 1.2;
}

.button-primary { background: var(--blue); border-color: #42a7f8; }
.button-primary:hover { background: #087fdc; }

.button-secondary { background: var(--raised); border-color: var(--line-strong); }
.button-secondary:hover,
.button-quiet:hover { background: var(--selected); border-color: #3c6d88; }

.button-quiet { background: transparent; border-color: var(--line); color: #aac0cf; }
.button-danger { background: #4a2028; border-color: #88404a; color: #ffd8db; }
.button-danger:hover { background: #612630; }
.button-block { width: 100%; }
.button:disabled { cursor: not-allowed; opacity: .55; }

.button-progress {
  width: 14px;
  height: 14px;
  display: none;
  border: 2px solid rgba(244, 248, 251, .35);
  border-top-color: var(--ink-strong);
  border-radius: 50%;
  animation: auth-spin .72s linear infinite;
}

form[aria-busy="true"] .button-progress { display: inline-block; }

@keyframes auth-spin { to { transform: rotate(360deg); } }

.auth-recovery-copy {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.auth-recovery-copy strong { color: var(--ink-strong); font-size: 13px; }
.auth-recovery-copy p { margin: 5px 0 0; color: var(--ink-muted); font-size: 12px; }

.auth-panel-footer {
  padding: 13px 24px;
  border-top: 1px solid var(--line);
  color: #7892a8;
  font-size: 11px;
  line-height: 1.55;
  text-align: left;
}

[hidden] { display: none !important; }

.console-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 10px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: var(--shell);
}

.console-header nav { display: flex; align-items: center; gap: 8px; }
.current-user { padding: 0 8px; color: #9db4c4; font-size: 12px; }

.admin-workspace {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 38px 0 64px;
}

.admin-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.admin-heading p { max-width: 70ch; }

.policy-strip {
  display: grid;
  grid-template-columns: minmax(150px, .55fr) minmax(260px, 1.7fr) minmax(250px, 1fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #071522;
}

.policy-strip strong { color: var(--ink-strong); }

.admin-feedback { margin-bottom: 18px; padding: 12px 14px; }
.admin-feedback[data-kind="success"] { border-color: #29684f; background: #0e211a; color: #a8ead2; }
.admin-feedback[data-kind="warning"] { border-color: #725a2a; background: #211b10; color: #f6dca8; }

.user-admin-surface {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.admin-loading,
.admin-empty,
.permission-denied {
  min-height: 280px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 36px;
  text-align: center;
}

.admin-empty h2,
.permission-denied h2 { margin: 0; color: var(--ink-strong); font-size: 19px; }
.admin-empty p,
.permission-denied p { max-width: 56ch; margin: 0; color: var(--ink-muted); }

.loading-mark {
  width: 18px;
  height: 18px;
  border: 2px solid #2a536b;
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: auth-spin .72s linear infinite;
}

.user-toolbar {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 12px 9px 16px;
  border-bottom: 1px solid var(--line);
}

.user-toolbar-copy { display: grid; gap: 2px; }
.user-toolbar-copy strong { color: var(--ink-strong); }
.user-toolbar-copy span { color: var(--ink-muted); font-size: 12px; }

.user-table-wrap { overflow-x: auto; }

.user-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.user-table th,
.user-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.user-table th { color: #94adbd; background: #071522; font-size: 11px; font-weight: 680; }
.user-table tbody tr:last-child td { border-bottom: 0; }
.user-table tbody tr:hover { background: rgba(16, 45, 67, .32); }

.user-identity { display: grid; gap: 2px; }
.user-identity strong { color: var(--ink-strong); }
.user-identity small { color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.status-badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 680;
}

.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-muted); }
.status-badge[data-status="active"]::before { background: var(--healthy); }
.status-badge[data-status="disabled"]::before { background: var(--critical); }
.credential-state { color: var(--ink-muted); font-size: 12px; }
.credential-state[data-required="true"] { color: #f3ca76; }

.role-control { min-width: 160px; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.row-actions .button { min-width: 94px; }

dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .52);
}

dialog::backdrop { background: rgba(1, 7, 13, .82); }

.dialog-header,
.dialog-body,
.dialog-actions { padding: 18px 20px; }
.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; color: var(--ink-strong); font-size: 19px; }
.dialog-header p { margin: 6px 0 0; color: var(--ink-muted); }
.dialog-body { display: grid; gap: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); }

.temporary-secret {
  display: block;
  padding: 14px;
  border: 1px solid #32799e;
  border-radius: 6px;
  background: #04111c;
  color: var(--ink-strong);
  font-family: "Segoe UI Variable", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  user-select: all;
}

.secret-warning { margin: 0; color: #f3ca76; }

@media (max-width: 1180px) and (min-width: 761px) {
  .auth-panel {
    width: min(456px, calc(100% - 64px));
    margin-inline: auto;
  }

  .auth-scene-statement { display: none; }
  .auth-panel-demo-badge {
    display: inline-flex;
    align-self: flex-end;
    margin: 18px 18px 0;
  }
}

@media (max-width: 900px) {
  .auth-panel {
    width: min(456px, calc(100% - 64px));
    margin-inline: auto;
  }
  .auth-scene-content { padding: 32px; }
  .policy-strip { grid-template-columns: 1fr; gap: 8px; }
  .console-header { align-items: flex-start; }
  .console-header nav { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 760px) {
  .auth-threshold { display: block; min-height: 100svh; }
  .auth-scene { position: fixed; inset: 0; }
  .auth-scene-content { display: none; }
  .auth-scene-shade { background: rgba(3, 13, 23, .88); }
  .auth-panel {
    width: 100%;
    min-height: 100svh;
    position: relative;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: rgba(5, 18, 30, .94);
  }
  .mobile-brand { display: grid; justify-items: start; gap: 14px; padding: 24px 22px 0; }
  .mobile-brand .icc-mark-symbol { font-size: 24px; }
  .auth-panel-body { margin: 0 auto; padding: 44px 22px 32px; }
  .auth-heading { margin-bottom: 26px; }
  .auth-heading h1 { font-size: 28px; }
  .auth-panel-footer { margin-top: auto; }

  .console-header { align-items: stretch; flex-direction: column; padding: 14px 16px; }
  .console-header nav { display: grid; grid-template-columns: 1fr 1fr; }
  .console-header .current-user { grid-column: 1 / -1; grid-row: 1; padding: 0 0 5px; }
  .admin-workspace { width: min(100% - 24px, 1480px); padding: 26px 0 44px; }
  .admin-heading { align-items: stretch; flex-direction: column; }
  .user-toolbar { align-items: stretch; flex-direction: column; padding: 14px; }
  .user-toolbar .button { width: 100%; }
  .user-table-wrap { overflow: visible; }
  .user-table { min-width: 0; }
  .user-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .user-table,
  .user-table tbody,
  .user-table tr,
  .user-table td { display: block; width: 100%; }
  .user-table tr { padding: 14px; border-bottom: 1px solid var(--line); }
  .user-table td { display: grid; grid-template-columns: minmax(96px, .42fr) minmax(0, 1fr); gap: 10px; align-items: center; padding: 7px 0; border: 0; }
  .user-table td::before { content: attr(data-label); color: #8ea7b8; font-size: 11px; font-weight: 680; }
  .user-table td:first-child { display: block; padding-bottom: 12px; }
  .user-table td:first-child::before { content: none; }
  .role-control { min-width: 0; }
  .row-actions { display: grid; grid-template-columns: 1fr; justify-content: stretch; }
  .row-actions .button { width: 100%; }
  .dialog-actions { display: grid; }
  .dialog-actions .button { width: 100%; }
}

@media (max-height: 740px) and (min-width: 761px) {
  .auth-panel-body { padding-top: 26px; padding-bottom: 26px; }
  .auth-heading { margin-bottom: 20px; }
  .auth-heading h1 { font-size: 27px; }
  form { gap: 14px; }
  .auth-recovery-copy { margin-top: 20px; padding-top: 14px; }
  .auth-panel-footer { padding-block: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
