/* LM design system - adapted from LM_CapacityManagement.
   Brand navy #013469, accent indigo #667eea / purple #764ba2. */

html, body {
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #667eea;
}

.btn-primary {
    color: #fff;
    background-color: #667eea;
    border-color: #5a6fd6;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #5a6fd6;
    border-color: #4e5fc2;
}

/* ── Sign-in "dialog" card ── */
.login-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.5rem 1rem 3rem;
}

/* 68px, not LM_Board's 52: this app uses the roundel rather than the bare white mark (see
   AuthCard.razor), and a circle needs a little more height than a wordmark to carry the same
   visual weight above a 430px card. */
.login-logo {
    height: 68px;
    width: auto;
    margin-bottom: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(1, 52, 105, 0.14);
    padding: 2.5rem 2.25rem;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #013469;
    text-align: center;
    margin-bottom: 0.35rem;
}

.login-title.danger {
    color: #c0392b;
}

.login-subtitle {
    text-align: center;
    color: #6b7280;
    margin-bottom: 1.75rem;
}

/* Full-width navy primary action, matching the brand top bar. */
.btn-login {
    width: 100%;
    background: #013469;
    border: 1px solid #013469;
    color: #fff;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    transition: background 0.15s ease, color 0.15s ease;
}

.btn-login:hover,
.btn-login:focus {
    background: #012a55;
    border-color: #012a55;
    color: #fff;
}

/* Secondary sign-in option (passkey): outlined so it reads below the primary button. */
.btn-login-outline {
    width: 100%;
    background: #fff;
    border: 1px solid #013469;
    color: #013469;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    transition: background 0.15s ease, color 0.15s ease;
}

.btn-login-outline:hover,
.btn-login-outline:focus {
    background: #f0f4fa;
    color: #013469;
}

.login-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #9ca3af;
    font-size: 0.85rem;
    margin: 1.25rem 0;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid #e5e7eb;
}

.login-divider::before { margin-right: 0.75rem; }
.login-divider::after { margin-left: 0.75rem; }

.login-links {
    text-align: center;
}

.login-links a {
    font-weight: 600;
    text-decoration: none;
}

.login-links a:hover {
    text-decoration: underline;
}

.login-note {
    text-align: center;
    color: #9ca3af;
    font-size: 0.82rem;
    margin-top: 1.5rem;
    margin-bottom: 0;
}

@media (max-width: 480px) {
    .login-card {
        padding: 2rem 1.5rem;
    }
}

/* ── Two-row navbar ── */
.navbar-wrapper {
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.navbar-top {
    background: #013469;
    padding: 0.5rem 1rem;
}

.navbar-top .navbar-brand {
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.navbar-top .navbar-logo {
    height: 40px;
    width: auto;
    margin-right: 12px;
}

.navbar-top .brand-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
}

.user-section {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    color: #fff;
}

.user-info .user-name {
    font-weight: 500;
}

.user-info i.fa-user-circle {
    font-size: 1.25rem;
}

/* Menu bar */
.navbar-menu {
    background: #013469;
    padding: 0;
    min-height: auto;
    box-shadow: none;
}

.navbar-menu .container-fluid {
    padding: 0;
    display: flex;
    align-items: stretch;
}

.navbar-menu .navbar-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    margin: 0;
    padding: 0;
    list-style: none;
}

.navbar-menu .nav-item {
    display: flex;
    align-items: stretch;
    margin: 0;
    padding: 0;
}

.navbar-menu .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    line-height: 1.5;
}

.navbar-menu .nav-link:hover {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.15);
}

.navbar-menu .nav-link.active {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.2);
}

/* ── Cards ── */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    background-color: #fff;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #eee;
    padding: 1rem 1.25rem;
    font-weight: 600;
    border-radius: 12px 12px 0 0 !important;
}

.card-body {
    padding: 1.25rem;
}

/* ── Forms & tables ── */
.form-control:focus,
.form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.table {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}

.page-header {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

/* ── Register statement: pinned toolbar and totals ──
   A statement runs to dozens of rows. Two things must never scroll away: the actions (hunting for
   "Add entry" at the bottom of a long list is miserable) and the net position (a net-worth statement
   whose grand total is off-screen has buried its own answer).

   <main> is the app's scroll container (MainLayout.razor.css), so top/bottom 0 resolve to its
   visible edges - no offset for the nav bar height, and nothing to re-tune if the nav ever changes.
   Both bars are opaque so rows pass cleanly behind them. */
/* Sits clear of the nav at rest and docks flush only once scrolled.
   Two earlier attempts were worse: a negative margin-top pulled it hard against the menu bar so it
   read as clipped, and a sticky `top` offset left a gap that rows scrolled through, which looked
   like a rendering fault. Letting .content's own padding do the spacing needs neither - and with no
   negative margin there is no way for the card to end up underlapping the nav. */
.register-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0.8rem 1.1rem;
    margin-bottom: 1rem;
}

/* .page-title is otherwise a bare h1 at Bootstrap's 2.5rem, which is most of why this header was
   so tall. The period label does not need to be the loudest thing on the page. */
.register-toolbar .page-title {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.3;
}

.register-totals {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin-bottom: 0;
    /* Upward shadow: signals that rows continue underneath rather than the list having ended. */
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.10);
}

@media (max-width: 767.98px) {
    .register-toolbar {
        padding: 0.55rem 0.85rem;
    }

    .register-toolbar .page-title {
        font-size: 1.05rem;
    }
}

/* ── Dashboard: KPI stat cards ── */
.stat-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    padding: 1.15rem 1.35rem;
    display: flex;
    /* Top-align the text: cards with a sub-line are taller, and centring would push the labels of
       the shorter cards down so they no longer line up across the row. */
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    height: 100%;
}

.stat-label {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.72rem;
    font-weight: 600;
    color: #8a94a6;
    margin-bottom: 0.15rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.05;
    color: #1a2230;
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    font-size: 0.76rem;
    color: #8a94a6;
    margin-top: 0.2rem;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.3rem;
    flex-shrink: 0;
    align-self: center; /* icon stays vertically centred even though the text is top-aligned */
}

.stat-icon-navy { background: linear-gradient(135deg, #013469, #1e5aa8); }
.stat-icon-purple { background: linear-gradient(135deg, #667eea, #764ba2); }
.stat-icon-green { background: linear-gradient(135deg, #11998e, #38ef7d); }
.stat-icon-pink { background: linear-gradient(135deg, #f093fb, #f5576c); }
.stat-icon-blue { background: linear-gradient(135deg, #4facfe, #00c6fb); }
.stat-icon-red { background: linear-gradient(135deg, #ff6a6a, #ee0979); }
.stat-icon-amber { background: linear-gradient(135deg, #f7971e, #ffd200); }

/* Count pill used in dashboard summary tables */
.count-pill {
    display: inline-block;
    min-width: 34px;
    text-align: center;
    background: #013469;
    color: #fff;
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── Subtle badges ──
   Bootstrap 5.3 added the bg-*-subtle / text-*-emphasis utilities; this app self-hosts 5.1, where
   they don't exist. Without them a `badge bg-primary-subtle text-primary-emphasis` renders as
   .badge's white text on a transparent background - invisible except when the row highlights on
   hover. Values are Bootstrap 5.3's own light-theme subtle/emphasis pairs. */
.bg-primary-subtle { background-color: #cfe2ff !important; }
.bg-secondary-subtle { background-color: #e2e3e5 !important; }
.bg-success-subtle { background-color: #d1e7dd !important; }
.bg-info-subtle { background-color: #cff4fc !important; }
.bg-warning-subtle { background-color: #fff3cd !important; }
.bg-danger-subtle { background-color: #f8d7da !important; }

.text-primary-emphasis { color: #052c65 !important; }
.text-secondary-emphasis { color: #2b2f32 !important; }
.text-success-emphasis { color: #0a3622 !important; }
.text-info-emphasis { color: #055160 !important; }
.text-warning-emphasis { color: #664d03 !important; }
.text-danger-emphasis { color: #58151c !important; }

/* ── Toasts (self-dismissing "it worked" feedback) ── */
.toast-host {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none; /* let clicks through the empty container */
}

.toast-item {
    pointer-events: auto;
    display: flex;
    align-items: center;
    min-width: 260px;
    max-width: 380px;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    color: #fff;
    font-size: 0.92rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    animation: toast-in 0.22s ease-out;
}

.toast-success { background: #1e7e4f; }
.toast-danger { background: #c0392b; }
.toast-warning { background: #9a6700; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .toast-item {
        animation: none;
    }
}

@media (max-width: 575.98px) {
    .toast-host {
        left: 1rem;
        right: 1rem;
    }

    .toast-item {
        min-width: 0;
        max-width: none;
    }
}

/* ── Responsive / mobile ── */

/* Wrapped tables keep the rounded card look while scrolling horizontally on narrow screens. */
.table-responsive {
    border-radius: 12px;
}

/* Rating scale: comfortable finger targets, wrap cleanly instead of overflowing. */
.rating-options .btn {
    min-height: 44px;
}

/* Menu bar: on tablets/phones let items wrap to another line rather than run off-screen. */
@media (max-width: 991.98px) {
    .navbar-menu .navbar-nav {
        flex-wrap: wrap;
    }

    .navbar-menu .nav-link {
        padding: 0.55rem 0.85rem;
    }
}

/* Small screens: tidy the header rows, page titles and card padding. */
@media (max-width: 767.98px) {
    .page-header {
        padding: 1.1rem;
    }

    .page-header h1,
    h1 {
        font-size: 1.5rem;
    }

    /* Title-and-actions rows stack instead of squashing. */
    .page-header.d-flex,
    .page-header .d-flex {
        flex-wrap: wrap;
        gap: 0.6rem;
    }

    .card-header,
    .card-body {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Very small screens: keep the top brand bar uncramped. */
@media (max-width: 575.98px) {
    .navbar-top {
        padding: 0.5rem 0.75rem;
    }

    .navbar-top .brand-text {
        font-size: 1.05rem;
    }

    .user-info .user-name {
        display: none;
    }
}

/* ── Statement table (RegisterStatement.razor) ── */
/* The classification rows were Bootstrap's .table-light: on a white card that is a band two shades
   off white, and it read as a slightly dirty entry row rather than a heading. A statement is read
   by scanning for its groups first, so the band is a navy tint with a rule above it, a navy
   accent at the left edge and the name in navy - the same family as the card header above it,
   one step quieter. */
.register-statement tr.register-class > td {
    background-color: #e6ecf5;
    color: #013469;
    font-weight: 600;
    border-top: 2px solid #b9c7dc;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.register-statement tr.register-class > td:first-child {
    box-shadow: inset 3px 0 0 #013469;
}

/* The same columns in the same places on every card. Each group is its own table, so without
   fixed widths "Legal owner" lands wherever that card's longest description pushes it, and the eye
   has to re-find the money columns on every group. Description takes whatever is left. */
.register-statement {
    table-layout: fixed;
    width: 100%;
}

.register-statement th.col-owner   { width: 20%; }
.register-statement th.col-money   { width: 12%; }
.register-statement th.col-alloc   { width: 6%; }
.register-statement th.col-actions { width: 6.5rem; }

.register-statement td {
    overflow-wrap: break-word;
}

/* The percentage box beside each owner of a jointly owned entry (doc §2.26). An input-group is
   100% wide by default; this one is a fixed slot so the owner dropdown gets the rest of the row and
   the shares line up one under another. Wide enough for "33.3334". */
.owner-share {
    flex: 0 0 8.5rem;
    width: 8.5rem;
}

/* ── Loan security (doc §2.27) ── */
/* The badge on an asset line naming the loan it secures. A loan's description can be long, and a
   badge does not wrap, so it is capped and ellipsised rather than pushing the row wide - the full
   name is in its tooltip. */
.badge-security {
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

/* The "which assets secure this loan" list in the entry dialog. Capped and scrolling: a register
   can hold fifty assets and the dialog is already long. */
.security-picker {
    max-height: 15rem;
    overflow-y: auto;
}

.security-picker-group {
    position: sticky;
    top: 0;
    padding: 0.25rem 0.75rem;
    background-color: #f6f8fc;
    border-bottom: 1px solid #e6eaf0;
    color: #6b7686;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* A whole row is the label, so anywhere on it ticks the box. */
.security-picker-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    padding: 0.35rem 0.75rem;
    border-bottom: 1px solid #f0f2f6;
    cursor: pointer;
}

.security-picker-row:hover {
    background-color: #f6f8fc;
}

/* Entry rows light up under the pointer, so a wide row can be followed across to its figures.
   Band rows do not: they are not something you act on. */
.register-statement tbody tr:not(.register-class):hover > td {
    background-color: #f6f8fc;
}

@media (max-width: 991.98px) {
    /* Narrow screens size by content again - a fixed 12% money column is too thin to hold a figure. */
    .register-statement {
        table-layout: auto;
    }
}
