/* =============================================================================
   MODERN DESIGN SYSTEM - 3x-ui Reseller Panel
   Improved UI/UX with better components, spacing, typography, and interactions
   ============================================================================= */

/* ===== THEME TOKENS ===== */
:root,
:root[data-theme="dark"] {
  /* Colors */
  --bg: #0e1116;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(79, 140, 255, 0.08), transparent 60%);
  --panel: #161b22;
  --panel-2: #1d242e;
  --panel-3: #232c38;
  --border: #2a323d;
  --text: #e8ebf0;
  --muted: #9aa6b4;

  /* Primary brand */
  --primary: #4f8cff;
  --primary-press: #3b78ec;
  --primary-hover: #6a9eff;
  --primary-light: rgba(79, 140, 255, 0.12);
  --on-primary: #ffffff;

  /* Status colors */
  --green: #30a46c;
  --green-light: rgba(48, 164, 108, 0.12);
  --red: #e5484d;
  --red-light: rgba(229, 72, 77, 0.12);
  --yellow: #e8c400;
  --yellow-light: rgba(232, 196, 0, 0.12);
  --orange: #f5a623;
  --orange-light: rgba(245, 166, 35, 0.12);
  --blue: #3b82f6;

  /* Badge colors */
  --badge-green-bg: rgba(48, 164, 108, 0.18);
  --badge-green-fg: #5bd99a;
  --badge-red-bg: rgba(229, 72, 77, 0.18);
  --badge-red-fg: #ff8086;
  --badge-yellow-bg: rgba(232, 196, 0, 0.16);
  --badge-yellow-fg: #ecd04e;
  --badge-orange-bg: rgba(245, 166, 35, 0.16);
  --badge-orange-fg: #ffc078;
  --badge-blue-bg: rgba(59, 130, 246, 0.16);
  --badge-blue-fg: #60a5fa;
  --badge-muted-bg: #232c38;
  --badge-muted-fg: #9aa6b4;

  /* Shadows */
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.38);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.4);
  --topbar-bg: rgba(22, 27, 34, 0.85);

  /* Transitions */
  --transition: all 0.2s ease;
  --transition-fast: all 0.12s ease;
}

:root[data-theme="light"] {
  --bg: #f3f5f9;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(79, 140, 255, 0.12), transparent 60%);
  --panel: #ffffff;
  --panel-2: #f1f4f8;
  --panel-3: #e7ecf3;
  --border: #e1e6ee;
  --text: #1a2230;
  --muted: #687283;

  --primary: #2f6bf0;
  --primary-press: #245ad6;
  --primary-hover: #4179f7;
  --primary-light: rgba(47, 107, 240, 0.12);
  --on-primary: #ffffff;

  --green: #1a8f57;
  --green-light: rgba(26, 143, 87, 0.12);
  --red: #d23b40;
  --red-light: rgba(210, 59, 64, 0.12);
  --yellow: #b58a00;
  --yellow-light: rgba(181, 138, 0, 0.12);
  --orange: #d98400;
  --orange-light: rgba(217, 132, 0, 0.12);
  --blue: #1d4ed8;

  --badge-green-bg: rgba(26, 143, 87, 0.12);
  --badge-green-fg: #167a49;
  --badge-red-bg: rgba(210, 59, 64, 0.1);
  --badge-red-fg: #c0282d;
  --badge-yellow-bg: rgba(181, 138, 0, 0.14);
  --badge-yellow-fg: #936f00;
  --badge-orange-bg: rgba(217, 132, 0, 0.14);
  --badge-orange-fg: #b56a00;
  --badge-blue-bg: rgba(29, 78, 216, 0.12);
  --badge-blue-fg: #1e40af;
  --badge-muted-bg: #e7ecf3;
  --badge-muted-fg: #687283;

  --shadow: 0 10px 34px rgba(34, 50, 84, 0.14);
  --shadow-sm: 0 2px 10px rgba(34, 50, 84, 0.08);
  --shadow-xs: 0 1px 3px rgba(34, 50, 84, 0.08);
  --shadow-lg: 0 20px 50px rgba(34, 50, 84, 0.15);
  --topbar-bg: rgba(255, 255, 255, 0.85);

  --transition: all 0.2s ease;
  --transition-fast: all 0.12s ease;
}

/* ===== RESET & BASE STYLES ===== */
* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Vazirmatn", "Segoe UI", Roboto, Tahoma, system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  font-weight: 400;
  transition: background-color 0.2s, color 0.2s;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.12s ease;
}

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

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.1rem;
}

p {
  margin: 0;
  line-height: 1.6;
}

code, .mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 4px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ===== TOP BAR ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px clamp(12px, 3vw, 20px);
  background: var(--topbar-bg);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  flex-wrap: wrap;
  box-shadow: var(--shadow-xs);
}

.topbar .brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .brand .dot {
  color: var(--primary);
  font-size: 1.3em;
}

.topbar .spacer {
  flex: 1;
}

.topbar .who {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.topbar .role-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: var(--panel-3);
  border-color: var(--primary);
}

.icon-btn:active {
  transform: scale(0.95);
}

.lang-toggle {
  font-size: 0.85rem;
  padding: 6px 11px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.lang-toggle:hover {
  background: var(--panel-3);
  text-decoration: none;
}

/* ===== LAYOUT ===== */
.layout {
  display: flex;
  min-height: calc(100vh - 55px);
  align-items: stretch;
}

.sidebar {
  width: 212px;
  flex-shrink: 0;
  padding: 14px 10px;
  background: var(--panel);
  border-inline-end: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin-bottom: 4px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition-fast);
  position: relative;
}

.sidebar a:hover {
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
}

.sidebar a.active {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.sidebar a .ic {
  width: 18px;
  text-align: center;
  opacity: 0.9;
  font-size: 1.1em;
}

.container {
  flex: 1;
  min-width: 0;
  padding: 22px clamp(14px, 3vw, 32px);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
}

.page-head .spacer {
  flex: 1;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: -6px 0 18px;
}

/* ===== CARDS ===== */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.card > h1 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.5rem;
}

.card > h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.card > h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.card.highlight {
  border-color: var(--primary);
  background: var(--primary-light);
}

.card.success {
  border-color: var(--green);
  background: var(--green-light);
}

.card.warning {
  border-color: var(--yellow);
  background: var(--yellow-light);
}

.card.error {
  border-color: var(--red);
  background: var(--red-light);
}

/* ===== GRID ===== */
.grid {
  display: grid;
  gap: 18px;
}

.grid.cols-2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

/* ===== STATS ===== */
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

a.stat:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.stat .n {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.stat .l {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.stat .desc {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 8px;
}

/* ===== FORMS ===== */
label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 12px 0 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--panel-2);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
  display: block;
}

.error-text {
  font-size: 0.78rem;
  color: var(--red);
  margin-top: 4px;
  display: block;
}

.success-text {
  font-size: 0.78rem;
  color: var(--green);
  margin-top: 4px;
  display: block;
}

.checkbox,
.radio {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  cursor: pointer;
}

.checkbox input,
.radio input {
  width: auto;
  margin: 0;
  cursor: pointer;
}

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

.form-group {
  margin-bottom: 14px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
  background: var(--primary);
  color: var(--on-primary);
  border: 1px solid transparent;
  padding: 10px 18px;
  border-radius: 9px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  outline: none;
}

.btn:hover {
  background: var(--primary-hover);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn.sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 8px;
}

.btn.lg {
  padding: 12px 24px;
  font-size: 1rem;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn.ghost:hover {
  background: var(--panel-2);
  border-color: var(--primary);
  color: var(--primary);
}

.btn.secondary {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn.secondary:hover {
  background: var(--panel-3);
  border-color: var(--primary);
}

.btn.danger {
  background: var(--red);
}

.btn.danger:hover {
  filter: brightness(1.1);
  box-shadow: var(--shadow-sm);
}

.btn.success {
  background: var(--green);
}

.btn.success:hover {
  filter: brightness(1.08);
  box-shadow: var(--shadow-sm);
}

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

.btn.warning:hover {
  filter: brightness(0.95);
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-group.vertical {
  flex-direction: column;
}

/* ===== TABLES ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 12px 14px;
  text-align: start;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--panel-2);
  padding: 14px;
}

tbody tr {
  transition: background-color 0.1s ease;
}

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

tbody tr:last-child td {
  border-bottom: none;
}

td.actions {
  white-space: nowrap;
}

td.text-center {
  text-align: center;
}

td.text-end {
  text-align: end;
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge.green {
  background: var(--badge-green-bg);
  color: var(--badge-green-fg);
}

.badge.red {
  background: var(--badge-red-bg);
  color: var(--badge-red-fg);
}

.badge.yellow {
  background: var(--badge-yellow-bg);
  color: var(--badge-yellow-fg);
}

.badge.orange {
  background: var(--badge-orange-bg);
  color: var(--badge-orange-fg);
}

.badge.blue {
  background: var(--badge-blue-bg);
  color: var(--badge-blue-fg);
}

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

/* ===== USAGE BAR ===== */
.usage {
  min-width: 150px;
}

.usage .bar {
  height: 8px;
  background: var(--panel-3);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.usage .bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
  background: var(--primary);
}

.usage .bar.full > span {
  background: var(--red);
}

.usage .bar.warning > span {
  background: var(--yellow);
}

.usage .lbl {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

/* Compact x-ui-like traffic meter: used · bar · limit, with remaining below. */
.usage-xui { min-width: 270px; max-width: 430px; }
.usage-line { direction: ltr; display: flex; align-items: center; gap: 10px; }
.usage-line > *, .reseller-usage bdi { unicode-bidi: isolate; }
.reseller-usage { min-width: 240px; }
.usage-number, .usage-limit { min-width: 66px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.usage-number { text-align: end; color: var(--text); }
.usage-limit { text-align: start; color: var(--muted); }
.usage-track { flex: 1; min-width: 110px; height: 9px; background: var(--panel-3); border-radius: 999px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.18); }
.usage-track > span { display: block; height: 100%; border-radius: inherit; min-width: 0; transition: width .4s ease; }
.usage-meta { margin-top: 6px; padding-inline: 76px 76px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .72rem; }
.remaining-pill { color: var(--badge-green-fg); background: var(--badge-green-bg); border-radius: 999px; padding: 2px 8px; font-weight: 700; white-space: nowrap; }

@media (max-width: 720px) {
  .usage-xui { min-width: 230px; }
  .usage-meta { padding-inline: 0; }
}

/* ===== ALERTS & FLASH ===== */
.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideIn 0.2s ease;
}

.flash.success {
  background: var(--badge-green-bg);
  border-color: var(--green);
  color: var(--badge-green-fg);
}

.flash.error {
  background: var(--badge-red-bg);
  border-color: var(--red);
  color: var(--badge-red-fg);
}

.flash.warning {
  background: var(--badge-yellow-bg);
  border-color: var(--yellow);
  color: var(--badge-yellow-fg);
}

.flash.info {
  background: var(--badge-blue-bg);
  border-color: var(--blue);
  color: var(--badge-blue-fg);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== MODAL ===== */
.modal-back {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 12, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 60;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 14px;
  overflow-y: auto;
  animation: fadeIn 0.15s ease;
}

.modal-back.open {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.modal .modal-head h2 {
  margin: 0;
  flex: 1;
  font-size: 1.3rem;
}

.modal .close-x {
  cursor: pointer;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  background: none;
  border: none;
  padding: 0;
  transition: color 0.12s ease;
}

.modal .close-x:hover {
  color: var(--text);
}

.modal-body {
  margin: 16px 0;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ===== LINK / QR BLOCKS ===== */
.linkblock {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 14px;
  margin-bottom: 14px;
  transition: var(--transition-fast);
}

.linkblock:hover {
  border-color: var(--primary);
}

.linkblock .lh {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.linkblock .lrow {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.linkblock .lrow input {
  font-size: 0.78rem;
  flex: 1;
}

.linkblock .qr {
  text-align: center;
  margin-top: 14px;
}

.linkblock .qr img {
  width: 190px;
  height: 190px;
  background: #fff;
  border-radius: 10px;
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

/* ===== LOGIN PAGE ===== */
.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card .brand {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.login-card .brand .dot {
  color: var(--primary);
}

.login-card .tag {
  text-align: center;
  color: var(--muted);
  margin-bottom: 24px;
  font-size: 0.95rem;
  font-weight: 500;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===== LOADING STATES ===== */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 50%, var(--panel-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton.text {
  height: 12px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.skeleton.title {
  height: 24px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.skeleton.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

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

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state .title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state .description {
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* ===== UTILITIES ===== */
.muted {
  color: var(--muted);
}

.text-primary {
  color: var(--primary);
}

.text-success {
  color: var(--green);
}

.text-danger {
  color: var(--red);
}

.text-warning {
  color: var(--yellow);
}

.text-center {
  text-align: center;
}

.text-end {
  text-align: end;
}

.text-start {
  text-align: start;
}

.nowrap {
  white-space: nowrap;
}

.mt {
  margin-top: 14px;
}

.mb {
  margin-bottom: 14px;
}

.mt-2 {
  margin-top: 20px;
}

.mb-2 {
  margin-bottom: 20px;
}

.p-0 {
  padding: 0;
}

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

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-center {
  align-items: center;
  justify-content: center;
}

.flex-between {
  align-items: center;
  justify-content: space-between;
}

.gap-sm {
  gap: 6px;
}

.gap-md {
  gap: 12px;
}

.gap-lg {
  gap: 18px;
}

.opacity-50 {
  opacity: 0.5;
}

.opacity-75 {
  opacity: 0.75;
}

details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
}

details summary:hover {
  color: var(--text);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 760px) {
  html {
    font-size: 14.5px;
  }

  .layout {
    flex-direction: column;
    min-height: 0;
  }

  .sidebar {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 8px 10px;
    border-inline-end: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    position: sticky;
    top: 55px;
    z-index: 20;
    background: var(--panel);
  }

  .sidebar a {
    margin: 0;
    padding: 8px 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .sidebar a span:not(.ic) {
    display: inline;
  }

  .container {
    padding: 16px 14px;
  }

  .topbar .who {
    display: none;
  }

  .page-head {
    margin-bottom: 18px;
  }

  .page-head h1 {
    font-size: 1.5rem;
  }

  .btn-group {
    gap: 6px;
  }

  .modal {
    padding: 18px;
    border-radius: 14px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 0.85rem;
  }

  th, td {
    padding: 10px 10px;
  }

  .grid.cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 420px) {
  .topbar {
    gap: 8px;
  }

  .topbar .role-chip {
    display: none;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .page-head h1 {
    font-size: 1.3rem;
  }

  .grid.cols-4 {
    grid-template-columns: 1fr;
  }

  .grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .btn.sm {
    width: 100%;
  }
}
