/* Bokföring - Clean accounting UI */

:root {
    --bg: #fafafa;
    --surface: #fff;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-muted: #718096;
    --primary: #2b6cb0;
    --primary-hover: #2c5282;
    --success: #276749;
    --success-bg: #f0fff4;
    --warning: #975a16;
    --warning-bg: #fffff0;
    --danger: #c53030;
    --danger-bg: #fff5f5;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    font-size: 14px;
}

/* Navigation */
.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 3rem;
    gap: 2rem;
}

.nav-brand a {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    text-decoration: none;
}

.nav-links { display: flex; gap: 0.25rem; }

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--bg); color: var(--text); }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.25rem; font-weight: 600; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.card-body { padding: 1rem; }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

thead th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover { background: #f7fafc; }
tbody tr:last-child td { border-bottom: none; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-mono { font-family: "SF Mono", SFMono-Regular, Consolas, monospace; font-size: 0.8125rem; }

/* Amounts */
.amount { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.amount-debit { color: var(--text); }
.amount-credit { color: var(--text); }

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-draft { background: var(--warning-bg); color: var(--warning); }
.badge-posted { background: var(--success-bg); color: var(--success); }
.badge-cancelled { background: var(--danger-bg); color: var(--danger); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.5;
}

.btn:hover { background: var(--bg); border-color: #cbd5e0; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { padding: 0.25rem 0.625rem; font-size: 0.75rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.1);
}

select.form-control { appearance: auto; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.form-inline { display: flex; gap: 0.5rem; align-items: end; }

/* Stats grid */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}

/* Account class groups */
.account-group { margin-bottom: 1.5rem; }
.account-group-header {
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 0;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 0.5rem;
    color: var(--primary);
}

/* Voucher legs table */
.legs-table td:nth-child(3),
.legs-table td:nth-child(4),
.legs-table th:nth-child(3),
.legs-table th:nth-child(4) { text-align: right; }

.legs-total {
    font-weight: 700;
    border-top: 2px solid var(--border);
}

/* Detail grid */
.detail-grid {
    display: grid;
    grid-template-columns: 10rem 1fr;
    gap: 0.375rem 1rem;
    font-size: 0.8125rem;
}

.detail-label { font-weight: 500; color: var(--text-muted); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state p { margin-bottom: 1rem; }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.8125rem;
}

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #c6f6d5; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fed7d7; }

/* HTMX loading indicator */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* Spacing helpers */
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
