/* ==========================================================================
   VC Design System
   Sumber tunggal untuk token, elemen dasar, dan komponen bersama.
   File kanonik di public/css/theme.css; portal admin/superadmin/key-monitor
   memakainya lewat rute /css/theme.css.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Brand */
  --brand-300: #a5c2fd;
  --brand-400: #7aa5fb;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-soft: rgba(59, 130, 246, 0.14);
  --brand-line: rgba(59, 130, 246, 0.38);

  /* Surfaces */
  --bg: #060a12;
  --surface-1: #0d1320;
  --surface-2: #121a2b;
  --surface-3: #182235;
  --surface-input: #0a101c;
  --surface-glass: rgba(13, 19, 32, 0.82);

  /* Lines */
  --border: #1c2739;
  --border-2: #26344b;
  --border-3: #33445f;

  /* Text */
  --text: #e9eff9;
  --text-2: #9db0cd;
  --text-3: #6a7b97;

  /* Status */
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --ok-line: rgba(52, 211, 153, 0.34);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --warn-line: rgba(251, 191, 36, 0.34);
  --danger: #f87171;
  --danger-strong: #ef4444;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --danger-line: rgba(248, 113, 113, 0.34);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.12);
  --info-line: rgba(56, 189, 248, 0.34);

  /* Radius */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Elevation */
  --sh-1: 0 1px 2px rgba(2, 6, 14, 0.5);
  --sh-2: 0 6px 20px -6px rgba(2, 6, 14, 0.6);
  --sh-3: 0 24px 60px -16px rgba(2, 6, 14, 0.78);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --dur: 0.16s;

  --ring: 0 0 0 3px rgba(59, 130, 246, 0.32);
  --ring-danger: 0 0 0 3px rgba(248, 113, 113, 0.28);

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Legacy alias — dipakai markup lama */
  --card: var(--surface-1);
  --muted: var(--text-2);
  --primary: var(--brand-500);
  --primary-hover: var(--brand-600);
  --danger-hover: #dc2626;
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 620px at 12% -12%, rgba(59, 130, 246, 0.16), transparent 62%),
    radial-gradient(880px 520px at 96% 4%, rgba(14, 165, 233, 0.1), transparent 58%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1.08rem;
}

h3 {
  font-size: 0.95rem;
}

p {
  margin: 0;
}

a {
  color: var(--brand-400);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}

a:hover {
  color: var(--brand-300);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

::selection {
  background: var(--brand-soft);
  color: var(--text);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-3) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: var(--r-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-3);
  background-clip: padding-box;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.muted {
  color: var(--text-2);
  font-size: 0.875rem;
}

.subtle {
  color: var(--text-3);
  font-size: 0.8rem;
}

.mono,
code.mono,
code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  word-break: break-all;
}

.eyebrow {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

/* --------------------------------------------------------------------------
   Brand mark
   -------------------------------------------------------------------------- */

.brand-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(140deg, var(--brand-500), #0ea5e9);
  box-shadow: 0 6px 18px -6px rgba(59, 130, 246, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  object-fit: cover;
  overflow: hidden;
}

img.brand-icon {
  background: none;
  box-shadow: 0 6px 18px -6px rgba(11, 17, 28, 0.55);
  padding: 0;
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--r-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand-300);
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  --btn-h: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

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

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  border-color: var(--brand-600);
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(37, 99, 235, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--brand-400), var(--brand-500));
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-3);
}

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}

.btn-quiet:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: var(--danger-line);
  color: #fda4a4;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
  color: #fff;
}

.btn-solid-danger {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
  color: #fff;
}

.btn-solid-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-sm {
  --btn-h: 32px;
  padding: 0 11px;
  font-size: 0.8rem;
  border-radius: var(--r-sm);
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-lg {
  --btn-h: 46px;
  padding: 0 20px;
  font-size: 0.94rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: var(--btn-h);
  padding: 0;
}

/* --------------------------------------------------------------------------
   Penyempurnaan tombol — kedalaman, fokus keyboard, dan umpan balik tekan
   -------------------------------------------------------------------------- */

.btn {
  position: relative;
  letter-spacing: 0.01em;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-color: var(--brand-400);
}

.btn-primary {
  border-color: rgba(255, 255, 255, 0.14);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow:
    0 12px 26px -12px rgba(37, 99, 235, 1),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 6px rgba(2, 6, 14, 0.45);
}

.btn-primary:focus-visible {
  box-shadow:
    var(--ring),
    0 8px 20px -10px rgba(37, 99, 235, 0.95);
}

.btn-ghost {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface-1) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.btn-ghost:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--surface-3) 0%, var(--surface-2) 100%);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 8px 18px -12px rgba(2, 6, 14, 0.9);
}

.btn-ghost:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 6px rgba(2, 6, 14, 0.5);
}

.btn-quiet:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn-danger {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.btn-danger:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -12px rgba(239, 68, 68, 0.95);
}

.btn-danger:focus-visible,
.btn-solid-danger:focus-visible {
  box-shadow: var(--ring-danger);
  border-color: var(--danger-strong);
}

.btn-solid-danger {
  background: linear-gradient(180deg, #f05252 0%, #dc2626 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 8px 20px -12px rgba(239, 68, 68, 0.95);
}

.btn-solid-danger:hover:not(:disabled) {
  background: linear-gradient(180deg, #f76a6a 0%, #e02424 100%);
  transform: translateY(-1px);
}

.btn-solid-danger:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 6px rgba(2, 6, 14, 0.45);
}

.btn svg {
  transition: transform var(--dur) var(--ease);
}

.btn:hover:not(:disabled) svg {
  transform: scale(1.06);
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .btn svg {
    transition: none;
    transform: none !important;
  }
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

label {
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--text-2);
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface-input);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease);
}

textarea {
  height: auto;
  min-height: 96px;
  padding: 11px 13px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-3);
}

input:hover:not(:disabled):not([readonly]),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: var(--border-3);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--ring);
}

input:disabled,
select:disabled,
textarea:disabled,
input[readonly] {
  background: rgba(10, 16, 28, 0.6);
  color: var(--text-2);
  cursor: not-allowed;
}

input[readonly] {
  cursor: text;
}

input[type='search'] {
  -webkit-appearance: none;
  appearance: none;
}

input[type='search']::-webkit-search-cancel-button {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--text-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6L6 18' stroke='%23000' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6L6 18' stroke='%23000' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  cursor: pointer;
}

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239db0cd' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 15px;
  cursor: pointer;
}

select option {
  background: var(--surface-2);
  color: var(--text);
}

.field-hint {
  font-size: 0.76rem;
  color: var(--text-3);
  line-height: 1.4;
}

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

/* Input dengan tombol aksi di kanan */
.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
}

.input-row .btn {
  --btn-h: 42px;
  flex-shrink: 0;
}

.password-field {
  align-items: stretch;
}

.password-toggle {
  width: 42px;
  min-width: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.password-toggle-icon {
  display: block;
}

.password-toggle[aria-pressed='true'] .password-toggle-show {
  display: none;
}

.password-toggle[aria-pressed='true'] .password-toggle-hide {
  display: block;
}

.password-toggle[aria-pressed='false'] .password-toggle-hide {
  display: none;
}

/* --------------------------------------------------------------------------
   Alerts — .error / .success dipakai langsung oleh JS lama
   -------------------------------------------------------------------------- */

.error,
.success,
.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  padding: 10px 13px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.45;
}

.error::before,
.success::before {
  content: '';
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  background: currentColor;
}

.error {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: #fca5a5;
}

.error::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 100 20 10 10 0 000-20zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 100 20 10 10 0 000-20zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.success {
  border-color: var(--ok-line);
  background: var(--ok-soft);
  color: #6ee7b7;
}

.success::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 100 20 10 10 0 000-20zm-1 14.5l-4-4L8.4 11 11 13.6 15.6 9 17 10.4l-6 6.1z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 100 20 10 10 0 000-20zm-1 14.5l-4-4L8.4 11 11 13.6 15.6 9 17 10.4l-6 6.1z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.error[hidden],
.success[hidden],
.alert[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 1.5;
}

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

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

.badge-off {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-line);
}

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

/* --------------------------------------------------------------------------
   Surfaces
   -------------------------------------------------------------------------- */

.panel,
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}

.panel-head h2 {
  font-size: 0.98rem;
}

/* --------------------------------------------------------------------------
   Tabel
   -------------------------------------------------------------------------- */

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

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.86rem;
}

th,
td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  background: #0b111d;
  white-space: nowrap;
}

tbody tr {
  transition: background var(--dur) var(--ease);
}

tbody tr:hover td {
  background: rgba(59, 130, 246, 0.05);
}

tbody tr:last-child td {
  border-bottom: 0;
}

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

.empty {
  padding: 44px 24px !important;
  text-align: center;
  color: var(--text-3);
  font-size: 0.875rem;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: rgba(10, 16, 28, 0.4);
}

.pagination-controls {
  display: flex;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   Modal — dialog ubah password
   -------------------------------------------------------------------------- */

.password-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.password-dialog[hidden] {
  display: none !important;
}

.password-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 14, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade-in 0.18s var(--ease);
}

.password-dialog-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 24px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  background: var(--surface-1);
  box-shadow: var(--sh-3);
  animation: dialog-in 0.2s var(--ease);
}

.password-dialog-card h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.password-dialog-card .dialog-sub {
  margin: 0 0 18px;
  color: var(--text-2);
  font-size: 0.84rem;
}

.password-dialog-card .form-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
