/* --------------------------------------------------------------------------
   LLM-Style Design System
   Palette: Primary (#0858C3), Background (#ffffff), Borders (#dde1ea), Neutral text (#111111)
   Typography: System fonts (-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)
   Weights: 400 (Body), 500 (Headings, Labels) only
   Line Heights: 1.3 (Headings), 1.6 (Body)
   -------------------------------------------------------------------------- */

:root {
    --bg-main: #ffffff;
    --bg-subtle: #f5f7fa;
    --bg-accent: #e8f0fc;
    --bg-hover: #f0f4fd;
    
    --text-main: #111111;
    --text-muted: #5a6072;
    --text-accent: #0858C3;
    
    --primary: #0858C3;
    --primary-hover: #0649a3;
    --error: #d93025;
    
    --border: #dde1ea;
    
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Pro Mono", Menlo, Monaco, Consolas, monospace;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    font-weight: 400;
    min-height: 100vh;
}

/* App Container - Two-column sidebar + main content wrapper */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: 240px;
    background-color: var(--bg-subtle);
    border-right: 1px solid var(--border);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand {
    display: flex;
    text-decoration: none;
    margin-bottom: 48px;
}

.brand-title {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-grow: 1;
}

.nav-item a {
    display: block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 120ms ease-in-out, color 120ms ease-in-out;
}

.nav-item a:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.nav-item.active a {
    background-color: var(--primary);
    color: var(--bg-main);
    font-weight: 500;
}

.sidebar-footer {
    padding-top: 24px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Content Area */
.main-content {
    margin-left: 240px;
    flex-grow: 1;
    padding: 48px;
    max-width: calc(100vw - 240px);
    display: flex;
    flex-direction: column;
    gap: 48px;
}

/* Header Wrapper */
.header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.header-title h1 {
    font-size: 22px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-main);
    margin-bottom: 8px;
}

.header-title p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
}

/* Buttons (Flat, rounded-8, focus outlines) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border-radius: 8px;
    border: none;
    outline: none;
    transition: background-color 120ms ease-in-out, border-color 120ms ease-in-out, color 120ms ease-in-out;
}

.btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--bg-main);
}

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

.btn-secondary {
    background-color: var(--bg-main);
    border: 1px solid var(--primary);
    color: var(--primary);
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

/* Stats Comparison Grid (Side-by-side) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.stat-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.stat-header {
    margin-bottom: 16px;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.stat-value {
    font-size: 22px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-main);
    margin-bottom: 8px;
}

.stat-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* Dashboard Vertical Stack (Decluttered single-column content) */
.dashboard-stack, .detail-stack {
    display: flex;
    flex-direction: column;
    gap: 48px;
}

.section-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-main);
}

.link-nav {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-accent);
    text-decoration: none;
}

.link-nav:hover {
    text-decoration: underline;
}

/* Financial Reserves Currency List */
.currency-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.currency-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}

.currency-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.currency-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.currency-badge {
    background-color: var(--bg-accent);
    color: var(--text-accent);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-mono);
}

.currency-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

.currency-count {
    font-size: 12px;
    color: var(--text-muted);
}

.currency-total {
    text-align: right;
}

.currency-amt {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 500;
    color: var(--text-accent);
}

/* Portfolio Distribution List */
.distribution-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dist-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dist-header {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.dist-label {
    font-weight: 500;
    color: var(--text-main);
}

.dist-val {
    color: var(--text-muted);
    font-size: 12px;
}

/* Progress bar container and fill */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--bg-subtle);
    border-radius: 8px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--primary);
    border-radius: 8px;
}

/* Tables (LLM style, grid aligned, subtle hover shift) */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.custom-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
    vertical-align: middle;
}

.custom-table tr:last-child td {
    border-bottom: none;
}

.custom-table tr:hover td {
    background-color: var(--bg-hover);
}

.code-number {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 400;
}

.owner-name {
    font-weight: 500;
}

.owner-email {
    font-size: 12px;
    color: var(--text-muted);
}

.balance-cell {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
}

.actions-header {
    text-align: right;
}

.actions-cell {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Badges / Tags (#e8f0fc bg, #0858C3 text, 4px radius) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    background-color: var(--bg-accent);
    color: var(--text-accent);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Django Message / Alerts */
.messages-container {
    margin-bottom: 24px;
}

.alert {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-subtle);
    color: var(--text-main);
}

.alert-success {
    background-color: var(--bg-accent);
    color: var(--text-accent);
}

.alert-error, .alert-danger {
    border-color: var(--error);
    color: var(--error);
    background-color: var(--bg-main);
}

.alert-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

/* Filters & Search Toolbar (Grouped with whitespace only) */
.toolbar-wrapper {
    margin-bottom: 48px;
}

.toolbar-form {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.search {
    flex-grow: 2;
    min-width: 250px;
}

.form-group label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

/* Form inputs (White bg, 1px border, 8px radius, focus outline 2px primary) */
.form-input, .form-select, .form-textarea {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
    outline: none;
    transition: border-color 120ms ease-in-out;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.toolbar-actions {
    display: flex;
    gap: 16px;
}

/* Empty State */
.empty-state {
    padding: 48px 24px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    text-align: left;
    background-color: var(--bg-subtle);
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
}

/* Detail view styles */
.detail-wrapper {
    display: flex;
    flex-direction: column;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.info-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.info-val {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-main);
}

.balance-large {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--primary);
}

.balance-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.notes-content {
    background-color: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
    min-height: 100px;
}

.notes-empty {
    color: var(--text-muted);
    font-style: italic;
}

.danger-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.danger-actions {
    display: flex;
}

/* Form Container & Form Cards */
.form-container {
    max-width: 800px;
}

.form-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.form-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Error helper state styling */
.form-errors {
    color: var(--error);
    font-size: 12px;
    margin-top: 8px;
}

.non-field-errors {
    border: 1px solid var(--error);
    border-radius: 8px;
    padding: 16px;
    background-color: var(--bg-main);
    color: var(--error);
    font-size: 14px;
}

.form-actions {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    padding-top: 24px;
    margin-top: 8px;
}

/* Confirm Deletion Page */
.confirm-wrapper {
    display: flex;
    justify-content: flex-start;
    padding-top: 24px;
}

.confirm-card {
    width: 100%;
    max-width: 600px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.confirm-title {
    font-size: 22px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-main);
}

.confirm-desc {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
}

.confirm-desc .highlight {
    color: var(--primary);
    font-weight: 500;
}

.confirm-ledger-box {
    background-color: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.ledger-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ledger-row:last-child {
    margin-bottom: 0;
}

.ledger-label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.ledger-val {
    font-size: 14px;
    color: var(--text-main);
}

.confirm-actions {
    display: flex;
    gap: 16px;
}

/* Responsive Collapse */
@media (max-width: 1024px) {
    .sidebar {
        width: 70px;
        padding: 32px 8px;
        align-items: center;
    }
    
    .brand-title, .nav-text, .sidebar-footer {
        display: none;
    }
    
    .main-content {
        margin-left: 70px;
        max-width: calc(100vw - 70px);
        padding: 24px;
        gap: 32px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .toolbar-form {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
}
