/* Musa frontend — visual identity shared with Awaker */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin: 20px auto;
}

h1 {
    color: #333;
    margin-bottom: 20px;
    border-bottom: 2px solid #007cba;
    padding-bottom: 10px;
}

h2 {
    color: #495057;
    font-size: 18px;
    margin: 24px 0 10px;
}

h3.ccy {
    color: #007cba;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
    margin: 14px 0 6px;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #007cba;
}

.error {
    color: #d32f2f;
    background-color: #ffebee;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid #d32f2f;
}

button {
    background-color: #007cba;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

button:hover { background-color: #005a87; }
button:disabled { background-color: #ccc; cursor: not-allowed; }

/* Login page */
.index-container {
    max-width: 400px;
    text-align: center;
    margin-top: 12vh;
}

.index-container input[type="password"] {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 16px;
}

.index-container button { width: 100%; }

/* Top bar */
.topbar {
    background-color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
}

.topbar-brand {
    font-size: 20px;
    font-weight: bold;
    color: #007cba;
    white-space: nowrap;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.logout-btn {
    background-color: #6c757d;
    padding: 8px 14px;
    font-size: 14px;
}
.logout-btn:hover { background-color: #565e64; }

.refresh-btn { padding: 8px 14px; font-size: 14px; }

.add-btn {
    padding: 8px 14px;
    font-size: 14px;
    background-color: #198754;
}
.add-btn:hover { background-color: #157347; }

/* Add-transaction modal */
#modalRoot { position: fixed; inset: 0; z-index: 1000; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}
.modal {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 640px;
    padding: 20px 24px 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.modal-wide { max-width: 860px; max-height: 88vh; overflow-y: auto; }
.detail-sub { margin: 18px 0 8px; font-size: 15px; color: #007cba; }
.asset-link { color: #007cba; text-decoration: none; cursor: pointer; }
.asset-link:hover { text-decoration: underline; }
.edit-price { text-decoration: none; cursor: pointer; font-size: 13px; opacity: 0.7; }
.edit-price:hover { opacity: 1; }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.modal-head h2 { margin: 0; font-size: 20px; color: #007cba; }
.modal-close {
    background: none;
    color: #6c757d;
    font-size: 26px;
    line-height: 1;
    padding: 0 6px;
}
.modal-close:hover { background: none; color: #212529; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.wide { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 600; color: #495057; }
.form-hint {
    font-size: 12px;
    color: #6c757d;
    line-height: 1.35;
    margin-top: 2px;
}
.form-field input,
.form-field select {
    padding: 7px 9px;
    font-size: 14px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}
.form-field input[readonly] {
    background-color: #e9ecef;
    color: #495057;
    cursor: not-allowed;
}
.form-field .chk {
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 0;
}
.form-field .chk input { width: auto; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}
.btn-primary { background-color: #198754; padding: 9px 18px; }
.btn-primary:hover { background-color: #157347; }
.btn-primary:disabled { background-color: #6c757d; cursor: default; }
.btn-secondary { background-color: #6c757d; padding: 9px 18px; }
.btn-secondary:hover { background-color: #565e64; }

.confirm-table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.confirm-table th,
.confirm-table td {
    text-align: left;
    padding: 6px 10px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}
.confirm-table th { width: 40%; color: #495057; font-weight: 600; }

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #212529;
    color: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 1100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 520px) {
    .form-grid { grid-template-columns: 1fr; }
}


/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tab {
    background: none;
    color: #495057;
    padding: 8px 14px;
    font-size: 14px;
    border-radius: 4px 4px 0 0;
    border: none;
    cursor: pointer;
}

.tab:hover { background-color: #eef4f8; }

.tab.active {
    background-color: #007cba;
    color: white;
}

.viewer-container {
    max-width: 1600px;
    padding-left: 16px;
    padding-right: 16px;
    overflow-x: auto;
}

/* Summary cards */
.cards {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 10px;
}

.card {
    flex: 1 1 180px;
    background-color: #f8f9fa;
    border-left: 4px solid #007cba;
    border-radius: 6px;
    padding: 14px 16px;
}

.card .card-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.card .card-value {
    font-size: 22px;
    font-weight: bold;
    margin-top: 4px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

th, td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #495057;
    font-size: 13px;
}

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

tr:hover { background-color: #f8f9fa; }

.timestamp { font-size: 12px; color: #666; }

.pos { color: #2e7d32; font-weight: bold; }
.neg { color: #d32f2f; font-weight: bold; }

.badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    background-color: #e9ecef;
    color: #495057;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

/* Year multi-select filter */
.year-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    margin: 12px 0 4px;
}

.year-filter .filter-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-right: 4px;
}

.year-filter label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    user-select: none;
}

.year-filter select[multiple] {
    font-size: 14px;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-width: 90px;
    color: #495057;
}

.year-filter .filter-hint {
    font-size: 12px;
    color: #999;
    font-style: italic;
}

/* PowerBI-style checkbox dropdown */
.pbi-dropdown {
    position: relative;
    display: inline-block;
}

.pbi-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 160px;
    padding: 6px 10px;
    font-size: 14px;
    color: #495057;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.pbi-toggle:hover { border-color: #007cba; }
.pbi-toggle.open { border-color: #007cba; box-shadow: 0 0 0 2px rgba(0,124,186,0.15); }

.pbi-toggle .pbi-summary {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pbi-toggle .pbi-caret { font-size: 10px; color: #888; }

.pbi-panel {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    z-index: 20;
    min-width: 100%;
    max-height: 240px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 4px 0;
}

.pbi-panel .pbi-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.pbi-item:hover { background-color: #eaf4fb; }

.pbi-item input[type="checkbox"] { cursor: pointer; }

.pbi-item.pbi-all {
    font-weight: bold;
    border-bottom: 1px solid #eee;
}

.year-filter .filter-actions {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

.year-filter .filter-actions a {
    font-size: 12px;
    color: #007cba;
    cursor: pointer;
    text-decoration: underline;
}

tr.total-row td {
    font-weight: bold;
    border-top: 2px solid #007cba;
    background-color: #f8f9fa;
}

tr.group-row {
    cursor: pointer;
    background-color: #eef4f8;
}
tr.group-row:hover { background-color: #e1edf5; }
tr.group-row td { font-weight: bold; }

.tree-toggle {
    display: inline-block;
    width: 16px;
    color: #007cba;
    font-size: 11px;
    user-select: none;
}

.muted { color: #888; font-weight: normal; }

tr.group-detail td:first-child { padding-left: 28px; }

td.tax-exempt {
    background-color: #d4edda;
    box-shadow: inset 3px 0 0 #28a745;
}
