/* =====================================================================
   Kay Mortgage Portal – portal shell, home page, Mortgage Journal, Asset Management.
   Navy and white on light gray, with the logo's orange as a small accent.
   ===================================================================== */
:root { --bg: #f2f4f8; --navy-deep: #1b2150; }

/* ---------- header & portal navigation ---------- */
.topbar { border-bottom: 3px solid var(--navy); box-shadow: 0 1px 0 var(--accent); }
.brand-text { font-size: 16px; letter-spacing: .04em; text-transform: uppercase; }
.portal-nav { display: flex; align-items: stretch; height: 100%; margin-left: 8px; }
.portal-nav a { display: flex; align-items: center; padding: 0 14px; color: var(--text); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -3px; white-space: nowrap; }
.portal-nav a:hover { color: var(--navy); background: var(--navy-soft); text-decoration: none; }
.portal-nav a.active { color: var(--navy); border-bottom-color: var(--accent); }
.logout-btn { height: 32px; border-color: var(--navy); color: var(--navy); }
.logout-btn:hover { background: var(--navy); color: #fff; }
.side-portal { display: none; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.side-portal a.active { background: var(--navy); color: #fff; box-shadow: none; }
.side-title { font-weight: 700; color: var(--navy); padding: 6px 12px 10px; font-size: 13px; letter-spacing: .02em; }
.sidenav .global-search { margin: 0 4px 10px; max-width: none; }
.sidenav .global-search input { height: 34px; font-size: 13px; padding: 0 12px; }
.sidenav .dropdown { right: auto; width: 320px; }
.sidenav .count { float: right; }
#assetFolderNav a { display: flex; justify-content: space-between; gap: 6px; }
.fold-name { min-width: 0; overflow-wrap: anywhere; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 700; color: var(--accent-ink); margin: 0 0 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (min-width: 1200px) {
  body[data-app="home"] .sidenav { display: none; }
  body[data-app="home"] main { max-width: 1240px; margin: 0 auto; padding: 32px 24px; }
}
@media (max-width: 1199px) {
  .portal-nav { display: none; }
  .side-portal { display: block; }
}
@media (max-width: 640px) {
  .logout-btn { display: none; }
}

/* ---------- home ---------- */
.portal-hero { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%); color: #fff; border-radius: 12px; padding: 28px 30px; margin-bottom: 22px; border-left: 6px solid var(--accent); }
.portal-hero h1 { font-size: 28px; color: #fff; margin-bottom: 6px; }
.portal-hero .muted { color: #cfd4ef; max-width: 720px; margin: 0; }
.portal-hero .eyebrow { color: #f6c27f; }
.app-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.app-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; box-shadow: var(--shadow); color: var(--text); border-top: 4px solid var(--navy); transition: transform .12s, box-shadow .12s, border-color .12s; min-height: 270px; }
.app-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-top-color: var(--accent); }
.app-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.app-icon { width: 58px; height: 58px; border-radius: 14px; background: var(--navy-soft); display: grid; place-items: center; margin-bottom: 14px; }
.app-icon svg { width: 32px; height: 32px; fill: none; stroke: var(--navy); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.app-body { flex: 1; }
.app-body h2 { font-size: 19px; color: var(--navy); margin-bottom: 6px; }
.app-body p { color: var(--muted); line-height: 1.5; }
.app-stats { display: flex; gap: 22px; margin-top: 12px; }
.app-stat b { display: block; font-size: 22px; color: var(--navy); }
.app-stat span { font-size: 12px; color: var(--muted); }
.app-cta { margin-top: 16px; font-weight: 650; color: var(--navy-2); }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }
@media (max-width: 1000px) { .app-grid { grid-template-columns: minmax(0, 1fr); } .app-card { min-height: 0; } }
@media (max-width: 640px) { .portal-hero { padding: 20px; } .portal-hero h1 { font-size: 22px; } }

/* ---------- shared: stats, forms, filters, tables ---------- */
.stat.stat-ok .num { color: var(--ok); }
.stat.stat-danger .num { color: var(--danger); }
.stat.stat-warn .num { color: var(--warn); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
.journal-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 820px; }
.journal-form .form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 6px; }
.alert.ok-alert { background: var(--ok-soft); border-color: #bfe5cb; color: #14532d; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; padding: 14px 16px 4px; }
.filter-bar label { flex: 1 1 150px; min-width: 130px; margin-bottom: 10px; font-size: 13px; }
.filter-bar .fb-search { flex: 2 1 240px; }
.filter-bar .fb-actions { display: flex; gap: 6px; margin-bottom: 10px; }
.filter-bar input, .filter-bar select { height: 34px; padding: 5px 9px; }
th.sortable a { color: inherit; display: block; }
th.sortable a:hover { color: var(--navy); text-decoration: none; }
th.sorted { color: var(--navy); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 2px; }
.row-actions .btn.sm { padding: 0 8px; height: 26px; font-size: 12.5px; }
.journal-table td { vertical-align: middle; }
.disp-note { max-width: 220px; margin-top: 2px; }
.journal-dash { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; }
@media (max-width: 1100px) { .journal-dash { grid-template-columns: minmax(0, 1fr); } }
.selected-row td { background: var(--navy-soft); }
.up { color: var(--ok); font-weight: 650; }
.down { color: var(--danger); font-weight: 650; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; }
.inline-form select { width: auto; margin: 0; height: 34px; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.history .old { text-decoration: line-through; color: var(--muted); }
.check-row { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 12px; }
.preset-row .chip:hover { border-color: var(--navy-2); text-decoration: none; }
.report-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin: 6px 0 12px; }
.report-bar .actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 1100px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .form-grid, .journal-form .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2, .journal-form .form-grid .span-2 { grid-column: auto; }
  .row-actions { text-align: left; white-space: normal; }
}

/* ---------- journal dashboard bars ---------- */
.year-bars { display: grid; gap: 8px; }
.year-bar { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 10px; align-items: center; color: var(--text); }
.year-bar:hover { text-decoration: none; }
.year-bar:hover .yb-track { outline: 2px solid var(--navy-soft); }
.yb-label { font-weight: 650; }
.yb-track { display: flex; height: 18px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.yb-track span { display: block; height: 100%; }
.year-bar b { text-align: right; }
.seg-funded, .lg-funded { background: #1f7a4a; }
.seg-denied, .lg-denied { background: #b42318; }
.seg-withdrawn, .lg-withdrawn { background: #d98a1c; }
.seg-other, .lg-other { background: #39429a; }
.seg-pending, .lg-pending { background: #aab2c5; }
.legend .lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: middle; }
.legend { margin-top: 10px; color: var(--muted); }

/* ---------- report sheet (resembles the paper OFR journal) ---------- */
.report-sheet { padding: 22px; }
.rs-top { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; margin-bottom: 10px; }
.rs-right { text-align: right; }
.rs-title { text-align: center; font-size: 17px; letter-spacing: .04em; color: var(--navy); border-top: 2px solid var(--navy); border-bottom: 1px solid var(--navy); padding: 8px 0; margin: 8px 0; }
.report-sheet h3 { text-align: center; }
.sheet-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.sheet-table th, .sheet-table td { border: 1px solid #9aa3b5; padding: 6px 8px; }
.sheet-table th { background: var(--navy); color: #fff; text-transform: none; letter-spacing: 0; font-size: 12px; white-space: normal; position: static; }
.sheet-table tbody tr:nth-child(even) td { background: #f5f7fb; }
.sheet-table .disp-col { text-align: center; width: 70px; }
.rs-totals { margin-top: 10px; }

/* ---------- asset management ---------- */
.asset-stats { grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(260px, 2fr); }
.recent-stat ul { list-style: none; padding: 0; margin: 6px 0 0; font-size: 13px; }
.recent-stat li { padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-btn { height: 40px; font-size: 15px; padding: 0 18px; }
.uploader { border: 2px solid var(--navy-soft); }
.up-folder { max-width: 360px; }
.drop-zone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; border: 2px dashed var(--border-strong); border-radius: 10px; background: #fafbfd; text-align: center; cursor: pointer; }
.drop-zone:hover, .drop-zone:focus, .drop-zone.over { border-color: var(--navy-2); background: var(--navy-soft); outline: none; }
.dz-icon svg { width: 40px; height: 40px; fill: none; stroke: var(--navy); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.up-list { list-style: none; padding: 0; margin: 12px 0 0; }
.up-list li { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; }
.up-list li.err { border-color: #f4c7c2; background: var(--danger-soft); }
.up-list li.err .up-msg { color: var(--danger); }
.up-list li.done .up-msg { color: var(--ok); }
.up-bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin: 6px 0 4px; }
.up-bar span { display: block; height: 100%; width: 0; background: var(--navy-2); transition: width .15s; }
.up-list li.done .up-bar span { background: var(--ok); }
.up-list li.err .up-bar { display: none; }
.file-badge { display: inline-block; min-width: 34px; text-align: center; font-size: 10px; font-weight: 800; letter-spacing: .03em; padding: 2px 4px; border-radius: 3px; color: #fff; background: #6b7280; vertical-align: middle; }
.fb-PDF { background: #b42318; } .fb-DOC { background: #2b579a; } .fb-XLS, .fb-CSV { background: #217346; }
.fb-PPT { background: #c4401f; } .fb-JPG, .fb-PNG { background: #6d28d9; } .fb-TXT { background: #4b5563; }
.doc-name { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; word-break: break-word; }
.doc-table td { vertical-align: middle; }
.preview-box { text-align: center; background: #f3f4f6; border-radius: 6px; padding: 10px; margin-bottom: 10px; }
.preview-box img { max-width: 100%; max-height: 70vh; }
.pdf-frame { width: 100%; height: 72vh; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 10px; }
.modal.wide { max-width: 1000px; }
@media (max-width: 1100px) { .asset-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .recent-stat { grid-column: 1 / -1; } }
@media (max-width: 640px) { .asset-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } .asset-stats .stat { padding: 10px; } .asset-stats .num { font-size: 19px; } .page-head .actions { width: 100%; } }

/* ---------- login page ---------- */
.login-title { letter-spacing: .08em; font-size: 19px; }
.login-alt { text-align: center; margin: 14px 0 0; }
.login-foot { text-align: center; font-size: 12px; color: var(--muted); margin: 18px 0 0; }
.form-ok { color: var(--ok); margin-bottom: 8px; }

/* ---------- printing ---------- */
@media print {
  @page { size: landscape; margin: 0.5in; }
  body { background: #fff; }
  .no-print, .page-head, .topbar, .sidenav, #toasts, .alert { display: none !important; }
  .layout, main { display: block; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .table-wrap { overflow: visible; border: 0; }
  .sheet-table th { background: #fff !important; color: #000; border: 1px solid #000; -webkit-print-color-adjust: exact; }
  .sheet-table td { border: 1px solid #000; }
  .sheet-table tbody tr:nth-child(even) td { background: #fff; }
  .sheet-table thead { display: table-header-group; }
  .sheet-table tr { page-break-inside: avoid; }
  .rs-title { color: #000; border-color: #000; }
}
