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

:root {
    --bg-primary: #fff;
    --bg-secondary: #fafafa;
    --bg-card: #fff;
    --bg-hover: #f5f5f5;
    --text-primary: #1a1a1a;
    --text-secondary: #888;
    --text-muted: #bbb;
    --border-primary: #e0e0e0;
    --border-secondary: #eee;
    --selection-bg: #1a1a1a;
    --selection-text: #fff;
    --btn-hover-bg: #1a1a1a;
    --btn-hover-text: #fff;
    --positive-color: #1a1a1a;
    --negative-color: #bbb;
    --stat-bg: var(--bg-card);
    --stat-border: var(--border-primary);
    --grid-gap-bg: var(--border-primary);
    --alert-bg: #fafafa;
    --empty-color: #bbb;
    --back-link-color: #bbb;
    --back-link-hover: #1a1a1a;
    --logo-dark: block;
    --logo-light: none;
    --select-arrow: "%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E";
}

[data-theme="dark"] {
    --bg-primary: #000;
    --bg-secondary: #0a0a0a;
    --bg-card: #0a0a0a;
    --bg-hover: #111;
    --text-primary: #fff;
    --text-secondary: #555;
    --text-muted: #444;
    --border-primary: #222;
    --border-secondary: #1a1a1a;
    --selection-bg: #fff;
    --selection-text: #000;
    --btn-hover-bg: #fff;
    --btn-hover-text: #000;
    --positive-color: #fff;
    --negative-color: #888;
    --stat-bg: #0a0a0a;
    --stat-border: #222;
    --grid-gap-bg: #222;
    --alert-bg: #111;
    --empty-color: #444;
    --back-link-color: #555;
    --back-link-hover: #fff;
    --logo-dark: none;
    --logo-light: block;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    transition: background .2s, color .2s;
}
::selection { background: var(--selection-bg); color: var(--selection-text); }
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* header */
.header { border-bottom: 1px solid var(--border-primary); padding: 16px 0; }
.header .container { display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-wrap: wrap; }
.header h1 { font-size: 15px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; flex-shrink: 0; }
.header h1 a { color: var(--text-primary); text-decoration: none; }
.nav { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.nav a { color: var(--text-secondary); text-decoration: none; font-size: 13px; font-weight: 500; letter-spacing: 0.3px; transition: color .15s; white-space: nowrap; }
.nav a:hover { color: var(--text-primary); }
.nav-item { position: relative; }
.nav-item > a { color: var(--text-secondary); text-decoration: none; font-size: 13px; font-weight: 500; letter-spacing: 0.3px; transition: color .15s; white-space: nowrap; cursor: pointer; }
.nav-item > a:hover { color: var(--text-primary); }
.nav-dropdown { display: none; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); background: var(--bg-card); border: 1px solid var(--border-primary); min-width: 160px; z-index: 100; padding: 4px 0; }
.nav-dropdown::before { content: ''; position: absolute; top: -8px; left: 0; right: 0; height: 8px; }
.nav-dropdown::after { content: ''; position: absolute; top: -6px; left: 50%; transform: translateX(-50%); border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 6px solid var(--border-primary); }
.nav-dropdown a { display: block; padding: 8px 16px; color: var(--text-secondary); text-decoration: none; font-size: 12px; white-space: nowrap; transition: all .15s; }
.nav-dropdown a:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item:hover .nav-dropdown { display: block; }
.header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-shrink: 0; }

/* theme toggle */
.theme-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.theme-toggle input { display: none; }
.theme-toggle .slider { width: 30px; height: 16px; background: var(--border-primary); border-radius: 8px; position: relative; transition: background .2s; }
.theme-toggle .slider::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: var(--text-primary); border-radius: 50%; transition: transform .2s; }
.theme-toggle input:checked + .slider { background: var(--border-primary); }
.theme-toggle input:checked + .slider::after { transform: translateX(14px); }
.theme-toggle .icon { font-size: 12px; line-height: 1; color: var(--text-secondary); }

.logo-dark { display: var(--logo-dark); }
.logo-light { display: var(--logo-light); }

/* cards */
.card { background: var(--bg-card); border: 1px solid var(--border-primary); padding: 24px; margin-bottom: 20px; }
.card-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-secondary); margin-bottom: 20px; }

/* stats grid */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--grid-gap-bg); }
.stat { background: var(--stat-bg); text-align: center; padding: 28px 20px; }
.stat-value { font-size: 28px; font-weight: 300; color: var(--text-primary); letter-spacing: -0.5px; }
.stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 8px; text-transform: uppercase; letter-spacing: 1px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border-secondary); }
th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); background: transparent; border-bottom: 1px solid var(--border-primary); }
td { color: var(--text-primary); }
tr:hover td { background: var(--bg-hover); }
tr.total-row:hover td { background: var(--bg-card); cursor: default; }
tr.total-row td { background: var(--bg-secondary); }

/* buttons */
.btn {
    display: inline-flex; align-items: center; padding: 8px 16px;
    text-decoration: none; font-size: 12px; font-weight: 500;
    border: 1px solid var(--border-primary); cursor: pointer; transition: all .15s;
    background: transparent; color: var(--text-primary); letter-spacing: 0.3px;
}
.btn:hover { background: var(--btn-hover-bg); color: var(--btn-hover-text); border-color: var(--btn-hover-bg); }
.btn-sm { padding: 5px 10px; font-size: 11px; }

/* forms */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px;
    background: var(--bg-secondary); border: 1px solid var(--border-primary); border-radius: 0;
    font-size: 14px; color: var(--text-primary); outline: none; transition: border .15s;
    -webkit-appearance: none;
}
.form-control:focus { border-color: var(--text-primary); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
[data-theme="dark"] select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23555' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); }

/* text helpers */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.positive { color: var(--positive-color); font-weight: 500; }
.negative { color: var(--negative-color); font-weight: 500; text-decoration: line-through; }

/* alerts */
.alert { padding: 12px 16px; margin-bottom: 18px; font-size: 13px; border: 1px solid; }
.alert-success { background: var(--alert-bg); color: var(--text-primary); border-color: var(--border-primary); }
.alert-danger { background: var(--alert-bg); color: var(--text-primary); border-color: var(--border-primary); }

/* empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--empty-color); font-size: 13px; }
.empty a { color: var(--text-primary); text-decoration: underline; }

/* back link */
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 20px; color: var(--back-link-color); text-decoration: none; font-size: 12px; transition: color .15s; }
.back-link:hover { color: var(--back-link-hover); }

/* page headings */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-head h2 { font-size: 24px; font-weight: 300; letter-spacing: -0.3px; }

/* footer */
.footer-site { border-top: 1px solid var(--border-primary); margin-top: 48px; padding: 20px 0; }
.footer-site .container { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-col { font-size: 11px; color: var(--text-secondary); }
.footer-col strong { color: var(--text-primary); }
