/* ============================================================
   Share / Money Management System — shared styles
   ============================================================ */
:root, :root[data-theme="dark"] {
    --bg:        #0f172a;
    --surface:   #1e293b;
    --surface-2: #273449;
    --border:    #334155;
    --text:      #e2e8f0;
    --muted:     #94a3b8;
    --primary:   #6366f1;
    --primary-2: #818cf8;
    --green:     #22c55e;
    --red:       #ef4444;
    --amber:     #f59e0b;
    --radius:    12px;
    --shadow:    0 8px 24px rgba(0, 0, 0, .25);
}

:root[data-theme="light"] {
    --bg:        #f1f5f9;
    --surface:   #ffffff;
    --surface-2: #f1f5f9;
    --border:    #e2e8f0;
    --text:      #0f172a;
    --muted:     #64748b;
    --primary:   #6366f1;
    --primary-2: #4f46e5;
    --green:     #16a34a;
    --red:       #dc2626;
    --amber:     #d97706;
    --radius:    12px;
    --shadow:    0 8px 24px rgba(15, 23, 42, .08);
}

html { background: var(--bg); }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar navigation ---------- */
.sidebar {
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.theme-toggle {
    margin-top: auto;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 500;
    font-size: 13.5px;
    padding: 11px 14px;
    text-align: left;
}
.theme-toggle:hover { filter: brightness(1.05); }
.brand {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.nav { margin-top: 28px; display: flex; flex-direction: column; gap: 4px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary); color: #fff; }
.nav a .ico { width: 18px; text-align: center; }

/* ---------- Main content ---------- */
.main { flex: 1; padding: 32px 40px; max-width: 1200px; }
.page-title { font-size: 26px; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 28px; font-size: 14px; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 18px; font-size: 17px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.field { margin-bottom: 16px; }
input, select, textarea {
    width: 100%;
    padding: 11px 13px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .25);
}
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

button {
    cursor: pointer;
    border: none;
    border-radius: 9px;
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    transition: filter .15s, opacity .15s;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
button.ghost { background: var(--surface-2); color: var(--text); }
button.danger { background: var(--red); }
button.success { background: var(--green); }
button.sm { padding: 7px 12px; font-size: 12.5px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); }

/* ---------- Utility ---------- */
.pos { color: var(--green); }
.neg { color: var(--red); }
.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.pill.applied { background: rgba(34, 197, 94, .15); color: var(--green); }
.pill.pending { background: rgba(245, 158, 11, .15); color: var(--amber); }
.empty { color: var(--muted); text-align: center; padding: 28px; font-size: 14px; }
.muted { color: var(--muted); }

/* ---------- Stat tiles (report + dashboard) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.stat .k { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Toast ---------- */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
}
.toast {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    padding: 13px 18px;
    border-radius: 9px;
    font-size: 14px;
    box-shadow: var(--shadow);
    animation: slidein .2s ease;
    max-width: 340px;
}
.toast.ok  { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* investor preview rows */
.preview-profit { color: var(--green); font-weight: 600; }
.preview-loss   { color: var(--red);   font-weight: 600; }
.split-row .del { flex: 0 0 auto; }

/* ---------- expandable transaction rows ---------- */
.txn-main { cursor: pointer; }
.txn-main:hover { background: var(--surface-2); }
.caret { display: inline-block; width: 14px; color: var(--primary-2); transition: transform .15s; }
.txn-detail > td { background: var(--bg); padding: 0; }
.detail-box { padding: 14px 18px 18px; }
.detail-table { width: 100%; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.detail-table th { background: var(--surface-2); }
.detail-table th, .detail-table td { padding: 9px 12px; }
.detail-table tbody tr:hover { background: var(--surface); }
.detail-table tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
