/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif; background: #f1f5f9; color: #0f172a; min-height: 100vh; overflow-x: hidden; }
.hidden { display: none !important; }
.muted { color: #64748b; }

/* ========== LOGIN ========== */
.login-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: #0f172a; }
.login-box { background: #1e293b; border-radius: 16px; padding: 40px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-logo { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; background: linear-gradient(135deg, #0ea5e9, #6366f1); border-radius: 14px; color: #fff; font-weight: 800; font-size: 1rem; margin-bottom: 16px; }
.login-box h2 { color: #f1f5f9; font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.login-box .muted { color: #94a3b8; font-size: .85rem; margin-bottom: 24px; display: block; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form input { background: #0f172a; border: 1px solid #334155; border-radius: 10px; padding: 12px 14px; color: #f1f5f9; font-size: .9rem; outline: none; transition: border-color .2s; }
.login-form input:focus { border-color: #0ea5e9; }
.login-form button { background: linear-gradient(135deg, #0ea5e9, #6366f1); border: none; border-radius: 10px; padding: 12px; color: #fff; font-weight: 600; font-size: .9rem; cursor: pointer; transition: opacity .2s; }
.login-form button:hover { opacity: .9; }

/* ========== APP LAYOUT ========== */
.app-layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* ========== SIDEBAR ========== */
.sidebar { background: #0f172a; display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; overflow-y: auto; z-index: 100; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 24px; }
.brand-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: linear-gradient(135deg, #0ea5e9, #6366f1); border-radius: 10px; color: #fff; font-weight: 800; font-size: .7rem; flex-shrink: 0; }
.brand-icon.small { width: 28px; height: 28px; font-size: .6rem; border-radius: 8px; }
.brand-text { color: #f1f5f9; font-weight: 700; font-size: 1rem; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none; border-radius: 10px; padding: 10px 14px; color: #94a3b8; font-size: .85rem; font-weight: 500; cursor: pointer; transition: all .15s; text-align: left; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: #1e293b; color: #e2e8f0; }
.nav-item.active { background: linear-gradient(135deg, rgba(14,165,233,.15), rgba(99,102,241,.1)); color: #0ea5e9; border-left: 3px solid #0ea5e9; }

.sidebar-footer { padding: 12px 8px 16px; border-top: 1px solid #1e293b; margin-top: auto; }
.sidebar-status { padding: 8px 14px; display: flex; flex-direction: column; gap: 2px; }
.status-dot { font-size: .75rem; color: #94a3b8; }
.status-dot::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #22c55e; margin-right: 6px; }
.nav-logout { color: #ef4444 !important; }
.nav-logout:hover { background: rgba(239,68,68,.1) !important; }

/* ========== MOBILE HEADER ========== */
.mobile-header { display: none; position: sticky; top: 0; z-index: 90; background: #0f172a; padding: 12px 16px; align-items: center; gap: 12px; color: #f1f5f9; }
.hamburger { background: none; border: none; color: #f1f5f9; cursor: pointer; padding: 4px; }
.hamburger svg { width: 22px; height: 22px; }
#mobile-section-title { font-weight: 600; font-size: .95rem; }

/* ========== CONTENT ========== */
.content { padding: 24px; overflow-y: auto; min-height: 100vh; }
.page { display: none; }
.page.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-header { margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header .muted { font-size: .85rem; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ========== CARDS ========== */
.card { background: #fff; border-radius: 12px; border: 1px solid #e2e8f0; padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ========== STATS ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 12px; border: 1px solid #e2e8f0; padding: 16px; display: flex; flex-direction: column; gap: 4px; transition: transform .15s, box-shadow .15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.stat-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #64748b; }
.stat-card strong { font-size: 1.6rem; font-weight: 800; }
.stat-card.accent-green strong { color: #16a34a; }
.stat-card.accent-red strong { color: #dc2626; }
.stat-card.accent-orange strong { color: #ea580c; }
.stat-card.accent-blue strong { color: #2563eb; }
.stat-card.accent-purple strong { color: #7c3aed; }
.stat-card.accent-cyan strong { color: #0891b2; }
.stat-card.accent-indigo strong { color: #4f46e5; }
.stat-card.accent-teal strong { color: #0d9488; }

/* ========== BUTTONS ========== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; font-size: .8rem; font-weight: 600; cursor: pointer; transition: all .15s; border: 1px solid transparent; white-space: nowrap; }
.btn-primary { background: #0ea5e9; color: #fff; border-color: #0ea5e9; }
.btn-primary:hover { background: #0284c7; }
.btn-accent { background: #6366f1; color: #fff; border-color: #6366f1; }
.btn-accent:hover { background: #4f46e5; }
.btn-ghost { background: #f8fafc; color: #334155; border-color: #e2e8f0; }
.btn-ghost:hover { background: #e2e8f0; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }

/* ========== FORMS ========== */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-col { display: flex; flex-direction: column; gap: 12px; }
.form-row label, .form-col label { display: flex; flex-direction: column; gap: 4px; }
.form-row label span, .form-col label span { font-size: .75rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .3px; }
input, select, textarea { padding: 9px 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: .85rem; font-family: inherit; color: #0f172a; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { border-color: #0ea5e9; box-shadow: 0 0 0 3px rgba(14,165,233,.1); }
input[type="file"] { padding: 7px; font-size: .8rem; }
input[type="search"] { max-width: 200px; }

.feeds-chooser { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: .8rem; }
.feeds-chooser label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.check-group { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: .8rem; }
.check-group label, .check-row { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: .8rem; }
.auto-refresh-label { display: flex; align-items: center; gap: 6px; font-size: .8rem; }

.upload-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 14px; }
.upload-bar input[type="text"] { flex: 1; min-width: 180px; }

/* ========== TABLES ========== */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.data-table th { background: #f8fafc; text-align: left; padding: 10px 12px; font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; color: #64748b; border-bottom: 2px solid #e2e8f0; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.data-table td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.data-table tr:hover td { background: #f8fafc; }
.data-table img { border-radius: 6px; }
.logos-table { min-width: 600px; }
.tokens-table { min-width: 900px; }
.audit-table { min-width: 700px; }
.empty-cell { text-align: center; color: #94a3b8; padding: 32px !important; }

.status-badge { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: .7rem; font-weight: 600; }
.status-active { background: #dcfce7; color: #166534; }
.status-inactive { background: #fef2f2; color: #991b1b; }

.actions-cell { display: flex; gap: 4px; flex-wrap: wrap; }
.action-btn { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 6px; font-size: .72rem; font-weight: 600; cursor: pointer; border: 1px solid #e2e8f0; background: #f8fafc; color: #334155; transition: all .15s; white-space: nowrap; }
.action-btn:hover { background: #e2e8f0; }
.action-btn.ok { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.action-btn.warn { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.action-btn.warn:hover { background: #fee2e2; }

.logo-thumb { width: 36px; height: 36px; object-fit: contain; }

.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 10px 0; margin-bottom: 8px; font-size: .8rem; flex-wrap: wrap; }
.bulk-bar label { display: flex; align-items: center; gap: 4px; }

/* ========== TABS ========== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e2e8f0; margin-bottom: 16px; }
.logos-tab-btn { background: none; border: none; padding: 10px 18px; font-size: .85rem; font-weight: 600; color: #64748b; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; display: flex; align-items: center; gap: 6px; }
.logos-tab-btn:hover { color: #0f172a; }
.logos-tab-btn.active { color: #0ea5e9; border-bottom-color: #0ea5e9; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: .7rem; font-weight: 700; background: #e2e8f0; color: #475569; }
.logos-tab-btn.active .badge { background: #0ea5e9; color: #fff; }
.logos-tab-panel { display: none; }
.logos-tab-panel.active { display: block; }

.view-toggle { display: flex; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.logos-view-btn { background: #f8fafc; border: none; padding: 6px 12px; font-size: .75rem; font-weight: 600; color: #64748b; cursor: pointer; transition: all .15s; }
.logos-view-btn.active { background: #0ea5e9; color: #fff; }

/* ========== GRID VIEW ========== */
.logos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; padding: 8px 0; }
.logo-grid-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; text-align: center; transition: transform .15s, box-shadow .15s; }
.logo-grid-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.logo-grid-card img { width: 48px; height: 48px; object-fit: contain; margin: 0 auto 8px; display: block; }
.logo-grid-name { font-size: .75rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo-grid-slug { font-size: .65rem; color: #94a3b8; margin-bottom: 6px; }
.logo-grid-actions { display: flex; justify-content: center; gap: 4px; }

/* ========== CODE BOX ========== */
.code-box { background: #0f172a; color: #a5f3fc; padding: 14px 16px; border-radius: 10px; font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: .75rem; line-height: 1.5; overflow-x: auto; white-space: pre-wrap; word-break: break-word; max-height: 300px; margin-top: 12px; }

/* ========== ALERT ========== */
.alert { padding: 12px 16px; border-radius: 8px; font-size: .8rem; margin-bottom: 12px; }

/* ========== TOAST / ERROR ========== */
.toast { position: fixed; bottom: 20px; right: 20px; z-index: 9999; background: #dc2626; color: #fff; padding: 14px 20px; border-radius: 10px; font-size: .85rem; font-weight: 500; max-width: 400px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }

/* ========== MODAL ========== */
.modal { border: none; border-radius: 14px; padding: 28px; max-width: 520px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal::backdrop { background: rgba(15,23,42,.6); backdrop-filter: blur(4px); }
.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }

/* ========== 2-COL GRID ========== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

/* ========== DOWNLOAD STATUS ========== */
.download-status-box { padding: 12px 16px; border-radius: 8px; font-size: .8rem; margin-bottom: 12px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; width: 260px; transition: left .25s ease; z-index: 200; }
  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,.3); }
  .mobile-header { display: flex; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; overflow-x: auto; }
  .upload-bar { flex-direction: column; }
  .upload-bar input[type="text"] { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
}
