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

:root {
    --ink:        #14131a;
    --panel:      #1c1b24;
    --panel-2:    #232230;
    --border:     rgba(255,255,255,0.09);
    --border-2:   rgba(255,255,255,0.14);
    --text:       #ece8e0;
    --text-muted: #9a96a6;
    --brass:      #c3924f;
    --brass-soft: rgba(195,146,79,0.14);
    --ok:         #5fa776;
    --ok-soft:    rgba(95,167,118,0.14);
    --warn:       #d9a441;
    --warn-soft:  rgba(217,164,65,0.14);
    --danger:     #c1554b;
    --danger-soft:rgba(193,85,75,0.14);
    --radius:     10px;
    --radius-sm:  6px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--ink);
    color: var(--text);
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    font-size: 15px;
    line-height: 1.7;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ===================== App Shell ===================== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 22px 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 22px 22px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 38px;
    height: 38px;
    border: 1.5px solid var(--brass);
    color: var(--brass);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}
.brand-mark.large { width: 58px; height: 58px; font-size: 26px; margin: 0 auto 14px; }

.brand-name { font-weight: 700; font-size: 15.5px; letter-spacing: 0.3px; }
.brand-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 12px;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    border-right: 2px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover { background: var(--panel-2); color: var(--text); }

.sidebar-nav a.active {
    background: var(--brass-soft);
    color: var(--brass);
    border-right-color: var(--brass);
}

.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-footer {
    padding: 14px 18px 0;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--panel-2);
    border: 1px solid var(--border-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--brass);
}

.user-name { font-size: 13.5px; font-weight: 600; }
.user-role { font-size: 11.5px; color: var(--text-muted); }

.logout-link {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    padding: 6px 2px;
}
.logout-link:hover { color: var(--danger); }

/* ===================== Main content ===================== */
.main-content {
    flex: 1;
    padding: 26px 34px 50px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 22px;
}

.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.topbar-date { font-size: 13px; color: var(--text-muted); }

.content-body { display: flex; flex-direction: column; gap: 20px; }

/* ===================== Stat cards ===================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
}

.stat-card.accent { border-color: rgba(195,146,79,0.35); }

.stat-label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-card.accent .stat-value { color: var(--brass); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===================== Panels ===================== */
.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 980px) { .panel-grid { grid-template-columns: 1fr; } }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px 20px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.panel-head h2 { font-size: 15.5px; font-weight: 700; margin: 0; }
.panel-link { font-size: 12.5px; color: var(--brass); }

.empty-note { color: var(--text-muted); font-size: 13.5px; padding: 10px 0; }

/* ===================== Tables ===================== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    text-align: right;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--border);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr[onclick] { cursor: pointer; }
.data-table tbody tr[onclick]:hover { background: var(--panel-2); }

.row-actions { display: flex; gap: 4px; }

.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); font-weight: 600; }
.text-warning { color: var(--warn); font-weight: 600; }
.text-accent { color: var(--brass); font-weight: 600; }
.small { font-size: 12px; }

/* ===================== Badges ===================== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warning { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--brass-soft); color: var(--brass); }

/* ===================== Buttons ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    background: transparent;
}
.btn-primary { background: var(--brass); color: #201708; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--panel-2); color: var(--text); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--border-2); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ===================== Toolbar / search ===================== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.search-form { display: flex; gap: 8px; align-items: center; }
.search-form input {
    background: var(--panel);
    border: 1px solid var(--border-2);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13.5px;
}

/* ===================== Forms ===================== */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
input, select {
    background: var(--ink);
    border: 1px solid var(--border-2);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--brass); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline-label { flex-direction: row; align-items: center; gap: 8px; }

/* ===================== Alerts ===================== */
.alert {
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    border: 1px solid transparent;
}
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: rgba(95,167,118,0.3); }
.alert-error   { background: var(--danger-soft); color: var(--danger); border-color: rgba(193,85,75,0.3); }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: rgba(217,164,65,0.3); }

/* ===================== Modal ===================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,9,13,0.65);
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}
.modal.open { display: flex; }
.modal-box {
    background: var(--panel);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    width: 100%;
    max-width: 440px;
    padding: 22px 24px 26px;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
}
.modal-form { display: flex; flex-direction: column; gap: 13px; }
.modal-note { font-size: 12px; color: var(--text-muted); margin: -4px 0 0; }

/* ===================== Auth pages ===================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--ink);
}
.auth-box {
    width: 100%;
    max-width: 380px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 34px 30px;
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.brand-title { font-size: 20px; font-weight: 700; margin: 0; }
.brand-subtitle { font-size: 13px; color: var(--text-muted); margin: 4px 0 0; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* ===================== Invoice new / bar chart ===================== */
.invoice-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.invoice-grand-total { font-size: 16px; font-weight: 700; color: var(--brass); }

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 160px;
    padding-top: 10px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar-fill { width: 100%; background: var(--brass); border-radius: 4px 4px 0 0; min-height: 4px; }
.bar-label { font-size: 10.5px; color: var(--text-muted); margin-top: 6px; }

/* ===================== Invoice sheet ===================== */
.invoice-header { display: flex; justify-content: space-between; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px dashed var(--border-2); }
.brand-name-lg { font-size: 19px; font-weight: 700; }
.invoice-meta { text-align: left; font-size: 13px; }
.invoice-meta div { margin-bottom: 3px; }
.invoice-items-table { margin-bottom: 18px; }
.invoice-summary { text-align: left; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.invoice-summary .grand { font-size: 16px; }
.invoice-footer { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.invoice-payments { margin-top: 16px; }
.invoice-payments h3 { font-size: 13.5px; margin: 0 0 8px; color: var(--text-muted); }

.status-select {
    background: var(--panel-2);
    border: 1px solid var(--border-2);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    font-size: 12.5px;
}
.status-select.status-cleared { color: var(--ok); }
.status-select.status-pending { color: var(--warn); }
.status-select.status-bounced { color: var(--danger); }
.inline-status-form { display: inline-block; }

@media print {
    .sidebar, .topbar, .no-print, .alert { display: none !important; }
    .main-content { padding: 0; }
    body, .invoice-sheet { background: #fff; color: #000; }
    .panel { border: none; padding: 0; }
}
