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

/* ── CSS VARIABLES ─── */
:root {
    --bg: #0f1219;
    --surface: #161b27;
    --surface2: #1e2535;
    --border: #2a3147;
    --accent: #4f7cff;
    --accent-hover: #3d6aee;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --text: #e2e8f0;
    --text-muted: #7c8db5;
    --radius: 10px;
}

/* ── BODY ─── */
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }

/* ── HEADER ─── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); transition: opacity 0.2s; text-decoration: none; }
.header-brand:hover { opacity: 0.85; }
.header-brand i { color: var(--accent); font-size: 1.3rem; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.user-pill { background: var(--surface2); border: 1px solid var(--border); border-radius: 30px; padding: 4px 14px; font-size: 0.82rem; color: var(--text-muted); }
.btn-logout { background: rgba(239,68,68,0.12); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); border-radius: 6px; padding: 6px 14px; font-size: 0.82rem; text-decoration: none; cursor: pointer; transition: all 0.2s; }
.btn-logout:hover { background: #ef4444; color: #fff; }

/* ── MAIN ─── */
main { flex: 1; max-width: 1400px; margin: 0 auto; padding: 2rem; width: 100%; }

/* ── BUTTONS ─── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: none; cursor: pointer; font-size: 0.875rem; font-weight: 500; font-family: inherit; transition: all 0.18s; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: rgba(239,68,68,0.12); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-warning { background: rgba(245,158,11,0.12); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.btn-warning:hover { background: var(--warning); color: #fff; }
.btn-success { background: rgba(16,185,129,0.12); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* ── FORM ELEMENTS ─── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 1rem; }
label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"], select, textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    width: 100%;
    transition: border-color 0.2s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[type="file"] { background: var(--bg); border: 1px dashed var(--border); padding: 10px; border-radius: 8px; color: var(--text-muted); cursor: pointer; font-size: 0.85rem; width: 100%; }
input[type="file"]:hover { border-color: var(--accent); }

/* ── MODAL ─── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.65); backdrop-filter: blur(4px); z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto; animation: fadeUp 0.22s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; }
.modal-title { font-size: 1.05rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.3rem; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ── TABS ─── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab-btn { padding: 8px 16px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); cursor: pointer; font-family: inherit; font-size: 0.875rem; font-weight: 500; transition: all 0.15s; margin-bottom: -1px; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── TOAST ─── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 18px; border-radius: 8px; font-size: 0.875rem; font-weight: 500; animation: slideIn 0.25s ease, fadeOut 0.5s ease 2.5s forwards; }
.toast-success { background: rgba(16,185,129,0.18); border: 1px solid var(--success); color: var(--success); }
.toast-error { background: rgba(239,68,68,0.18); border: 1px solid var(--danger); color: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(8px); } }

/* ── ALERTS ─── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 0.875rem; margin-bottom: 1rem; }
.alert-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }

/* ── FOOTER ─── */
footer { text-align: center; padding: 1rem; font-size: 0.8rem; color: var(--text-muted); border-top: 1px solid var(--border); }

/* ══ RESPONSIVE ══════════════════════════════════════════ */

/* Tablet (≤ 768px) */
@media (max-width: 768px) {
    header { padding: 0 1rem; height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
    .header-brand { font-size: 0.95rem; }
    .header-actions { gap: 6px; flex-wrap: wrap; }
    .user-pill { font-size: 0.75rem; padding: 3px 10px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    main { padding: 1.25rem 1rem; }
    .modal { padding: 1.2rem; max-width: calc(100vw - 2rem); max-height: 90vh; }
    .modal-backdrop { align-items: flex-end; }
    .modal { border-radius: 14px 14px 0 0; max-width: 100%; }
    .tabs { overflow-x: auto; }
    .tab-btn { padding: 8px 12px; font-size: 0.82rem; white-space: nowrap; }
    #toast-container { right: 50%; transform: translateX(50%); bottom: 1rem; }
}

/* Phone (≤ 480px) */
@media (max-width: 480px) {
    header { padding: 8px 0.75rem; }
    .header-brand span { display: none; }
    .user-pill { max-width: 120px; }
    main { padding: 1rem 0.75rem; }
    .btn { padding: 7px 12px; font-size: 0.82rem; }
    .btn-sm { padding: 5px 8px; font-size: 0.75rem; }
}
