* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-muted: #f9fafb;
  --field-bg: #ffffff;
  --text: #111827;
  --text-soft: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-text: #991b1b;
  --danger-border: #fecaca;
  --success: #16a34a;
  --success-hover: #15803d;
  --success-soft: #ecfdf5;
  --success-text: #166534;
  --success-border: #bbf7d0;
  --warning: #d97706;
  --warning-hover: #b45309;
  --warning-soft: #fffbeb;
  --warning-text: #92400e;
  --warning-border: #fde68a;
  --neutral: #4b5563;
  --neutral-hover: #374151;
  --muted-bg: #f3f4f6;
  --row-hover: #fbfcfe;
  --active-bg: #eef2f7;
  --placeholder: #9ca3af;
  --focus-ring: rgba(37, 99, 235, 0.14);
  --preview-bg: #f5f6f8;
  --sun: #f59e0b;
  --moon: #64748b;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --panel: #111827;
  --panel-muted: #1f2937;
  --field-bg: #0f172a;
  --text: #f9fafb;
  --text-soft: #d1d5db;
  --muted: #9ca3af;
  --line: #273449;
  --line-strong: #3f4b5f;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --primary-soft: rgba(96, 165, 250, 0.16);
  --danger: #f87171;
  --danger-hover: #ef4444;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --danger-text: #fecaca;
  --danger-border: rgba(248, 113, 113, 0.34);
  --success: #34d399;
  --success-hover: #10b981;
  --success-soft: rgba(52, 211, 153, 0.14);
  --success-text: #bbf7d0;
  --success-border: rgba(52, 211, 153, 0.34);
  --warning: #fbbf24;
  --warning-hover: #f59e0b;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --warning-text: #fde68a;
  --warning-border: rgba(251, 191, 36, 0.34);
  --neutral: #94a3b8;
  --neutral-hover: #cbd5e1;
  --muted-bg: #1f2937;
  --row-hover: rgba(96, 165, 250, 0.08);
  --active-bg: #1f2937;
  --placeholder: #6b7280;
  --focus-ring: rgba(96, 165, 250, 0.24);
  --preview-bg: #0b1120;
  --moon: #f8fafc;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: inherit;
}

.sidebar {
  width: 252px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 8px 18px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.sidebar-title {
  min-width: 0;
}

.account-menu {
  position: relative;
  flex: 0 0 auto;
}

.sidebar-header .account-menu {
  position: fixed;
  top: 18px;
  right: 28px;
  z-index: 50;
}

.account-avatar-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.account-avatar-button:hover,
.account-avatar-button[aria-expanded="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.account-avatar-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--primary), #38bdf8);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0;
}

.account-avatar.has-image {
  overflow: hidden;
  background: var(--panel-muted);
}

.account-avatar.has-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.account-avatar-lg {
  width: 46px;
  height: 46px;
  font-size: 18px;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}

.account-avatar-menu {
  width: 42px;
  height: 42px;
  font-size: 16px;
}

.avatar-change-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 2px solid var(--panel);
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.account-avatar-wrap {
  position: relative;
  display: inline-grid;
}

.avatar-change-badge-lg {
  right: -3px;
  bottom: -3px;
  width: 18px;
  height: 18px;
  border-color: var(--panel);
}

.account-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: 292px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

.account-panel[hidden] {
  display: none;
}

.account-panel-compact {
  width: 214px;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
}

.account-compact-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 13px;
}

.account-compact-head .account-title-block strong {
  font-size: 13px;
}

.account-compact-head .account-title-block span {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 650;
  text-transform: none;
  letter-spacing: 0;
}

.account-menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.account-menu-link * {
  pointer-events: none;
}

.account-menu-link:hover {
  background: var(--panel-muted);
  color: var(--text);
}

.account-menu-icon {
  color: var(--text-soft);
  font-size: 19px;
  line-height: 1;
}

.account-panel-footer {
  padding: 10px 14px;
}

.account-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.account-title-block {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.account-title-block strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-title-block span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.account-panel-section {
  display: grid;
  gap: 9px;
  padding: 14px 0;
}

.account-panel-section p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.account-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-muted);
  color: var(--text-soft);
}

.account-info-row strong {
  color: var(--text);
  font-size: 13px;
}

.account-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger-text);
  font-weight: 800;
  text-decoration: none;
}

.account-logout:hover {
  background: var(--danger);
  color: #fff;
}

.account-logout.compact {
  min-height: 32px;
  border-radius: 7px;
  background: #ff4d4f;
  color: #fff;
  font-size: 13px;
}

.account-logout.compact:hover {
  background: #dc2626;
}

.download-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  max-width: 1240px;
}

.theme-corner {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 2px;
  width: 76px;
  height: 36px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--text-soft);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.theme-choice {
  display: grid;
  place-items: center;
  width: 30px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.theme-choice:hover {
  color: var(--text);
}

.theme-choice:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.theme-choice[aria-pressed="true"] {
  background: var(--panel);
  box-shadow: var(--shadow);
}

.theme-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 26px;
  border-radius: 999px;
}

.theme-icon::before {
  content: "";
  position: absolute;
  display: block;
}

.theme-icon-sun::before {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--sun);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.theme-icon-moon::before {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: var(--moon);
}

.theme-icon-moon::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: var(--panel-muted);
  transform: translate(4px, -1px);
}

.theme-choice[aria-pressed="true"] .theme-icon-moon::after {
  background: var(--panel);
}

.language-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 88px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel-muted) 82%, var(--panel) 18%);
  color: var(--text-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.language-choice {
  display: inline-grid;
  place-items: center;
  min-width: 39px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.language-choice:hover {
  color: var(--text);
  transform: translateY(-1px);
}

.language-choice:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.language-choice[aria-pressed="true"] {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.24);
}

.sidebar-header .language-toggle {
  position: fixed;
  top: 18px;
  right: 74px;
  z-index: 50;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: var(--radius);
  color: var(--text-soft);
  font-weight: 650;
  text-decoration: none;
}

.sidebar-menu a:hover {
  background: var(--panel-muted);
  color: var(--text);
}

.sidebar-menu a.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-menu a.sidebar-muted-link {
  margin-top: 8px;
  color: var(--muted);
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px;
  overflow: auto;
}

.main-content > * {
  max-width: 1240px;
}

.page-title {
  margin: 0;
  color: var(--text);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0;
}

.page-subtitle {
  margin: 6px 0 18px;
  max-width: 760px;
  color: var(--muted);
}

.card {
  width: 100%;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  min-height: 142px;
  border-top: 3px solid var(--primary);
}

.stat-card.success {
  border-top-color: var(--success);
}

.stat-card.warn {
  border-top-color: var(--warning);
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  margin: 10px 0 8px;
  color: var(--text);
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.stat-note {
  color: var(--muted);
  font-size: 13px;
}

.toolbar,
.filter-toolbar,
.row-actions,
.form-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.filter-toolbar {
  margin-bottom: 14px;
}

.toolbar-spacer {
  margin-left: auto;
}

.key-toolbar {
  align-items: flex-start;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
}

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

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

.form-group label,
.filter-toolbar label,
.toolbar label {
  display: block;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

.form-group label {
  margin-bottom: 6px;
}

.form-group small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
.form-control {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:hover,
select:hover,
.form-control:hover {
  border-color: var(--placeholder);
}

input:focus,
select:focus,
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input.is-invalid,
select.is-invalid,
.form-control.is-invalid {
  border-color: var(--danger);
}

input::placeholder {
  color: var(--placeholder);
}

.input-sm {
  max-width: 86px;
  min-height: 32px;
  padding: 5px 8px;
  font-size: 13px;
}

.input-md {
  max-width: 220px;
}

.select-sm {
  max-width: 140px;
  min-height: 32px;
  padding: 5px 8px;
}

.select-md {
  max-width: 260px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--text-soft);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: var(--panel-muted);
  border-color: var(--line-strong);
  color: var(--text);
}

.btn:active {
  background: var(--active-bg);
}

.btn-sm {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background: var(--success-hover);
  border-color: var(--success-hover);
  color: #ffffff;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: #ffffff;
}

.btn-warning {
  background: var(--warning);
  color: #ffffff;
}

.btn-warning:hover {
  background: var(--warning-hover);
  border-color: var(--warning-hover);
  color: #ffffff;
}

.btn-neutral {
  background: var(--neutral);
  color: #ffffff;
}

.btn-neutral:hover {
  background: var(--neutral-hover);
  border-color: var(--neutral-hover);
  color: #ffffff;
}

.btn-secondary {
  border-color: var(--line-strong);
  background: var(--field-bg);
  color: var(--text-soft);
}

.btn-block {
  width: 100%;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--panel-muted);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:hover td {
  background: var(--row-hover);
}

.code-box {
  display: inline-flex;
  max-width: 360px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-muted);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.key-clickable {
  cursor: pointer;
}

.key-clickable:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 750;
}

.status-active {
  border-color: var(--success-border);
  background: var(--success-soft);
  color: var(--success-text);
}

.status-maint,
.status-warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning-text);
}

.status-locked {
  border-color: var(--line-strong);
  background: var(--muted-bg);
  color: var(--text-soft);
}

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

.status-muted {
  background: var(--muted-bg);
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.pagination-info {
  color: var(--muted);
  font-size: 13px;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.row-actions {
  align-items: center;
}

.no-wrap {
  white-space: nowrap;
}

.dropdown {
  position: relative;
  display: inline-block;
}

details summary {
  display: inline-block;
  list-style: none;
  cursor: pointer;
}

details summary::-webkit-details-marker {
  display: none;
}

.dropdown-panel {
  position: absolute;
  right: 0;
  z-index: 20;
  min-width: 190px;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.12);
}

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.48);
}

.modal-card {
  width: min(460px, 96vw);
  max-height: 84vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.18);
}

.modal-card.modal-wide {
  width: min(900px, 96vw);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

.section-heading {
  margin: 22px 0 12px;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.notice {
  width: 100%;
  max-width: 1240px;
  margin: 0 0 16px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 700;
}

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

.notice-error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger-text);
}

.account-profile-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  max-width: 1240px;
}

.profile-card {
  min-height: 560px;
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 156px;
  height: 156px;
  margin: 20px auto 14px;
  border-radius: 28px;
  background: linear-gradient(145deg, var(--primary), #38bdf8);
  color: #fff;
  font-size: 58px;
  font-weight: 900;
  box-shadow: 0 18px 40px rgba(37, 99, 235, 0.2);
}

.profile-avatar-form {
  margin: 20px auto 14px;
}

.profile-avatar-wrap {
  position: relative;
  display: inline-grid;
  cursor: pointer;
}

.profile-avatar-wrap input[type="file"] {
  position: absolute;
  inset: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.profile-avatar-form .profile-avatar {
  margin: 0;
}

.profile-avatar-action {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.profile-avatar-wrap:hover .profile-avatar-action {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

.profile-card h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 20px;
  font-weight: 850;
}

.profile-details {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.profile-details h4 {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 15px;
  font-weight: 850;
}

.profile-detail-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  color: var(--text-soft);
}

.profile-detail-row span {
  flex: 0 0 auto;
  font-weight: 800;
}

.profile-detail-row strong {
  min-width: 0;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.profile-logout {
  width: 100%;
  margin-top: 22px;
}

.account-edit-area {
  min-width: 0;
}

.profile-tabs {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.profile-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-soft);
  font-weight: 850;
  text-decoration: none;
}

.profile-tabs a:hover {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.profile-tabs a.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
}

.profile-form-card {
  padding: 22px;
  border-radius: 14px;
}

.discord-link-block {
  display: grid;
  gap: 10px;
}

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

.discord-code-box {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
  color: var(--text-soft);
}

.discord-code-box span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.discord-code-box code {
  display: inline-block;
  width: fit-content;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.07em;
}

.discord-code-box small {
  color: var(--muted);
}

.user-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.dashboard-user-grid {
  max-width: 1240px;
}

.user-usage-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.user-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.user-card-name {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.user-card-meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.usage-metric {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  min-width: 0;
}

.usage-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.usage-pair .usage-metric {
  margin-top: 0;
}

.usage-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-soft);
  font-size: 13px;
}

.usage-line strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.usage-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--active-bg);
}

.usage-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 0.2s ease;
}

.usage-primary {
  background: var(--primary);
}

.usage-success {
  background: var(--success);
}

.usage-warning {
  background: var(--warning);
}

.usage-danger {
  background: var(--danger);
}

.quota-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.key-filter-bar {
  align-items: flex-end;
  gap: 12px;
}

.key-search-form {
  display: flex;
  align-items: flex-end;
  flex: 1 1 420px;
  gap: 8px;
  min-width: 280px;
}

.filter-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.search-field {
  flex: 1 1 auto;
}

.key-filter-form {
  display: grid;
  flex: 0 1 230px;
  gap: 6px;
}

.key-limit-form {
  flex-basis: 110px;
}

body.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-top-action {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
}

.login-wrap {
  width: min(420px, 100%);
}

.login-card {
  width: 100%;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(17, 24, 39, 0.10);
}

.login-header {
  margin-bottom: 24px;
  text-align: center;
}

.login-title {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-subtitle {
  margin: 0;
  color: var(--muted);
}

.login-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger-text);
}

.login-card .form-group {
  margin-bottom: 16px;
}

.login-card .form-group:last-of-type {
  margin-bottom: 22px;
}

.login-card .btn {
  width: 100%;
}

.login-footer {
  margin-top: 20px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.login-footer a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

.download-page {
  min-height: 100vh;
  display: block;
  background: var(--bg);
  color: var(--text);
}

.download-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.download-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.download-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.download-subtitle,
.download-copy {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.download-card {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.download-platform {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.download-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.download-preview {
  margin-top: 22px;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.74fr) minmax(320px, 1.26fr);
  gap: 14px;
}

.preview-card {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.download-note {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-muted);
    font-size: 12px;
    color: var(--muted);
}

.download-note span {
    flex: 1 1 0;
    min-width: 0;
    line-height: 1.5;
}

.download-note code {
    display: block;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--active-bg);
    font-family: monospace;
    font-size: 12px;
}

.copy-command-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border: 1px solid var(--line-strong);
    border-radius: calc(var(--radius) - 2px);
    background: var(--field-bg);
    color: var(--text-soft);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.copy-command-btn:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.copy-command-btn:active {
    background: var(--active-bg);
}

.preview-card img {
  display: block;
  width: 100%;
  height: 460px;
  object-fit: contain;
  background: var(--preview-bg);
}

.preview-macos img {
  background: var(--preview-bg);
}

.preview-card figcaption {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.btn:disabled,
.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.58;
}

@media (max-width: 980px) {
  body {
    display: block;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-header {
    margin-bottom: 12px;
  }

  .sidebar-menu {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .sidebar-menu a {
    flex: 0 0 auto;
  }

  .sidebar-menu a.sidebar-muted-link {
    margin-top: 0;
  }

  .account-panel {
    right: 0;
    width: min(292px, calc(100vw - 28px));
  }

  .sidebar-header .account-menu {
    top: 16px;
    right: 14px;
  }

  .sidebar-header .language-toggle {
    top: 16px;
    right: 60px;
  }

  .main-content {
    padding: 18px;
  }

  .dashboard-grid,
  .form-grid,
  .account-profile-layout {
    grid-template-columns: 1fr;
  }

  .profile-card {
    min-height: 0;
  }

  .toolbar-spacer {
    width: 100%;
    margin-left: 0;
  }

  table {
    min-width: 760px;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: 14px;
  }

  .card {
    padding: 14px;
  }

  .page-title {
    font-size: 24px;
  }

  .stat-value {
    font-size: 34px;
  }

  .toolbar,
  .filter-toolbar,
  .row-actions,
  .inline-form {
    align-items: stretch;
  }

  .btn,
  .inline-form,
  .filter-toolbar form,
  .toolbar form {
    width: 100%;
  }

  .inline-form .btn,
  .row-actions .btn {
    width: auto;
  }

  .input-sm,
  .input-md,
  .select-md,
  .select-sm {
    max-width: none;
  }

  .key-search-form {
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
  }

  .key-filter-form {
    flex-basis: auto;
  }

  .login-card {
    padding: 24px;
  }

  .login-top-action {
    position: absolute;
  }

  .download-topbar,
  .download-card-footer {
    margin-top: auto;
  }

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

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

  .preview-card img {
    height: auto;
    max-height: 520px;
  }
}

@media (max-width: 420px) {
  .user-card-grid {
    grid-template-columns: 1fr;
  }

  .usage-pair {
    grid-template-columns: 1fr;
  }
}

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

.download-page {
  min-height: 100vh;
  background: var(--bg);
}

.download-shell {
  width: min(1000px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.download-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}

.download-title {
  margin: 0;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0;
}

.download-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
}

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

.download-card-minimal {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.download-card-minimal h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
}

.download-card-minimal p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.download-card-footer {
  margin-top: 22px;
}

.download-preview {
  margin-top: 36px;
}

.preview-header {
  text-align: center;
  margin-bottom: 18px;
}

.preview-header h2 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0;
}

.preview-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.preview-showcase {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.preview-image {
  display: block;
  width: 100%;
  border-radius: var(--radius);
}

@media (max-width: 768px) {
  .download-grid {
    grid-template-columns: 1fr;
  }

  .download-title {
    font-size: 32px;
  }

  .download-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .download-card-minimal {
    padding: 22px;
  }
}
