/* UI polish layer.
   Loaded after the base and theme layers so it can normalise the console shell
   without chasing specificity in styles.css. Only surfaces, rhythm and control
   sizes live here; page-specific layout stays in the base sheets. */

:root {
  --ui-radius: 16px;
  --ui-radius-sm: 10px;
  --ui-control: 34px;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: #7c5cff45;
}

/* ---------- controls ---------- */

.primary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--ui-control);
  line-height: 1.2;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease, transform 0.12s ease;
}

.primary {
  border-radius: var(--ui-radius-sm);
  padding: 8px 16px;
  box-shadow: 0 6px 16px #7c5cff38;
}

.primary:hover {
  box-shadow: 0 9px 22px #7c5cff55;
  filter: brightness(1.05);
}

.primary:active {
  transform: translateY(1px);
}

.primary:disabled {
  box-shadow: none;
  filter: none;
}

.ghost {
  border-radius: var(--ui-radius-sm);
  background: var(--panel);
  padding: 7px 13px;
}

.ghost:hover {
  border-color: #3d4a63;
  background: #ffffff08;
}

.ghost.danger:hover {
  border-color: #ff647c80;
  background: #ff647c12;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  border-radius: var(--ui-radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:not([type="checkbox"]):not([type="radio"]):hover,
select:hover,
textarea:hover {
  border-color: #35415a;
}

input::placeholder,
textarea::placeholder {
  color: #5c677c;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- header ---------- */

header {
  height: 80px;
  padding: 0 28px;
}

header h2 {
  font-size: 20px;
  letter-spacing: -0.01em;
  margin-top: 2px;
}

header .eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.22em;
}

.header-actions {
  gap: 10px;
}

.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--ui-control);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--ui-radius-sm);
  background: var(--panel);
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 3px #45d4831c, 0 0 10px var(--green);
}

.status-dot.bad {
  box-shadow: 0 0 0 3px #ff647c1c, 0 0 10px var(--red);
}

.header-balance,
.header-buy {
  height: var(--ui-control);
}

.header-balance {
  padding: 0 13px;
  border-radius: var(--ui-radius-sm);
  font-size: 13px;
}

.header-buy {
  padding: 0 15px;
  border-radius: var(--ui-radius-sm);
}

.header-actions .lang-select,
.header-actions #refresh {
  height: var(--ui-control);
}

.header-actions #refresh {
  padding: 0 14px;
}

/* ---------- sidebar ---------- */

.sidebar {
  background: linear-gradient(180deg, #0f141e 0%, #0b0f17 100%);
  border-right-color: #1d2431;
}

.side-brand .logo.small {
  box-shadow: 0 8px 22px #7055ff55;
}

.sidebar nav {
  margin-top: 16px;
  padding-right: 2px;
}

.sidebar nav button {
  margin: 2px 0;
  padding: 10px 12px;
  border-radius: var(--ui-radius-sm);
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar nav button:hover,
.sidebar nav button.active {
  color: #fff;
  background: #7c5cff1c;
}

.sidebar nav button.active {
  background: linear-gradient(90deg, #7c5cff2e, #7c5cff0a);
  box-shadow: inset 3px 0 var(--accent);
}

.sidebar nav p {
  margin: 20px 12px 7px;
  color: #5c667a;
}

.side-tools {
  margin-top: 12px;
}

.side-tools .theme-toggle,
.side-tools .side-toggle {
  height: var(--ui-control);
  border-radius: var(--ui-radius-sm);
}

.side-user {
  padding-top: 14px;
}

.avatar {
  background: linear-gradient(145deg, #2a214d, #1b2a3f);
  color: #c3b7ff;
  font-weight: 800;
}

/* ---------- content surfaces ---------- */

.content {
  padding: 28px 32px 44px;
}

.card,
.panel {
  border-radius: var(--ui-radius);
  border-color: var(--line);
}

.card {
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  opacity: 0.55;
}

.card small {
  font-size: 12px;
  letter-spacing: 0.02em;
}

.card strong {
  margin: 12px 0 4px;
  font-size: 28px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.card em {
  font-size: 11.5px;
}

.panel {
  padding: 20px;
}

.panel > .panel-head {
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.panel-head h3 {
  font-size: 15.5px;
  letter-spacing: -0.01em;
}

.balance-hero {
  border: 1px solid #7c5cff30;
  border-radius: 18px;
}

.balance-hero strong {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ---------- tables ---------- */

th,
td {
  padding: 12px;
}

th {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  font-weight: 700;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: #ffffff06;
}

.badge {
  padding: 3px 8px;
  font-weight: 600;
}

.table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #2a3344;
  border-radius: 4px;
}

.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- dialog ---------- */

dialog {
  border-radius: 18px;
}

dialog form {
  padding: 24px;
}

.modal-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.modal-head button {
  line-height: 1;
}

/* ---------- light theme ---------- */

[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #f5f7fc 100%);
  border-right-color: #e6eaf2;
}

[data-theme="light"] .sidebar nav button:hover,
[data-theme="light"] .sidebar nav button.active {
  background: #6b4df614;
  color: var(--text);
}

[data-theme="light"] .sidebar nav button.active {
  background: linear-gradient(90deg, #6b4df626, #6b4df60a);
  box-shadow: inset 3px 0 var(--accent);
}

[data-theme="light"] .sidebar nav p {
  color: #8a93a3;
}

[data-theme="light"] .ghost:hover {
  border-color: #c4cedf;
  background: #eef1f8;
}

[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):hover,
[data-theme="light"] select:hover,
[data-theme="light"] textarea:hover {
  border-color: #b8c3d5;
}

[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder {
  color: #98a1b3;
}

[data-theme="light"] tbody tr:hover {
  background: #f5f7fc;
}

[data-theme="light"] .table-wrap::-webkit-scrollbar-thumb {
  background: #cbd4e2;
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  header .eyebrow {
    display: none;
  }
}

@media (max-width: 900px) {
  .health-pill {
    padding: 0 10px;
  }

  .health-pill #health-text {
    display: none;
  }
}

@media (max-width: 820px) {
  .health-pill,
  .header-actions #refresh {
    display: none;
  }
}

@media (max-width: 700px) {
  header {
    height: 64px;
    padding: 0 14px;
  }

  header h2 {
    font-size: 18px;
  }

  .content {
    padding: 18px 12px 36px;
  }

  .sidebar nav button {
    justify-content: center;
    padding: 12px;
    font-size: 18px;
  }

  .header-actions {
    gap: 8px;
  }

  .header-balance {
    padding: 0 10px;
  }

  .header-buy {
    padding: 0 12px;
  }

  .header-actions .lang-select {
    max-width: 92px;
  }

  .cards {
    gap: 12px;
  }
}

@media (max-width: 520px) {
  header {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .header-actions::-webkit-scrollbar {
    display: none;
  }
}
