:root {
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --text: #17181c;
  --text-muted: #62636b;
  --border: #e2e3e8;
  --accent: #6c4cf1;
  --accent-contrast: #ffffff;
  --success: #1f9d55;
  --warning: #c78a02;
  --danger: #d64545;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 20, 30, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #101114;
  --bg-elevated: #1a1b20;
  --text: #f1f1f3;
  --text-muted: #9a9ba3;
  --border: #2b2c33;
  --accent: #8a6cf7;
  --accent-contrast: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  width: 230px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px 16px;
  transition: width .15s ease;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar-brand { font-weight: 700; line-height: 1.3; white-space: nowrap; }
.topbar-sub { display: block; color: var(--text-muted); font-weight: 400; font-size: 13px; }
.nav-toggle, .sidebar-collapse-toggle {
  display: none;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 17px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
}
.sidebar-nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.sidebar-link { color: var(--text-muted); font-size: 14px; padding: 6px 12px; }
.sidebar-link:hover { text-decoration: none; color: var(--text); }
.badge-support {
  background: var(--warning);
  color: #1a1a1a;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.page {
  flex: 1;
  min-width: 0;
  padding: 24px 24px 60px;
}

h1 { font-size: 22px; margin: 0 0 20px; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; }
h2 { font-size: 17px; margin: 28px 0 12px; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat .value { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }

form { display: flex; flex-direction: column; gap: 12px; }
label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=url], select, textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-success { color: var(--success); border-color: var(--success); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-row { display: flex; flex-direction: row; gap: 8px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-pending { background: #f2d774; color: #4a3b00; }
.badge-accepted { background: #b6f0c9; color: #0d4a24; }
.badge-refused { background: #f0c7c7; color: #6b1414; }
.badge-blacklisted { background: #2c2c34; color: #fff; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.flash-success { background: #d9f4e2; color: #0d4a24; }
.flash-error { background: #f8d7da; color: #6b1414; }
.flash-info { background: #d7e6fa; color: #143d6b; }

.thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--border); flex-shrink: 0; }
.thumb.shape-round { border-radius: 50%; }
.thumb.shape-rectangle { width: 66px; height: 38px; border-radius: 6px; }
.thumb-empty { border: 1px dashed var(--border); }

.visual-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 14px;
}
.visual-row input[type=file] {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}
.socials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
}
.muted { color: var(--text-muted); }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.auth-shell { max-width: 380px; margin: 60px auto; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: -6px; }

.stars { color: #e0a900; letter-spacing: 2px; }

.qr-modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 20px;
  max-width: 320px;
  width: 90vw;
}
.qr-modal.modal-wide { max-width: 460px; }
.qr-modal[open] { animation: qr-modal-slide-down .28s ease-out; }
@keyframes qr-modal-slide-down {
  from { transform: translateY(-60px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.qr-modal::backdrop { background: rgba(0, 0, 0, 0.5); }
.qr-modal .btn-row { flex-direction: column; margin-top: 14px; }
.qr-preview { width: 100%; max-width: 260px; display: block; margin: 0 auto; border-radius: 8px; background: #fff; padding: 10px; }

@media (min-width: 769px) {
  .sidebar-collapse-toggle { display: inline-flex; }
  .sidebar.collapsed { width: 60px; padding-left: 10px; padding-right: 10px; }
  .sidebar.collapsed .topbar-brand,
  .sidebar.collapsed .sidebar-nav,
  .sidebar.collapsed .sidebar-bottom {
    display: none;
  }
  .sidebar.collapsed .sidebar-top { justify-content: center; }
}

@media (max-width: 768px) {
  .sidebar-collapse-toggle { display: none; }
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    gap: 10px;
  }
  .nav-toggle { display: inline-flex; }
  .sidebar-nav, .sidebar-bottom { display: none; }
  .sidebar.nav-open .sidebar-nav,
  .sidebar.nav-open .sidebar-bottom {
    display: flex;
    animation: qr-modal-slide-down .2s ease-out;
  }
}

@media (max-width: 640px) {
  .page { padding: 16px 14px 50px; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; padding: 8px; }
  td { border: none; padding: 6px 4px; display: flex; justify-content: space-between; gap: 10px; }
  td::before { content: attr(data-label); color: var(--text-muted); font-size: 12px; font-weight: 600; }
}
