/* ============================================================
   Profit Tracker – Admin Dashboard CSS
   ============================================================ */

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

:root {
  --bg:         #0f172a;
  --bg2:        #1e293b;
  --bg3:        #334155;
  --surface:    #1e293b;
  --border:     #334155;
  --text:       #e2e8f0;
  --text2:      #94a3b8;
  --text3:      #64748b;
  --profit:     #22c55e;
  --expense:    #ef4444;
  --accent:     #3b82f6;
  --accent2:    #1d4ed8;
  --warn:       #f59e0b;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 4px 24px rgba(0,0,0,0.3);
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; line-height: 1.6; background: var(--bg); color: var(--text); }

/* ── Login ───────────────────────────────────────────────── */
.login-body   { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card   { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 380px; text-align: center; box-shadow: var(--shadow); }
.login-logo   { font-size: 48px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.login-sub    { color: var(--text2); margin-bottom: 28px; font-size: 13px; }

/* ── Layout ──────────────────────────────────────────────── */
body.login-body { display: flex; }
.sidebar { width: 220px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 0; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.logo-icon { font-size: 24px; }
.logo-text { font-size: 15px; font-weight: 600; }
.nav-links { list-style: none; padding: 12px 0; flex: 1; }
.nav-links li a { display: block; padding: 10px 20px; color: var(--text2); text-decoration: none; border-radius: 0; transition: all .15s; font-size: 13.5px; }
.nav-links li a:hover, .nav-links li a.active { background: var(--bg3); color: var(--text); }
.nav-links li a.active { border-left: 3px solid var(--accent); }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text2); }
.btn-logout { color: var(--expense); font-size: 12px; text-decoration: none; }
.btn-logout:hover { text-decoration: underline; }

.main-wrap { margin-left: 220px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 16px; font-weight: 600; }
.content { padding: 24px; flex: 1; }

/* ── Flash ───────────────────────────────────────────────── */
.flash { background: rgba(34,197,94,.15); border: 1px solid var(--profit); color: var(--profit); border-radius: var(--radius-sm); padding: 10px 16px; margin: 0 24px 0; font-size: 13px; }

/* ── Cards ───────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.max-w-lg { max-width: 680px; }
.mt-4 { margin-top: 20px; }

/* ── Stats ───────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
@media(max-width: 900px) { .stats-grid { grid-template-columns: repeat(2,1fr); } }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; position: relative; overflow: hidden; }
.stat-card::before { content:''; position: absolute; top:0; left:0; width:4px; height:100%; border-radius: var(--radius) 0 0 var(--radius); }
.stat-card.profit::before  { background: var(--profit); }
.stat-card.expense::before { background: var(--expense); }
.stat-card.net-positive::before { background: var(--accent); }
.stat-card.net-negative::before { background: var(--expense); }
.stat-card.neutral::before { background: var(--warn); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text2); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.stat-sub { font-size: 11px; color: var(--text3); }
.stat-sub a { color: var(--accent); text-decoration: none; }

/* ── Two-col layout ──────────────────────────────────────── */
.row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media(max-width: 800px) { .row-2col { grid-template-columns: 1fr; } }

/* ── Table ───────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 12px; color: var(--text2); font-weight: 500; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,.02); }
.table a { color: var(--accent); text-decoration: none; }
.table a:hover { text-decoration: underline; }
.empty-row { text-align: center; color: var(--text3); padding: 32px !important; }
.empty-row a { color: var(--accent); text-decoration: none; }
td.highlight, th.highlight { font-weight: 600; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 500; }
.badge-profit        { background: rgba(34,197,94,.15); color: #4ade80; }
.badge-expense       { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-hosting       { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-vps_sale      { background: rgba(139,92,246,.15); color: #a78bfa; }
.badge-vps_license   { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-domain        { background: rgba(20,184,166,.15); color: #2dd4bf; }
.badge-other         { background: rgba(100,116,139,.15); color: #94a3b8; }

/* ── Text colours ────────────────────────────────────────── */
.text-profit  { color: var(--profit); }
.text-expense { color: var(--expense); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg3); color: var(--text); font-size: 13px; text-decoration: none; cursor: pointer; transition: background .15s; }
.btn:hover { background: var(--border); }
.btn-primary { background: var(--accent); border-color: var(--accent2); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-danger  { background: rgba(239,68,68,.2); border-color: var(--expense); color: var(--expense); }
.btn-danger:hover { background: rgba(239,68,68,.35); }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-xs  { padding: 3px 8px; font-size: 11px; }
.btn-full { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 8px; margin-top: 16px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13px; outline: none; transition: border .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check label { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text); cursor: pointer; }
.form-check input[type=checkbox] { width: auto; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: rgba(239,68,68,.15); border: 1px solid var(--expense); color: #f87171; }

/* ── Toolbar / filter ────────────────────────────────────── */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.filter-form { display: flex; gap: 10px; }
.filter-form select { width: auto; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: center; }
.page-btn { display: inline-block; padding: 4px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg); color: var(--text); text-decoration: none; font-size: 12px; }
.page-btn.active { background: var(--accent); border-color: var(--accent); }

/* ── Invoice detail ──────────────────────────────────────── */
.invoice-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.invoice-meta .label { color: var(--text2); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; margin-right: 6px; }
.invoice-amounts { background: var(--bg); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px; }
.row-spread { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; color: var(--text2); }
.row-spread.total { font-size: 16px; font-weight: 700; color: var(--text); border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px; }
.notes { color: var(--text2); font-size: 13px; font-style: italic; }

/* ── Code blocks ─────────────────────────────────────────── */
.code-block { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; font-family: monospace; font-size: 12px; color: #7dd3fc; overflow-x: auto; margin: 10px 0; }
code { background: var(--bg); padding: 1px 6px; border-radius: 4px; font-family: monospace; font-size: 12px; color: #7dd3fc; }

/* ── Hints ───────────────────────────────────────────────── */
.hint { color: var(--text3); font-size: 12px; }
.mt-2 { margin-top: 8px; }

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