@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* Pro — the default. Dark navy with a violet/blue gradient accent, matching
   a data-dense merchant-dashboard style. */
:root, [data-theme="pro"] {
  --bg: #0A0B14;
  --surface: #12131F;
  --surface-2: #181A2A;
  --border: #262840;
  --text: #EDEDF7;
  --text-muted: #8B8CA8;
  --accent: #8B5CF6;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --accent-text: #FFFFFF;
  --accent-2: #3B82F6;
  --accent-2-soft: rgba(59, 130, 246, 0.14);
  --green: #22C55E;
  --green-soft: rgba(34, 197, 94, 0.14);
  --red: #F0435D;
  --red-soft: rgba(240, 67, 93, 0.13);
  --orange: #F59E0B;
  --orange-soft: rgba(245, 158, 11, 0.14);
  --radius: 14px;
  --sidebar-w: 260px;
}

/* Vault — warm-dark, gold for money, mint for digital goods. */
[data-theme="vault"] {
  --bg: #0D0B10;
  --surface: #17141C;
  --surface-2: #1F1B26;
  --border: #2C2733;
  --text: #F3F1F6;
  --text-muted: #9891A3;
  --accent: #E8B84B;
  --accent-soft: rgba(232, 184, 75, 0.14);
  --accent-text: #1A1409;
  --accent-2: #4FD1C5;
  --accent-2-soft: rgba(79, 209, 197, 0.14);
  --green: #4FD1C5;
  --green-soft: rgba(79, 209, 197, 0.14);
  --red: #E8607A;
  --red-soft: rgba(232, 96, 122, 0.13);
  --orange: #F59E0B;
  --orange-soft: rgba(245, 158, 11, 0.14);
}

/* Paper — light mode done properly: warm off-white, not stark white/black. */
[data-theme="paper"] {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --surface-2: #F1EBE0;
  --border: #E3DACB;
  --text: #241F1A;
  --text-muted: #7A7168;
  --accent: #B8722E;
  --accent-soft: rgba(184, 114, 46, 0.10);
  --accent-text: #FFFFFF;
  --accent-2: #2F8F7E;
  --accent-2-soft: rgba(47, 143, 126, 0.10);
  --green: #2F8F7E;
  --green-soft: rgba(47, 143, 126, 0.10);
  --red: #C6483D;
  --red-soft: rgba(198, 72, 61, 0.10);
  --orange: #B8722E;
  --orange-soft: rgba(184, 114, 46, 0.10);
}

/* Deep Sea — cool navy with a bright cyan accent for a more technical feel. */
[data-theme="deepsea"] {
  --bg: #071019;
  --surface: #0D1B2A;
  --surface-2: #122539;
  --border: #1E3A54;
  --text: #E7F1FA;
  --text-muted: #7C9AB5;
  --accent: #33C5E8;
  --accent-soft: rgba(51, 197, 232, 0.14);
  --accent-text: #04141C;
  --accent-2: #F0A857;
  --accent-2-soft: rgba(240, 168, 87, 0.14);
  --green: #4ADE9E;
  --green-soft: rgba(74, 222, 158, 0.13);
  --red: #F0435D;
  --red-soft: rgba(240, 67, 93, 0.12);
  --orange: #F0A857;
  --orange-soft: rgba(240, 168, 87, 0.14);
}

/* Orchid — dark plum with a violet accent, for a bolder alternative. */
[data-theme="orchid"] {
  --bg: #130B18;
  --surface: #1C1122;
  --surface-2: #24162C;
  --border: #392646;
  --text: #F4EEF8;
  --text-muted: #A18FB0;
  --accent: #C084FC;
  --accent-soft: rgba(192, 132, 252, 0.16);
  --accent-text: #17091F;
  --accent-2: #F0A857;
  --accent-2-soft: rgba(240, 168, 87, 0.14);
  --green: #4ADE9E;
  --green-soft: rgba(74, 222, 158, 0.13);
  --red: #F0435D;
  --red-soft: rgba(240, 67, 93, 0.12);
  --orange: #F0A857;
  --orange-soft: rgba(240, 168, 87, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'Inter', -apple-system, sans-serif;
  letter-spacing: -0.01em;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ---------- layout ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 20px;
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 700;
  color: var(--accent-text);
  font-size: 15px;
  flex-shrink: 0;
}

.brand-name {
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.nav-scroll {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.nav-group-label {
  flex-shrink: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  padding: 12px 12px 6px;
  opacity: 0.7;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 12px 7px 14px;
  border-radius: 9px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 1px;
  border-left: 2px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
}

.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-link:hover { background: var(--surface-2); color: var(--text); }

.nav-link.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-left-color: transparent;
  font-weight: 600;
  box-shadow: 0 2px 10px var(--accent-soft);
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}

.bell-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.user-chip-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.user-chip-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-chip-role { font-size: 11px; color: var(--text-muted); line-height: 1.2; }

.bot-status-card {
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin: 4px 0;
}
.bot-status-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.bot-status-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.bot-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.bot-status-dot.online { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.telegram-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: linear-gradient(135deg, #2AABEE, #229ED9);
  color: white;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 10px;
  margin: 6px 0;
}
.telegram-btn:hover { filter: brightness(1.08); }
.telegram-btn-icon {
  width: 22px; height: 22px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}
.sidebar-backdrop.open { display: block; }

.sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.logout-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 13px;
  border-radius: 8px;
}
.logout-link:hover { background: var(--surface-2); color: var(--red); }

.main {
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.page-title { font-size: 19px; font-weight: 600; margin: 0; }

.ticker {
  display: flex;
  align-items: baseline;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
}
.ticker-label { font-family: 'IBM Plex Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.ticker-value { font-family: 'Inter', -apple-system, sans-serif; font-size: 16px; font-weight: 600; color: var(--accent); }

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

/* ---------- flash messages ---------- */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 500;
}
.flash-success { background: var(--green-soft); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 30%, transparent); }
.flash-error { background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent); }

/* ---------- cards / stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
}

.stat-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-icon-badge {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon-badge svg { width: 18px; height: 18px; }
.stat-icon-badge.purple { background: var(--accent-soft); color: var(--accent); }
.stat-icon-badge.blue { background: var(--accent-2-soft); color: var(--accent-2); }
.stat-icon-badge.green { background: var(--green-soft); color: var(--green); }
.stat-icon-badge.orange { background: var(--orange-soft); color: var(--orange); }
.stat-icon-badge.red { background: var(--red-soft); color: var(--red); }

.stat-value {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  display: block;
  margin-bottom: 8px;
}

.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }
.stat-value.accent { color: var(--accent); }

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
}
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }
.stat-change.flat { color: var(--text-muted); }
.stat-change svg { width: 12px; height: 12px; }

.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title { font-family: 'Inter', -apple-system, sans-serif; font-size: 17px; font-weight: 600; margin: 0; }

.two-col {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  align-items: start;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: filter .12s, transform .05s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn-danger { background: transparent; color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.btn-danger:hover { background: var(--red-soft); }
.btn-success { background: transparent; color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }

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

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--surface-2); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-delivered { background: var(--green-soft); color: var(--green); }
.badge-paid { background: var(--accent-soft); color: var(--accent); }
.badge-pending { background: color-mix(in srgb, var(--text-muted) 16%, transparent); color: var(--text-muted); }
.badge-expired, .badge-error { background: var(--red-soft); color: var(--red); }

/* ---------- forms ---------- */

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-muted); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
}
.form-textarea { font-family: 'IBM Plex Mono', monospace; min-height: 120px; resize: vertical; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-check { display: flex; align-items: center; gap: 8px; }

.search-bar {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
}
.search-input { flex: 1; min-width: 200px; }

/* ---------- misc ---------- */

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

.stock-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
}
.stock-cred { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; word-break: break-all; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.theme-picker {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 4px 12px 10px;
}
.theme-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, border-color .1s;
}
.theme-swatch:hover { transform: scale(1.08); }
.theme-swatch.active { border-color: var(--accent); }
.theme-swatch svg { width: 12px; height: 12px; opacity: 0; }
.theme-swatch.active svg { opacity: 1; }
.theme-swatch-pro { background: linear-gradient(135deg, #8B5CF6, #3B82F6); }
.theme-swatch-vault { background: linear-gradient(135deg, #17141C, #E8B84B); }
.theme-swatch-paper { background: linear-gradient(135deg, #FAF7F2, #B8722E); }
.theme-swatch-deepsea { background: linear-gradient(135deg, #0D1B2A, #33C5E8); }
.theme-swatch-orchid { background: linear-gradient(135deg, #1C1122, #C084FC); }

.sidebar-stats {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 8px 0;
  font-size: 11px;
}
.sidebar-stat { flex: 1; text-align: center; }
.sidebar-stat-num { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 15px; display: block; }
.sidebar-stat-label { color: var(--text-muted); font-size: 10px; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 4px;
}
.back-btn:hover { color: var(--text); }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 0%, var(--surface-2) 0%, var(--bg) 60%);
}
.login-card {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  text-align: center;
}

.mobile-menu-btn { display: none; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -270px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .mobile-menu-btn { display: inline-flex; }
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.quick-action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: transform .1s, border-color .1s;
}
.quick-action-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.quick-action-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.quick-action-icon svg { width: 18px; height: 18px; }
.quick-action-icon.purple { background: var(--accent-soft); color: var(--accent); }
.quick-action-icon.blue { background: var(--accent-2-soft); color: var(--accent-2); }
.quick-action-icon.green { background: var(--green-soft); color: var(--green); }
.quick-action-icon.orange { background: var(--orange-soft); color: var(--orange); }

@media (max-width: 900px) {
  .quick-actions-grid { grid-template-columns: repeat(2, 1fr); }
}
