/*
 * Shared visual system for the desktop user, admin, and workbench pages.
 * Keep layout-specific rules in each page; this file owns their shared palette,
 * typography, controls, surfaces, status treatments, and responsive rhythm.
 */
:root {
  color-scheme: dark;
  --ui-bg: #08111f;
  --ui-bg-deep: #07101d;
  --ui-panel: #102038;
  --ui-panel-strong: #12213a;
  --ui-panel-soft: #0b1829;
  --ui-line: #2a4262;
  --ui-line-strong: #355170;
  --ui-text: #eff6ff;
  --ui-muted: #9eafc8;
  --ui-accent: #62dfb5;
  --ui-accent-strong: #3fc89e;
  --ui-blue: #8bb8ff;
  --ui-danger: #ff9299;
  --ui-warn: #ffd276;
  --ui-radius: 18px;
  --ui-control-radius: 10px;
  --ui-shadow: 0 18px 55px rgba(0, 0, 0, .32);

  /* Compatibility aliases keep legacy page-specific selectors on the same
     palette while those pages are gradually reduced to shared styles. */
  --bg: var(--ui-bg);
  --bg-deep: var(--ui-bg-deep);
  --surface: var(--ui-panel);
  --surface-muted: #152941;
  --panel: var(--ui-panel);
  --panel2: var(--ui-panel-strong);
  --text: var(--ui-text);
  --muted: var(--ui-muted);
  --line: var(--ui-line);
  --blue: var(--ui-blue);
  --blue-focus: #9cc4ff;
  --green: var(--ui-accent);
  --orange: var(--ui-warn);
  --red: var(--ui-danger);
  --accent: var(--ui-accent);
  --accent2: var(--ui-blue);
  --warn: var(--ui-warn);
  --danger: var(--ui-danger);
  --radius: var(--ui-radius);
  --control-radius: var(--ui-control-radius);
  --shadow: var(--ui-shadow);
  --max: 1180px;
}

html {
  background: var(--ui-bg-deep);
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at 8% 0, #1c3a5d, transparent 34%),
    linear-gradient(145deg, var(--ui-bg-deep), #0b1729 65%, var(--ui-bg));
  color: var(--ui-text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
/* Workbench legacy CSS adds a grid overlay; keep the desktop surfaces on the
   same clean background used by the user and admin pages. */
body::before { content: none; }

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

a { color: var(--ui-blue); }
h1, h2, h3 { color: var(--ui-text); }
button, input, select, textarea { font: inherit; }

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--ui-control-radius);
  padding: 10px 14px;
  background: var(--ui-accent);
  color: #05291e;
  font-weight: 700;
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
  box-shadow: 0 8px 18px rgba(27, 155, 120, .18);
}

button:hover { filter: brightness(1.08); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; transform: none; }
button.secondary, .secondary {
  background: #203552;
  border-color: #3d5c82;
  color: var(--ui-text);
  box-shadow: none;
}
button.danger, .danger {
  background: #40232e;
  border-color: #714253;
  color: #ffdce0;
  box-shadow: none;
}
button.tertiary, .tertiary {
  background: transparent;
  border-color: transparent;
  color: var(--ui-blue);
  box-shadow: none;
}
button.small { min-height: 34px; padding: 6px 10px; border-radius: 8px; font-size: 12px; }

input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-control-radius);
  background: #091525;
  color: var(--ui-text);
  padding: 10px 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
}
input::placeholder, textarea::placeholder { color: #6f86a3; }
input:focus, select:focus, textarea:focus {
  border-color: var(--ui-blue);
  box-shadow: 0 0 0 3px rgba(139, 184, 255, .14), 0 8px 20px rgba(0, 0, 0, .12);
}
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(139, 184, 255, .4);
  outline-offset: 2px;
}
label { color: #c9d8ee; }

.page, .wrap {
  width: min(100%, 1180px);
  max-width: 1180px;
  margin-inline: auto;
  color: var(--ui-text);
}

.panel {
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: linear-gradient(145deg, rgba(18, 36, 59, .94), rgba(11, 24, 41, .94));
  box-shadow: var(--ui-shadow);
}
.card, .account, .task, .kpi, .qr-box, .slot, .runner-card,
.task-create, .activity-grid > div, .account-chip, .workbench-switch,
.login-box, .clock {
  border-color: var(--ui-line);
  background: var(--ui-panel-soft);
  color: var(--ui-text);
}
.notice {
  border: 1px solid var(--ui-line-strong);
  background: #152941;
  color: #cfe1fa;
}
.notice.error, .banner.error { border-color: #714253; background: #432530; color: #ffd5da; }
.notice.success, .banner.success { border-color: #32745d; background: #153d36; color: #8be4c6; }
.muted, .section-copy, .subtitle, .hint, .task-meta, .footer { color: var(--ui-muted); }
.error { color: var(--ui-danger); }
.success { color: var(--ui-accent); }

.brand-mark span, .eyebrow { color: var(--ui-accent); }
.title, .section-title, .modal-title { color: var(--ui-text); }
.money { color: var(--ui-accent); }

.auth-switch {
  background: #0d1b2e;
  border: 1px solid var(--ui-line);
}
.auth-switch button { color: var(--ui-muted); box-shadow: none; }
.auth-switch button.active {
  background: #203552;
  color: var(--ui-text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .22);
}
.step { color: var(--ui-muted); }
.step.active { color: var(--ui-blue); }
.step-dot { background: #203552; color: var(--ui-muted); }
.step.active .step-dot { background: var(--ui-blue); color: #061529; }

.dot { background: var(--ui-accent); }
.pill, .status, .badge, .chip, .entitlement {
  border: 1px solid #355170;
  background: #203552;
  color: #cfe1fa;
}
.pill.ok, .status.done, .badge.paid, .badge.active,
.entitlement { border-color: #32745d; background: #153d36; color: #8be4c6; }
.status.failed, .badge.failed, .badge.closed, .badge.cancelled,
.badge.disabled, .badge.deleted { border-color: #714253; background: #432530; color: #ffd5da; }
.status.pending, .badge.pending { border-color: #765e31; background: #4a3d1f; color: var(--ui-warn); }
.status.active, .status.armed, .status.sniping { border-color: #3e6591; background: #1d385b; color: #b9d4ff; }
.status.cancelled, .status.expired { border-color: #53647b; background: #263449; color: #c6d1df; }

.task { border-radius: 14px; }
.qr, .payment-qr { background: #fff; }
.modal { background: rgba(0, 0, 0, .62); }
.modal-card, .qr-box, .agent-box {
  border: 1px solid #4a668b;
  border-radius: 22px;
  background: linear-gradient(150deg, #142841, #0c192b);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .62);
  color: var(--ui-text);
}
.modal-close { background: #203552; color: var(--ui-text); }
.payment-provider, .payment-state { color: var(--ui-muted); }
.payment-link { color: var(--ui-blue); }

table { color: var(--ui-text); }
th { color: #bcd0eb; }
th, td { border-color: #2b4260; }
.empty { color: var(--ui-muted); }

.topbar {
  background: rgba(9, 23, 40, .9);
  border-color: #304b69;
}
.quick-nav a { border-color: #2d4d6c; background: #10243b; color: #b9ccea; }
.quick-nav a:hover, .quick-nav a:focus-visible { border-color: #5c83aa; background: #193657; color: #fff; }

/* Logged-in user workspace: keep each functional area on the same grid and
   give repeated data blocks a shared visual rhythm. */
.user-page #app {
  display: grid;
  gap: 14px;
}
.user-page #app > .panel {
  margin: 0;
  padding: 20px;
}
.user-page #app > .top {
  margin-bottom: 2px;
}
.user-page #app > .top h1 {
  margin-bottom: 4px;
  font-size: clamp(26px, 3vw, 36px);
  letter-spacing: -.035em;
}
.user-page #accounts.grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.user-page #accounts .card {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
}
.user-page #entitlements {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.user-page #tasks {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.user-page #tasks .task {
  margin: 0;
  border: 1px solid var(--ui-line);
  border-left: 3px solid var(--ui-blue);
  border-radius: 14px;
  background: var(--ui-panel-soft);
  padding: 14px 16px;
}
.user-page #app .money {
  font-size: 24px;
}
.user-page #app .app-bind-actions button {
  min-height: 40px;
  padding: 8px 14px;
}
.user-page #app .section-head,
.user-page #app .top {
  gap: 14px;
}
.user-page #app .actions {
  gap: 8px;
}
.user-page #app .actions > select {
  min-width: 160px;
  flex: 1 1 180px;
}
.user-page #app .actions > button {
  flex: 0 1 auto;
}
.user-page #app .task-title,
.user-page #app .target {
  gap: 10px;
}
.user-page #app .task-meta {
  line-height: 1.45;
}

/* Admin overview and data tabs share the same vertical rhythm as the user
   workspace without affecting the protected workbench's own layout. */
.admin-page #dashboard {
  display: grid;
  gap: 14px;
}
.admin-page #dashboard > .panel,
.admin-page #dashboard > .tabs,
.admin-page #dashboard > .top {
  margin-top: 0;
  margin-bottom: 0;
}
.admin-page #dashboard > .panel { padding: 20px; }
.admin-page #dashboard .kpis { gap: 12px; }
.admin-page #dashboard .kpi { min-height: 96px; }
.admin-page #dashboard .tab-view .panel { margin: 0; }

@media (max-width: 640px) {
  .page, .wrap { padding-left: 12px; padding-right: 12px; }
  .panel { padding: 16px; border-radius: 16px; }
  .topbar { margin-left: -12px; margin-right: -12px; padding-left: 14px; padding-right: 14px; }
  body { font-size: 14px; }
  .user-page #app > .panel { padding: 16px; }
  .user-page #accounts.grid { grid-template-columns: 1fr; }
  .admin-page #dashboard > .panel { padding: 16px; }
}
