/* ═══════════════════════════════════════════════════════════
   DocuGen — Design System CSS
   Dark mode premium · Glassmorphism · Animaciones CSS3
   ═══════════════════════════════════════════════════════════ */

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

/* ─── Custom Properties ─────────────────────────────────── */
:root {
  --bg-primary:     #0a0f1e;
  --bg-secondary:   #111827;
  --bg-card:        rgba(255,255,255,0.04);
  --bg-card-hover:  rgba(255,255,255,0.07);
  --border:         rgba(255,255,255,0.08);
  --border-hover:   rgba(255,255,255,0.16);
  --accent:         #6366f1;
  --accent-hover:   #4f46e5;
  --accent-glow:    rgba(99,102,241,0.35);
  --accent-light:   rgba(99,102,241,0.12);
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --success:        #10b981;
  --success-bg:     rgba(16,185,129,0.12);
  --warning:        #f59e0b;
  --warning-bg:     rgba(245,158,11,0.12);
  --danger:         #ef4444;
  --danger-bg:      rgba(239,68,68,0.12);
  --sidebar-w:      260px;
  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      16px;
  --shadow:         0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:      0 8px 48px rgba(0,0,0,0.6);
  --transition:     0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ═══════════════════════════════════════════════════════════
   AUTH PAGES (login / register)
   ═══════════════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99,102,241,0.22) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(79,70,229,0.18) 0%, transparent 55%),
    radial-gradient(ellipse 40% 40% at 60% 40%, rgba(139,92,246,0.12) 0%, transparent 50%),
    var(--bg-primary);
  z-index: 0;
}

.auth-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(99,102,241,0.08) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
  0%   { transform: translateY(0); }
  100% { transform: translateY(40px); }
}

.auth-card {
  position: relative;
  z-index: 1;
  background: rgba(17,24,39,0.85);
  border: 1px solid var(--border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 0 0 1px rgba(99,102,241,0.1), var(--shadow-lg);
  animation: authSlideIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes authSlideIn {
  from { opacity: 0; transform: translateY(32px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 12px;
  box-shadow: 0 0 32px var(--accent-glow);
}

.auth-logo h1 {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, #f1f5f9, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   FORM COMPONENTS
   ═══════════════════════════════════════════════════════════ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  background: rgba(99,102,241,0.06);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition);
}

.btn:hover::after { background: rgba(255,255,255,0.06); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
  box-shadow: 0 6px 25px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.btn-success { background: var(--success); color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,0.3); }
.btn-danger  { background: var(--danger);  color: #fff; box-shadow: 0 4px 12px rgba(239,68,68,0.3); }
.btn-warning { background: var(--warning); color: #000; box-shadow: 0 4px 12px rgba(245,158,11,0.3); }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  aspect-ratio: 1;
  justify-content: center;
}

/* ─── Spinner ──────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-text { opacity: 0.7; }

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

/* ═══════════════════════════════════════════════════════════
   LAYOUT — SIDEBAR + MAIN
   ═══════════════════════════════════════════════════════════ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: rgba(10,15,30,0.96);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.sidebar-close-btn {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.sidebar-close-btn:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 20, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px var(--accent-glow);
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, #f1f5f9, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.sidebar-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 2px;
  display: inline-block;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
  min-height: 40px;
}

.sidebar-link:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left: 3px solid var(--accent);
  padding-left: 9px;
  font-weight: 600;
}

.sidebar-link .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
  background: rgba(10,15,30,0.8);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name  { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Main Content ─────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left 0.3s ease;
}

.topbar {
  background: rgba(10,15,30,0.88);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.sidebar-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.balance-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  white-space: nowrap;
}

.balance-badge .badge-icon { font-size: 14px; }
.balance-badge .amount { font-weight: 700; color: var(--success); }
.balance-badge .currency { font-size: 11px; color: var(--text-muted); font-weight: 600; }

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

/* ═══════════════════════════════════════════════════════════
   CARDS & STATS
   ═══════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color var(--transition), transform var(--transition);
  position: relative;
}

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

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

.card-title {
  font-size: 15px;
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
}

.stat-card:hover {
  border-color: rgba(99,102,241,0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.stat-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-light);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: rgba(255,255,255,0.03);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}

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

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ─── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-accent  { background: var(--accent-light); color: var(--accent); }
.badge-muted   { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ─── Brand badges ─────────────────────────────────────────── */
.badge-tmobile { background: rgba(226,0,116,0.2); color: #e20074; border: 1px solid rgba(226,0,116,0.3); }
.badge-apple   { background: rgba(100,100,100,0.2); color: #aaa; border: 1px solid rgba(150,150,150,0.3); }
.badge-ebay    { background: rgba(54,101,243,0.2); color: #3665f3; border: 1px solid rgba(54,101,243,0.3); }
.badge-sprint  { background: rgba(255,230,0,0.15); color: #ffe600; border: 1px solid rgba(255,230,0,0.3); }
.badge-ishop   { background: rgba(255,107,53,0.2); color: #ff6b35; border: 1px solid rgba(255,107,53,0.3); }
.badge-sunat   { background: rgba(200,16,46,0.2); color: #e03060; border: 1px solid rgba(200,16,46,0.3); }
.badge-custom  { background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }

/* ─── Document cards (generate page) ─────────────────────── */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.doc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.doc-card:hover {
  border-color: rgba(99,102,241,0.4);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(99,102,241,0.15);
}

.doc-card:hover::before { opacity: 1; }

.doc-card-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 14px;
  background: rgba(255,255,255,0.06);
}

.doc-card-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.doc-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.doc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.doc-price {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
}

/* ─── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-overlay.show .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 22px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 17px; font-weight: 700; }

.modal-close {
  background: rgba(255,255,255,0.06);
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 24px; display: flex; gap: 10px; justify-content: flex-end; }

/* ─── Toast Notifications ──────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

.toast.removing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); max-height: 100px; }
  to   { opacity: 0; transform: translateX(100%); max-height: 0; padding: 0; margin: 0; }
}

.toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; }
.toast-title { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.toast-msg { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--accent); }

/* ─── Alert boxes ──────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: var(--success-bg); border: 1px solid rgba(16,185,129,0.3); color: var(--success); }
.alert-error   { background: var(--danger-bg);  border: 1px solid rgba(239,68,68,0.3);  color: var(--danger); }
.alert-warning { background: var(--warning-bg); border: 1px solid rgba(245,158,11,0.3); color: var(--warning); }
.alert-info    { background: var(--accent-light); border: 1px solid rgba(99,102,241,0.3); color: var(--accent); }

/* ─── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  transition: all var(--transition);
}

.page-link:hover { border-color: var(--accent); color: var(--accent); }
.page-link.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-link.disabled { opacity: 0.4; pointer-events: none; }

/* ─── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
  width: fit-content;
  margin-bottom: 24px;
}

.tab-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  transition: all var(--transition);
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ─── Misc ─────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

.text-muted    { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent   { color: var(--accent); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }

.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }
.fs-24  { font-size: 24px; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

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

.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }

/* ─── Progress / Loading bar ───────────────────────────────── */
.progress-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  border-radius: 2px;
  animation: progressAnim 1.5s ease infinite;
}

@keyframes progressAnim {
  0%   { width: 0%; margin-left: 0; }
  50%  { width: 60%; margin-left: 20%; }
  100% { width: 0%;  margin-left: 100%; }
}

/* ─── Responsive Media Queries ─────────────────────────────── */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0,0,0,0.85);
  }
  .sidebar-close-btn {
    display: flex;
  }
  .sidebar-toggle-btn {
    display: inline-flex;
  }
  .main {
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  .page-content { padding: 16px 12px; }
  .topbar { padding: 0 14px; height: 60px; }
  .topbar-title { font-size: 15px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  
  /* Form controls touch sizing (avoids iOS Safari auto-zoom) */
  input, select, textarea, .form-control {
    font-size: 16px !important;
    min-height: 44px;
  }
  
  /* Tables */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrapper table {
    min-width: 640px;
  }

  /* Modals */
  .modal {
    max-width: calc(100vw - 24px);
    padding: 20px 16px;
    margin: 12px auto;
  }
  .modal-body {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Filter toolbars */
  .page-content > form,
  .page-content > div:first-child form {
    width: 100%;
  }
  .page-content form input.form-control,
  .page-content form select.form-control {
    width: 100% !important;
    flex: 1 1 100%;
  }
}

@media (max-width: 540px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 32px 20px; margin: 12px; }
  .doc-grid { grid-template-columns: 1fr; }
  .card { padding: 16px 14px; border-radius: var(--radius-sm); }
  .card-header { margin-bottom: 14px; }
  
  .balance-badge {
    padding: 5px 10px;
    font-size: 12px;
  }
  .balance-badge .currency { display: none; }
  
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
}
