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

:root {
    --bg: #0d0f14;
    --bg2: #13161e;
    --bg3: #1a1e28;
    --surface: #1e2332;
    --border: #2a2f42;
    --border-light: #333a52;
    --accent: #6c63ff;
    --accent2: #00d4aa;
    --accent3: #ff6584;
    --text: #e8eaf2;
    --text-muted: #7a82a0;
    --text-dim: #4a5070;
    --font-head: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
    --transition: 0.2s ease;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent2); }

/* ===== AUTH PAGES ===== */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108,99,255,0.15), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(0,212,170,0.08), transparent);
    padding: 2rem;
}

.auth-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    font-family: var(--font-head);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-logo span { color: var(--accent); }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 2rem; }
.auth-title { font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; margin-bottom: 1.5rem; }

/* ===== LAYOUT ===== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 1.5rem 1.5rem 1rem;
    font-family: var(--font-head);
    font-size: 1.4rem;
    font-weight: 800;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-logo .dot { color: var(--accent); }

.sidebar-user {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; color: white;
    flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.75rem; color: var(--accent2); font-weight: 500; }

.sidebar-nav { padding: 1rem 0; flex: 1; overflow-y: auto; }
.nav-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    padding: 0.75rem 1.5rem 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-link:hover { color: var(--text); background: var(--bg3); }
.nav-link.active { color: var(--accent); background: rgba(108,99,255,0.1); }
.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.main-content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-family: var(--font-head);
    font-size: 1.2rem;
    font-weight: 700;
}

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.page-content { padding: 2rem; flex: 1; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.25rem; }

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color var(--transition);
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.12);
}

select option { background: var(--bg3); }
textarea { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #5a54e0; color: white; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(108,99,255,0.35); }
.btn-success { background: var(--accent2); color: #0d0f14; }
.btn-success:hover { background: #00bfa0; color: #0d0f14; }
.btn-danger { background: rgba(255,101,132,0.15); color: var(--accent3); border: 1px solid rgba(255,101,132,0.3); }
.btn-danger:hover { background: var(--accent3); color: white; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); border-color: var(--border-light); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn svg { width: 16px; height: 16px; }

/* ===== CARDS ===== */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

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

.card-title {
    font-family: var(--font-head);
    font-size: 1rem;
    font-weight: 700;
}

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    border-radius: 50%;
    opacity: 0.07;
    transform: translate(30%, -30%);
}

.stat-card.purple::after { background: var(--accent); }
.stat-card.teal::after   { background: var(--accent2); }
.stat-card.red::after    { background: var(--accent3); }
.stat-card.orange::after { background: #ffab40; }

.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-family: var(--font-head); font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-card.purple .stat-value { color: var(--accent); }
.stat-card.teal .stat-value   { color: var(--accent2); }
.stat-card.red .stat-value    { color: var(--accent3); }
.stat-card.orange .stat-value { color: #ffab40; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

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

thead tr { border-bottom: 1px solid var(--border); }
thead th {
    padding: 0.85rem 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    text-align: left;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:hover { background: var(--bg3); }
tbody tr:last-child { border-bottom: none; }

tbody td {
    padding: 0.9rem 1rem;
    font-size: 0.88rem;
    vertical-align: middle;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-draft    { background: rgba(122,130,160,0.15); color: var(--text-muted); }
.badge-sent     { background: rgba(108,99,255,0.15);  color: var(--accent); }
.badge-paid     { background: rgba(0,212,170,0.15);   color: var(--accent2); }
.badge-cancelled{ background: rgba(255,101,132,0.15); color: var(--accent3); }
.badge-admin    { background: rgba(255,171,64,0.15);  color: #ffab40; }
.badge-sales    { background: rgba(108,99,255,0.15);  color: var(--accent); }

/* ===== ALERTS ===== */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success { background: rgba(0,212,170,0.1);  border: 1px solid rgba(0,212,170,0.25);  color: var(--accent2); }
.alert-error   { background: rgba(255,101,132,0.1);border: 1px solid rgba(255,101,132,0.25);color: var(--accent3); }
.alert-info    { background: rgba(108,99,255,0.1); border: 1px solid rgba(108,99,255,0.25); color: var(--accent); }

/* ===== INVOICE ITEMS ===== */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
    background: var(--bg3);
    padding: 0.6rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
}

.items-table td { padding: 0.5rem 0.4rem; vertical-align: middle; }
.items-table input { padding: 0.5rem 0.6rem; }

.btn-remove-item {
    background: none;
    border: none;
    color: var(--accent3);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 4px;
    transition: var(--transition);
}
.btn-remove-item:hover { background: rgba(255,101,132,0.1); }

/* ===== INVOICE SUMMARY ===== */
.invoice-summary {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.summary-row.total {
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.summary-row.total span:last-child { color: var(--accent2); }

/* ===== FILTERS ===== */
.filters {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.filters select,
.filters input {
    width: auto;
    min-width: 140px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

/* ===== FILE UPLOAD ===== */
.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(108,99,255,0.05);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.upload-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.upload-text { font-weight: 600; color: var(--text); margin-bottom: 0.25rem; }
.upload-hint { font-size: 0.8rem; color: var(--text-muted); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 1rem; right: 1rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.modal-close:hover { color: var(--text); }
.modal-title { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; margin-bottom: 1.5rem; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h3 { font-family: var(--font-head); margin-bottom: 0.5rem; color: var(--text); }
.empty-state p { font-size: 0.875rem; }

/* ===== TEMPLATE CARDS ===== */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }

.template-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    position: relative;
    transition: border-color var(--transition);
}

.template-card:hover { border-color: var(--border-light); }
.template-card .template-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.template-card .template-name { font-weight: 600; margin-bottom: 0.25rem; }
.template-card .template-meta { font-size: 0.8rem; color: var(--text-muted); }

/* ===== MISC ===== */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--accent2); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .page-content { padding: 1rem; }
}
