/* =============================================================================
   MRComputerPro Customer Portal — Theme
   Dark-first, mobile responsive, MSP/ISP look. CSS variables throughout.
   ============================================================================= */
:root {
    --bg:            #0b1220;
    --bg-elev:       #111a2e;
    --bg-elev-2:     #16223c;
    --surface:       #16223c;
    --surface-hover: #1d2c4d;
    --line:          #22304f;
    --line-soft:     #1a2742;
    --text:          #e7eefb;
    --text-muted:    #9fb0cf;
    --text-faint:    #6b7da3;
    --brand:         #2f6df6;
    --brand-2:       #4f8bff;
    --brand-grad:    linear-gradient(135deg, #2f6df6 0%, #6a5cff 100%);
    --ok:            #22c08a;
    --ok-bg:         rgba(34,192,138,.14);
    --info:          #38a9f5;
    --info-bg:       rgba(56,169,245,.14);
    --warn:          #f5a623;
    --warn-bg:       rgba(245,166,35,.14);
    --danger:        #f0506e;
    --danger-bg:     rgba(240,80,110,.14);
    --muted-bg:      rgba(159,176,207,.12);
    --radius:        14px;
    --radius-sm:     9px;
    --shadow:        0 10px 30px rgba(0,0,0,.35);
    --shadow-sm:     0 2px 8px rgba(0,0,0,.25);
    --sidebar-w:     256px;
    --font:          'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
small { color: var(--text-muted); }
hr { border: none; border-top: 1px solid var(--line); margin: 1.25rem 0; }
code { font-family: ui-monospace, Menlo, monospace; background: var(--bg-elev); padding: 1px 6px; border-radius: 5px; font-size: .85em; }

/* ---- Icons --------------------------------------------------------------- */
/* Base size for every inline icon(). More specific component rules
   (.nav-item .ico, .btn .ico, .stat .ico-wrap .ico) override this. */
.ico { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; display: inline-block; }
h1 .ico, h2 .ico, h3 .ico { vertical-align: -2px; }
.stat .ico-wrap .ico { width: 20px; height: 20px; vertical-align: 0; }
.card-head .ico { width: 18px; height: 18px; }

/* ---- Layout shell -------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-elev);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px; border-bottom: 1px solid var(--line); min-height: 64px;
}
.sidebar-brand .logo {
    width: 34px; height: 34px; border-radius: 9px; background: var(--brand-grad);
    display: grid; place-items: center; font-weight: 800; color: #fff; flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(47,109,246,.4);
}
.sidebar-brand .name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.sidebar-brand .name small { display: block; color: var(--text-faint); font-weight: 500; font-size: 11px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 12px 24px; }
.nav-group-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
    color: var(--text-faint); padding: 16px 10px 6px; font-weight: 700;
}
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px; border-radius: var(--radius-sm); color: var(--text-muted);
    font-weight: 500; margin-bottom: 2px; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 14px rgba(47,109,246,.35); }
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav-item .badge-mini { margin-left: auto; }

/* ---- Main column --------------------------------------------------------- */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 64px; display: flex; align-items: center; gap: 16px;
    padding: 0 24px; border-bottom: 1px solid var(--line);
    background: rgba(17,26,46,.85); backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 40;
}
.topbar .page-title { font-size: 16px; font-weight: 650; }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
    display: flex; align-items: center; gap: 9px; padding: 6px 10px;
    border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
}
.topbar .avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--brand-grad);
    display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
}
.hamburger { display: none; background: none; border: none; color: var(--text); cursor: pointer; padding: 6px; }
.content { padding: 24px; max-width: 1320px; width: 100%; }

/* ---- Cards / stats ------------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-head {
    display: flex; align-items: center; gap: 12px;
    padding: 15px 20px; border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.col-span-2 { grid-column: span 2; }

.stat {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; position: relative; overflow: hidden;
}
.stat .label { color: var(--text-muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.85rem; font-weight: 750; margin-top: 6px; letter-spacing: -.02em; }
.stat .sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.stat .ico-wrap {
    position: absolute; top: 16px; right: 16px; width: 40px; height: 40px;
    border-radius: 11px; display: grid; place-items: center; background: var(--brand-grad); color: #fff;
}
.stat.ok .ico-wrap { background: linear-gradient(135deg,#1aa777,#22c08a); }
.stat.warn .ico-wrap { background: linear-gradient(135deg,#d98a13,#f5a623); }
.stat.danger .ico-wrap { background: linear-gradient(135deg,#d63a58,#f0506e); }
.stat.info .ico-wrap { background: linear-gradient(135deg,#2487cf,#38a9f5); }

/* ---- Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
    text-align: left; padding: 11px 14px; color: var(--text-muted);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
    border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--bg-elev);
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: none; }
.table-empty { text-align: center; padding: 40px 20px; color: var(--text-faint); }

/* ---- Badges -------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
    line-height: 1.4; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.danger { color: var(--danger); background: var(--danger-bg); }
.badge.muted { color: var(--text-muted); background: var(--muted-bg); }
.badge.feature { color: var(--brand-2); background: rgba(79,139,255,.14); }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-family: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer;
    transition: transform .12s, box-shadow .15s, background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 14px rgba(47,109,246,.35); }
.btn-primary:hover { box-shadow: 0 6px 18px rgba(47,109,246,.5); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: linear-gradient(135deg,#d63a58,#f0506e); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Forms --------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-muted); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.input, .select, .textarea {
    width: 100%; padding: 10px 13px; background: var(--bg-elev); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
    transition: border-color .15s, box-shadow .15s; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,109,246,.22); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.textarea { min-height: 110px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%239fb0cf' stroke-width='2'><polyline points='6 8 10 12 14 8'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; background-size: 15px; padding-right: 36px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 180px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---- Flash / alerts ------------------------------------------------------ */
.flash-stack { position: fixed; top: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.alert {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 15px;
    border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-elev-2);
    box-shadow: var(--shadow); font-size: 13.5px; animation: slideIn .25s ease;
}
.alert.success { border-left: 3px solid var(--ok); }
.alert.error   { border-left: 3px solid var(--danger); }
.alert.info    { border-left: 3px solid var(--info); }
.alert.warning { border-left: 3px solid var(--warn); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.notice { padding: 12px 15px; border-radius: var(--radius-sm); background: var(--bg-elev); border: 1px solid var(--line); margin-bottom: 16px; }
.notice.warn { border-left: 3px solid var(--warn); }
.notice.info { border-left: 3px solid var(--info); }

/* ---- Page header --------------------------------------------------------- */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-muted); font-size: 13px; }
.page-head .spacer { flex: 1; }
.breadcrumb { color: var(--text-faint); font-size: 12.5px; margin-bottom: 4px; }
.breadcrumb a { color: var(--text-muted); }

/* ---- Auth / public pages ------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: radial-gradient(1200px 600px at 70% -10%, rgba(47,109,246,.18), transparent),
                radial-gradient(800px 500px at -10% 110%, rgba(106,92,255,.16), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; }
.auth-card .brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-card .brand .logo { width: 40px; height: 40px; border-radius: 11px; background: var(--brand-grad); display: grid; place-items: center; font-weight: 800; color: #fff; }
.auth-card h1 { font-size: 1.3rem; }
.auth-card .muted-link { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }

/* ---- Misc utilities ------------------------------------------------------ */
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.spacer { flex: 1; } .text-muted { color: var(--text-muted); } .text-faint { color: var(--text-faint); }
.text-right { text-align: right; } .text-center { text-align: center; } .mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.mono { font-family: ui-monospace, Menlo, monospace; }
.pill-code { font-family: ui-monospace, monospace; background: var(--bg-elev); border: 1px dashed var(--line); padding: 4px 10px; border-radius: 7px; letter-spacing: .05em; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--muted-bg); color: var(--text-muted); font-size: 11.5px; font-weight: 600; }
.coming-soon-banner { display:flex; align-items:center; gap:10px; padding:14px 18px; border-radius: var(--radius); background: var(--warn-bg); border: 1px solid rgba(245,166,35,.3); color: var(--warn); margin-bottom: 20px; font-weight: 600; }

/* ---- Topology (managed network placeholder) ------------------------------ */
.topology { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 18px; }
.topo-node { padding: 12px 16px; border-radius: 11px; background: var(--bg-elev); border: 1px solid var(--line); text-align: center; min-width: 120px; }
.topo-node .t { font-weight: 650; font-size: 13px; } .topo-node .s { font-size: 11px; color: var(--text-faint); }
.topo-arrow { color: var(--text-faint); }

/* ---- Mobile -------------------------------------------------------------- */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 45; }
@media (max-width: 980px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: 1fr; }
    .col-span-2 { grid-column: span 1; }
}
@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
    .sidebar-backdrop.show { display: block; }
    .main { margin-left: 0; }
    .hamburger { display: inline-flex; }
    .grid-2, .grid-4 { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .flash-stack { left: 12px; right: 12px; max-width: none; }
}

/* ===== Billing: invoices, receipts, print ===== */
.invoice-doc { background: var(--surface); }
.totals-table { border-collapse: collapse; }
.totals-table td { padding: 6px 10px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.totals-table tr:last-child td { border-bottom: none; }
.totals-table .text-right { text-align: right; }
.no-print { }

@media print {
    .sidebar, .topbar, .flash-stack, .no-print, .hamburger { display: none !important; }
    .app, .main, .content { display: block; margin: 0; padding: 0; background: #fff; }
    .invoice-doc, .card { box-shadow: none !important; border: none !important; }
    body { background: #fff; }
    a[href]:after { content: ""; }
}
