/* Options Algo Admin UI — Design System
   Grayscale palette · Inter + Outfit fonts
   ═══════════════════════════════════════ */

/* ── Design Tokens ──────────────────────────────────── */
:root {
  --font-base: 'Inter', system-ui, sans-serif;
  --font-display: 'Outfit', system-ui, sans-serif;

  --color-bg: #f1f3f5;
  --color-surface: #ffffff;
  --color-surface-2: #f8f9fa;
  --color-border: #e0e3e7;
  --color-muted: #9ca3af;
  --color-subtle: #6b7280;
  --color-text: #1f2937;
  --color-text-dim: #6b7280;

  --primary: #111111;
  --primary-hover: #333333;

  --success-color: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.08);
  --success-border: rgba(22, 163, 74, 0.22);

  --danger-color: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --danger-border: rgba(220, 38, 38, 0.22);

  --warning-color: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --warning-border: rgba(217, 119, 6, 0.22);

  --info-color: #2563eb;
  --info-bg: rgba(37, 99, 235, 0.08);
  --info-border: rgba(37, 99, 235, 0.22);

  --sidebar-width: 220px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.10);
  --transition: 0.18s ease;
}

/* ── Reset ───────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
}

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

p {
  margin: 0;
}

/* ── App Shell ───────────────────────────────────────── */
.app-layout {
  height: 100%;
}

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

/* ── Mobile Header & Overlay ────────────────────────────── */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 1.25rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  width: 100%;
}

.mobile-menu-toggle {
  background: transparent;
  border: none;
  color: var(--color-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  margin-left: -0.5rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.mobile-menu-toggle:hover {
  background: var(--color-surface-2);
}

.mobile-menu-toggle svg {
  width: 20px;
  height: 20px;
}

.mobile-brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary);
}

.mobile-header-right {
  display: flex;
  align-items: center;
}

.mobile-user-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-surface-2);
  color: var(--color-text-dim);
}

.mobile-user-badge svg {
  width: 16px;
  height: 16px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1050;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0 1rem;
  overflow-y: auto;
  transition: width var(--transition), min-width var(--transition);
}

/* Collapsible Sidebar Styles */
body.sidebar-collapsed {
  --sidebar-width: 68px;
}

body.sidebar-collapsed .sidebar-logo {
  padding: 0 0 1.25rem;
  justify-content: center;
}

body.sidebar-collapsed .sidebar-logo-content {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle-btn {
  margin-left: 0 !important;
}

body.sidebar-collapsed .sidebar-toggle-btn svg {
  transform: rotate(180deg);
}

body.sidebar-collapsed .sidebar-nav-item {
  justify-content: center;
  padding: 0.55rem;
}

body.sidebar-collapsed .sidebar-nav-item span {
  display: none;
}

body.sidebar-collapsed .sidebar-nav-title {
  display: none;
}

body.sidebar-collapsed .sidebar-footer {
  padding: 0.75rem 0.5rem 0;
}

body.sidebar-collapsed .sidebar-logout-btn {
  justify-content: center;
  padding: 0.55rem;
}

body.sidebar-collapsed .sidebar-logout-btn span {
  display: none;
}

.sidebar-logo-content {
  display: flex;
  flex-direction: column;
}

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--color-subtle);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.sidebar-toggle-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.sidebar-toggle-btn svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.25rem;
}

.sidebar-logo-icon {
  font-size: 1.4rem;
}

.sidebar-logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
}

.sidebar-logo-sub {
  font-size: 0.72rem;
  color: var(--color-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 0 0.6rem;
  list-style: none;
}

.sidebar-nav-title {
  padding: 1.25rem 0.75rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
}


.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-dim);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 0.1rem;
}

.sidebar-nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

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

.sidebar-nav-item.active {
  background: rgba(0, 0, 0, 0.06);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 0.75rem 0.6rem 0;
  border-top: 1px solid var(--color-border);
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-dim);
  font-size: 0.83rem;
  font-family: var(--font-base);
  cursor: pointer;
  transition: all var(--transition);
}

.sidebar-logout-btn svg {
  width: 14px;
  height: 14px;
}

.sidebar-logout-btn:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-color);
}

/* ── Mode Banner ─────────────────────────────────────── */
.mode-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}

.mode-banner svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.mode-banner-live {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-color);
}

.mode-banner-dummy {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-color);
}

/* ── Page Header ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
}

.page-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  margin-top: 0.2rem;
}

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.card-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}

.card-footer-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.75rem;
}

/* ── Stat Cards ──────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color var(--transition);
}

.stat-card:hover {
  border-color: #aaa;
}

.stat-icon {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--primary);
  margin-top: 0.2rem;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-base);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}

.btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-outline:hover {
  background: var(--color-surface-2);
  border-color: #aaa;
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-color);
  border-color: var(--danger-border);
  font-weight: 600;
}

.btn-danger:hover {
  background: rgba(220, 38, 38, 0.15);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 9999px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-gray {
  background: rgba(100, 100, 100, 0.1);
  border-color: rgba(100, 100, 100, 0.2);
  color: var(--color-subtle);
}

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

.badge-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-color);
}

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

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

/* ── Table ───────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-muted);
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

.td-muted {
  color: var(--color-text-dim);
  font-size: 0.78rem;
}

/* ── Forms ───────────────────────────────────────────── */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.form-field {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text-dim);
  margin-bottom: 0.35rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-bottom: 0.5rem;
}

.mb-3 {
  margin-bottom: 0.75rem;
}

.badge-muted {
  background: rgba(100, 100, 100, 0.08);
  border-color: rgba(100, 100, 100, 0.18);
  color: var(--color-muted);
}

.badge-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input,
select,
textarea {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: 0.84rem;
  padding: 0.5rem 0.75rem;
  transition: border-color var(--transition);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #555;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* ── Toggle Switch ───────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle-input {
  display: none;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  background: var(--color-border);
  border-radius: 9999px;
  padding: 0.2rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background var(--transition);
  color: var(--color-muted);
}

.toggle-input:checked+.toggle-label {
  background: var(--success-color);
  color: #fff;
}

.toggle-on {
  display: none;
}

.toggle-off {
  display: inline;
}

.toggle-input:checked+.toggle-label .toggle-on {
  display: inline;
}

.toggle-input:checked+.toggle-label .toggle-off {
  display: none;
}

/* ── Flash ───────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}

.flash svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.flash-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-color);
}

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

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

/* ── Empty State ─────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1rem;
  color: var(--color-muted);
  gap: 0.75rem;
}

.empty-state svg {
  width: 36px;
  height: 36px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.875rem;
}

/* ── Profile: Token rows ─────────────────────────────── */
.info-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.75rem;
}

.info-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}

.info-value {
  font-size: 0.875rem;
  color: var(--color-text);
}

.token-section {
  margin-top: 1.25rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.token-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
}

.token-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-muted);
  flex-shrink: 0;
  width: 90px;
}

.token-value {
  flex: 1;
  font-size: 0.78rem;
  font-family: monospace;
  color: var(--color-text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monospace {
  font-family: monospace;
}

/* ── Filters ─────────────────────────────────────────── */
.filter-form {
  display: flex;
  align-items: flex-end;
}

.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding-bottom: 1rem;
}

/* ── Pagination ──────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
}

.page-info {
  font-size: 0.82rem;
  color: var(--color-text-dim);
}

/* ── Utility ─────────────────────────────────────────── */
.text-success {
  color: var(--success-color);
}

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

.text-muted {
  color: var(--color-muted);
  font-size: 0.84rem;
}

.fw-600 {
  font-weight: 600;
}

/* ── Login page ──────────────────────────────────────── */
.minimal-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--color-bg);
}

.minimal-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-icon {
  font-size: 2.25rem;
  display: block;
  margin-bottom: 0.5rem;
}

.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

.login-subtitle {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.25rem;
}

.login-footer {
  font-size: 0.75rem;
  color: var(--color-muted);
  text-align: center;
  margin-top: 1rem;
}

/* ── SweetAlert2 z-index & styling custom overrides ── */
.swal2-container {
  z-index: 99999 !important;
}

.swal2-popup-custom {
  padding: 1.75rem !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--color-border) !important;
  max-width: 420px !important;
  font-family: var(--font-base) !important;
}

.swal2-title.modal-title {
  font-family: var(--font-display) !important;
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  color: var(--primary) !important;
  margin-top: 1rem !important;
  margin-bottom: 0.5rem !important;
}

.swal2-html-container {
  font-size: 0.88rem !important;
  color: var(--color-text-dim) !important;
  margin-bottom: 1.5rem !important;
  text-align: center !important;
}

.swal2-actions-custom {
  display: flex !important;
  gap: 0.5rem !important;
  justify-content: center !important;
  width: 100% !important;
}

/* ── Layout Grid Utility ── */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 992px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

/* ── Layout & Flexbox Utilities ── */
.d-flex {
  display: flex !important;
}

.d-inline-flex {
  display: inline-flex !important;
}

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

.flex-1 {
  flex: 1 !important;
}

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

.justify-between {
  justify-content: space-between !important;
}

.justify-center {
  justify-content: center !important;
}

.items-center {
  align-items: center !important;
}

.items-stretch {
  align-items: stretch !important;
}

.items-end {
  align-items: flex-end !important;
}

/* ── Spacing Utilities ── */
.m-0 {
  margin: 0 !important;
}

.h-full {
  height: 100% !important;
}

.w-full {
  width: 100% !important;
}

.mb-0 {
  margin-bottom: 0 !important;
}

.mb-2 {
  margin-bottom: 0.5rem !important;
}

.mb-3 {
  margin-bottom: 0.75rem !important;
}

.mb-6 {
  margin-bottom: 1.5rem !important;
}

.mb-8 {
  margin-bottom: 2rem !important;
}

.mt-1 {
  margin-top: 0.25rem !important;
}

.mt-3 {
  margin-top: 0.75rem !important;
}

.mt-6 {
  margin-top: 1.5rem !important;
}

.mt-n3 {
  margin-top: -0.75rem !important;
}

.mt-auto {
  margin-top: auto !important;
}

.ml-auto {
  margin-left: auto !important;
}

.pb-0 {
  padding-bottom: 0 !important;
}

.pl-6 {
  padding-left: 1.5rem !important;
}

.p-5 {
  padding: 1.25rem !important;
}

.gap-1 {
  gap: 0.25rem !important;
}

.gap-2 {
  gap: 0.5rem !important;
}

.gap-3 {
  gap: 0.75rem !important;
}

.gap-4 {
  gap: 1rem !important;
}

/* ── Border & Alignment ── */
.border-l {
  border-left: 1px solid var(--color-border) !important;
}

.text-right {
  text-align: right !important;
}

.text-uppercase {
  text-transform: uppercase !important;
}

.text-xs {
  font-size: 0.76rem !important;
}

.text-subtle {
  color: var(--color-subtle) !important;
}

.badge-micro {
  font-size: 0.58rem !important;
  padding: 0.05rem 0.28rem !important;
  border-radius: var(--radius-xs) !important;
}

.badge-interactive {
  cursor: pointer !important;
  border: none !important;
  font-size: 0.78rem !important;
  font-weight: 500 !important;
}

.icon-sm {
  width: 14px !important;
  height: 14px !important;
  flex-shrink: 0 !important;
}

/* ── Accessibility ── */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ── Multi-Column Grid Utilities ── */
.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

.form-grid-3-auto {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr auto;
  gap: 1rem;
  align-items: end;
}

@media (max-width: 992px) {
  .grid-2-1 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .form-grid-3-auto {
    grid-template-columns: 1fr;
  }
  .main-content {
    padding: 1rem;
  }
  .app-shell {
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }
  .mobile-header {
    display: flex;
  }
  body:not(.sidebar-collapsed) .sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1100;
    width: 70vw !important;
    min-width: 70vw !important;
    max-width: 300px !important;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
    transform: translateX(0);
    transition: transform var(--transition) !important;
  }
  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    width: 70vw !important;
    min-width: 70vw !important;
    max-width: 300px !important;
  }
  .sidebar-toggle-btn {
    display: none !important;
  }
}

/* ── Custom Component Utilities ── */
.card-footer-actions {
  margin-top: 1rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
}

.stat-card-horizontal {
  margin-bottom: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
}

.stat-icon-large {
  font-size: 1.5rem !important;
}

.stat-label-small {
  font-size: 0.72rem !important;
  text-transform: uppercase !important;
  color: var(--color-muted) !important;
}

.stat-label-tiny {
  font-size: 0.68rem !important;
  margin-bottom: 0.1rem !important;
}

.stat-value-medium {
  font-size: 1.2rem !important;
  font-weight: 700 !important;
  margin-top: 0.1rem !important;
}

.stat-value-large {
  font-size: 1.45rem !important;
  margin: 0 !important;
  line-height: 1.2 !important;
}

/* ── Code Block (read-only prompt viewer) ──────────────── */
.code-block {
  display: block;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--color-text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.6;
  margin: 0;
}

/* ── Modals / Dialogs ───────────────────────────────────── */
dialog {
  background: transparent;
  border: none;
  padding: 0;
  max-width: 96vw;
  max-height: 92vh;
  margin: auto;
  width: fit-content;
  overflow-y: auto;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.modal-article {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  width: 100%;
}

.modal-sm {
  width: 420px;
}

.modal-md {
  width: 540px;
}

.modal-lg {
  width: 680px;
}

.modal-xl {
  width: 860px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-header-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-header-inner svg {
  width: 18px;
  height: 18px;
  color: var(--color-subtle);
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-close {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-dim);
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.modal-close svg {
  width: 14px;
  height: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
}

.whitespace-nowrap {
  white-space: nowrap !important;
}