:root {
    --primary: #D83B20;
    --primary-hover: #c0331b;
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding: 1.5rem 1rem;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 620px; margin: 0 auto; }
.admin-body { max-width: 1100px; margin: 0 auto; }

/* ===== HEADER ===== */
.header {
    text-align: center;
    margin-bottom: 1.5rem;
    background: var(--primary);
    padding: 2rem 1.5rem;
    border-radius: var(--radius);
    color: #fff;
}
.logo { max-width: 180px; margin: 0 auto 0.75rem; display: block; }
.header h1 { font-size: 1.35rem; font-weight: 600; margin-bottom: 0.25rem; }
.header p { font-size: 0.9rem; opacity: 0.85; }

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}
.tab-btn {
    background: transparent !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    margin-bottom: -2px;
    padding: 10px 18px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: color 0.15s, border-color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 0 !important;
    box-shadow: none !important;
}
.tab-btn:hover {
    color: var(--text);
    background: transparent !important;
}
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary) !important;
    font-weight: 600;
    background: transparent !important;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== FORMS ===== */
.form-container {
    background: var(--card);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.form-group { margin-bottom: 1.25rem; }
.form-row { display: flex; gap: 1rem; margin-bottom: 1.25rem; }
.form-row .form-group { margin-bottom: 0; }
.half { flex: 1; }
label { display: block; font-weight: 500; margin-bottom: 0.4rem; font-size: 0.875rem; color: #374151; }
.required { color: #ef4444; }
small { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

input[type="text"], input[type="url"], input[type="number"], input[type="password"],
input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(216, 59, 32, 0.1);
}
textarea { resize: vertical; min-height: 80px; }

/* ===== BUTTONS ===== */
button {
    font-family: inherit;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s, opacity 0.15s;
    white-space: nowrap;
}
button:hover { background: var(--primary-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e5e7eb !important; }

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
}
.btn-danger {
    background: #fff;
    color: #dc2626;
    border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fef2f2 !important; }

.btn-portal {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s;
}
.btn-portal:hover { background: var(--primary-hover); }

/* Link buttons for info bar */
.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.85rem;
    background: #fff;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: background 0.15s;
}
.btn-link:hover { background: #f9fafb; }
.btn-link-blue { color: #1e40af; background: #eff6ff; border-color: #bfdbfe; }
.btn-link-blue:hover { background: #dbeafe; }

/* ===== SPINNER ===== */
.spinner {
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    width: 16px; height: 16px;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ===== MESSAGES ===== */
.message {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
    font-size: 0.9rem;
}
.message.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.message.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
}
.badge-barter { background: #ecfdf5; color: #065f46; }
.badge-fee { background: #fef3c7; color: #92400e; }
.badge-active { background: #ecfdf5; color: #047857; }
.badge-paused { background: #fef2f2; color: #b91c1c; }

/* ===== INFO BAR (Public form) ===== */
.info-bar {
    background: #f9fafb;
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.9rem;
}
.info-bar-label { font-weight: 600; color: #374151; }

/* ===== BANK SECTION ===== */
.bank-section {
    background: #fffbeb;
    padding: 1.25rem;
    border-radius: 6px;
    border: 1px solid #fef3c7;
    margin-bottom: 1.25rem;
}
.bank-section-title {
    color: #92400e;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.bank-section-desc {
    font-size: 0.8rem;
    color: #b45309;
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* ===== ADMIN LAYOUT ===== */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.admin-header h2 { font-size: 1.25rem; font-weight: 700; }
.admin-container {
    background: var(--card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Section card (create campaign area) */
.section-card {
    background: #f9fafb;
    padding: 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

/* ===== SLOT BUILDER ===== */
.slot-builder {
    margin-bottom: 1.25rem;
    background: #fff;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.slot-builder > label { font-weight: 600; margin-bottom: 0.5rem; }
.slot-builder-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.slot-builder-controls {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.slot-input-group {
    flex: 1;
    min-width: 120px;
}
.slot-input-group input { width: 100%; }
.slot-label {
    font-size: 0.75rem;
    margin-bottom: 2px;
    color: var(--text-secondary);
    font-weight: 500;
}
.btn-add-slot {
    height: 38px;
    padding: 0 1rem;
    font-size: 0.8rem;
    white-space: nowrap;
}
.slots-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0.75rem;
    padding: 10px;
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    min-height: 40px;
    align-items: center;
}
.slots-empty-msg {
    color: #9ca3af;
    font-size: 0.8rem;
}
.slot-badge {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}
.slot-badge-text { color: #111827; font-weight: 500; }
.slot-badge-quota {
    background: #dbeafe;
    color: #1e3a8a;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}
.slot-badge-remove {
    background: none !important;
    border: none !important;
    color: #9ca3af;
    cursor: pointer;
    padding: 0 !important;
    font-size: 0.85rem;
    line-height: 1;
    display: inline-flex !important;
}
.slot-badge-remove:hover { color: #ef4444; }

/* ===== OVERLAY / MODAL ===== */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}
.login-box {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    border: 1px solid var(--border);
}
.login-box h2 { text-align: center; margin-bottom: 1.25rem; font-size: 1.25rem; }

#loginOverlay {
    background: linear-gradient(135deg, #111827, #000);
}
#loginOverlay .login-box {
    background: #1f2937;
    border-color: #374151;
    color: #fff;
}
#loginOverlay .login-box h2 { color: #fff; }
#loginOverlay .login-box input[type="password"] {
    background: #0f172a;
    border-color: #374151;
    color: #fff;
}
#loginOverlay .login-box input::placeholder { color: #9ca3af; }

#editCampOverlay .login-box {
    background: #fff;
    color: var(--text);
}
#editCampOverlay .login-box h3 { color: var(--text); }
#editCampOverlay .login-box label { color: #374151; }

/* ===== TABLES ===== */
.table-responsive { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
tr:last-child td { border-bottom: none; }

td input[type="text"] {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 4px;
    background: #f9fafb;
}
td select {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 4px;
    min-width: 110px;
    width: auto;
}
td button { box-shadow: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .form-row { flex-direction: column; gap: 0.75rem; }
    .admin-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .tabs { overflow-x: auto; flex-wrap: nowrap; }
    .tab-btn { flex-shrink: 0; }
    .info-bar { flex-direction: column; align-items: flex-start; }
    .slot-builder-controls { flex-direction: column; }
    .slot-input-group { min-width: 100%; }
}
