/* =====================================================================
   ATTI — Admin Theme (v5)
   Purple #7C3AED → Indigo #4338CA, Navy #1B2A56, light grey canvas.
   Dashboard = header + 4 KPI cards + ONE row of 3 equal columns.
   ===================================================================== */

:root {
    --purple-1: #7C3AED;
    --purple-2: #4338CA;
    --navy:     #1B2A56;
    --navy-2:   #1A204A;
    --border:   #E5E7EB;
    --bg:       #F4F5F7;
    --text:     #1F2937;
    --muted:    #6B7280;
    --green:    #059669;
    --red:      #DC2626;
    --radius:   12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow-md: 0 4px 14px rgba(0,0,0,.08);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
body {
    background: var(--bg);
    font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    margin: 0; font-size: 14px; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--navy); margin: 0 0 12px; letter-spacing: -.01em; }
a { text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--purple-1); }
.text-danger { color: var(--red) !important; }
.text-success { color: var(--green) !important; }

/* ---------- Layout ---------- */
.main-content {
    margin-left: 260px;
    padding: 28px 36px 56px;
    min-height: 100vh;
    overflow-x: hidden;
    transition: margin-left .3s ease;
}

/* ---------- Page header ---------- */
.main-content .page-header {
    display: flex; flex-direction: row;
    justify-content: space-between; align-items: center;
    gap: 16px; flex-wrap: wrap;
    margin: 0 0 24px; padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.main-content .page-title {
    margin: 0 0 4px; font-size: 28px; font-weight: 700;
    line-height: 1.15; letter-spacing: -.02em; color: var(--navy);
}
.main-content .page-subtitle { margin: 0; font-size: 14px; color: var(--muted); }
.main-content .date-chip {
    display: inline-flex; align-items: center;
    padding: 8px 16px; background: #fff;
    border: 1px solid var(--border); border-radius: 999px;
    font-size: 13px; font-weight: 500; color: var(--navy);
    white-space: nowrap; box-shadow: var(--shadow-sm);
}

/* ---------- KPI row: 4 separate cards ---------- */
.main-content .kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px; margin: 0 0 24px;
    background: none; border: none; box-shadow: none; overflow: visible;
}
.main-content .kpi {
    position: relative;
    display: flex; flex-direction: column; justify-content: space-between;
    min-width: 0; min-height: 124px; padding: 20px 22px;
    background: #fff; border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow .2s ease, transform .2s ease;
}
.main-content .kpi:hover { box-shadow: 0 8px 20px rgba(27,42,86,.10); transform: translateY(-2px); }

.main-content .kpi-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 600; color: var(--muted);
}
.main-content .kpi-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
    box-shadow: 0 0 0 4px rgba(124,58,237,.10);
}
.main-content .kpi-value {
    margin: 10px 0 4px; font-size: 30px; font-weight: 700;
    line-height: 1.1; letter-spacing: -.03em; color: var(--navy);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.main-content .kpi-foot { font-size: 12px; color: #9CA3AF; }

/* Featured KPI (Paid revenue) */
.main-content .kpi.kpi-featured {
    background: linear-gradient(135deg, var(--purple-1) 0%, var(--purple-2) 100%);
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(124,58,237,.30);
}
.main-content .kpi-featured::after {
    content: ""; position: absolute; right: -30px; top: -30px;
    width: 120px; height: 120px; border-radius: 50%;
    background: rgba(255,255,255,.10); pointer-events: none;
}
.main-content .kpi-featured .kpi-label,
.main-content .kpi-featured .kpi-foot { color: rgba(255,255,255,.85); }
.main-content .kpi-featured .kpi-value { color: #fff; }

/* ---------- THE 3-COLUMN ROW ---------- */
.dash-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));  /* minmax(0) stops chart blow-out */
    gap: 20px;
    align-items: stretch;
}
.col-card {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}
.col-head { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.col-head h3 { margin: 0; font-size: 15px; }
.col-head .meta { font-size: 12px; color: var(--muted); }

.col-visual { padding: 0 20px 16px; }
.chart-wrap { position: relative; width: 100%; height: 190px; min-width: 0; }
.chart-wrap canvas { display: block; max-width: 100% !important; }

/* Summary row under a chart */
.split-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 20px 16px; }
.split-summary div { padding-left: 10px; border-left: 3px solid var(--border); }
.split-summary .paid   { border-color: #10B981; }
.split-summary .unpaid { border-color: #EF4444; }
.split-summary small { display: block; font-size: 12px; color: var(--muted); }
.split-summary strong { font-size: 14px; color: var(--navy); }

/* Month vs month delta */
.delta-row { padding: 0 20px 6px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.delta-value { font-size: 24px; font-weight: 700; color: var(--navy); letter-spacing: -.02em; }
.delta-chip { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.delta-chip.up   { background: #ECFDF5; color: var(--green); }
.delta-chip.down { background: #FEF2F2; color: var(--red); }
.delta-chip.flat { background: #F3F4F6; color: var(--muted); }
.delta-note { font-size: 12px; color: var(--muted); }

/* "Recent" block pinned to the bottom of each column */
.col-recent { margin-top: auto; border-top: 1px solid var(--border); }
.recent-title { padding: 12px 20px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }

/* ---------- Compact data table ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; background: transparent; border-radius: 0; box-shadow: none; table-layout: fixed; }
.data-table td {
    padding: 9px 20px; border: none; border-bottom: 1px solid #F1F3F5;
    color: var(--navy); vertical-align: middle;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #FAFAFC; }
.data-table td.num { text-align: right; font-weight: 600; width: 38%; }
.data-table td.muted { color: var(--muted); font-size: 12px; width: 28%; }

/* Customer rows with initials avatar */
.person { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid #F1F3F5; }
.person:last-child { border-bottom: none; }
.person:hover { background: #FAFAFC; }
.avatar-initials {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: #F3F0FF; color: var(--purple-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}
.person-info { min-width: 0; flex: 1; }
.person-info strong, .person-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-info strong { font-size: 13px; color: var(--navy); }
.person-info span { font-size: 12px; color: var(--muted); }
.person-date { font-size: 12px; color: var(--muted); white-space: nowrap; }

.empty-state { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--navy-2); color: #fff;
    height: 100vh; width: 260px; position: fixed; top: 0; left: 0;
    padding-top: 32px; box-shadow: 2px 0 20px rgba(26,32,74,.15);
    z-index: 1000; overflow-y: auto;
}
.sidebar .avatar {
    display: flex; flex-direction: column; align-items: center;
    margin-bottom: 28px; padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .avatar img {
    border-radius: 50%; width: 56px; height: 56px; margin-bottom: 10px;
    border: 2px solid rgba(124,58,237,.6); box-shadow: 0 0 0 3px rgba(124,58,237,.2);
}
.sidebar .avatar span { font-size: 14px; font-weight: 600; color: #fff; }
.sidebar a {
    color: rgba(255,255,255,.7); padding: 11px 22px; display: block;
    font-size: 14px; font-weight: 500; border-radius: 8px; margin: 2px 12px;
    transition: all .2s ease;
}
.sidebar a:hover, .sidebar a.active {
    background: linear-gradient(135deg, var(--purple-1), var(--purple-2));
    color: #fff; box-shadow: 0 4px 12px rgba(124,58,237,.35);
}
.sidebar .collapse { background: rgba(0,0,0,.2); border-radius: 8px; margin: 6px 12px; padding: 4px 0; }
.sidebar .collapse a { padding: 9px 20px; font-size: 13px; margin: 0 4px; color: rgba(255,255,255,.65); }
.sidebar .collapse a:hover { background: rgba(124,58,237,.25); color: #fff; }

/* ---------- Forms / Buttons (shared with other pages) ---------- */
input, select, textarea {
    width: 100%; padding: 10px 14px; margin: 8px 0;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; background: #fff;
    transition: border-color .2s ease, box-shadow .2s ease;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--purple-1); box-shadow: 0 0 0 3px rgba(124,58,237,.15); outline: none;
}
label { font-weight: 500; margin-bottom: 4px; display: block; color: var(--navy); font-size: 13px; }
button, .btn {
    background: linear-gradient(135deg, var(--purple-1), var(--purple-2));
    color: #fff; border: none; border-radius: var(--radius-sm);
    padding: 10px 18px; font-size: 14px; font-weight: 500; cursor: pointer;
    transition: all .2s ease; box-shadow: 0 4px 12px rgba(124,58,237,.25);
}
button:hover, .btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(124,58,237,.35); }

/* ---------- Generic tables (other pages) ---------- */
table {
    width: 100%; border-collapse: collapse; background: #fff;
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
table th, table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
table th { background: #FAFAFC; font-weight: 600; color: var(--navy); font-size: 12px; }
table tr:hover td { background: #FAFAFC; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #F1F1F1; border-radius: 8px; }
::-webkit-scrollbar-thumb { background: #C1C1C1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--purple-1); }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
    .main-content { padding: 24px; }
    .main-content .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
    .dash-columns { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .main-content { margin-left: 0; padding: 20px; }
}
@media (max-width: 560px) {
    .main-content .kpi-strip { grid-template-columns: 1fr; }
    .main-content .page-title { font-size: 24px; }
}