/* Simple Lend - Genesis. Design tokens + responsive shell (phone, tablet, desktop). */
:root {
  --g-primary: #0e5a6b;
  --g-primary-600: #0b4a58;
  --g-primary-700: #083843;
  --g-primary-50: #e8f3f5;
  --g-accent: #f2994a;
  --g-success: #1f9d6b;
  --g-warning: #e0a106;
  --g-danger: #d64550;
  --g-info: #2f80ed;
  --g-ink: #17262b;
  --g-muted: #6b7c82;
  --g-line: #e5ebed;
  --g-bg: #f4f7f8;
  --g-card: #ffffff;
  --g-radius: 14px;
  --g-shadow: 0 1px 2px rgba(16, 40, 48, .06), 0 4px 14px rgba(16, 40, 48, .05);
  --sidebar-w: 256px;
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--g-ink);
  --bs-border-color: var(--g-line);
  --bs-primary: var(--g-primary);
  --bs-primary-rgb: 14, 90, 107;
  --bs-link-color: var(--g-primary);
  --bs-link-color-rgb: 14, 90, 107;
  --bs-link-hover-color: var(--g-primary-700);
}
html, body { background: var(--g-bg); }
body { font-size: .925rem; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.text-muted { color: var(--g-muted) !important; }
.fw-600 { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- app shell ---------- */
.app { min-height: 100vh; }
.sidebar {
  --bs-offcanvas-width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--g-primary-700) 0%, var(--g-primary) 100%);
  color: #dbe9ec;
}
@media (min-width: 992px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); display: flex; flex-direction: column; z-index: 1030; }
  .main { margin-left: var(--sidebar-w); }
}
.sidebar .offcanvas-body, .sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: 0; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.25rem 1.25rem 1rem; color: #fff; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--g-accent), #f6c26b); color: var(--g-primary-700); font-weight: 800; font-size: 1.05rem;
}
.brand-name { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.brand-sub { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
.nav-section { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; opacity: .55; padding: 1rem 1.4rem .35rem; }
.side-link {
  display: flex; align-items: center; gap: .75rem; margin: .1rem .75rem; padding: .55rem .75rem; border-radius: 10px;
  color: #d4e6ea; font-weight: 500;
}
.side-link i { font-size: 1.05rem; opacity: .85; width: 1.2rem; text-align: center; }
.side-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.side-link.active { background: rgba(255, 255, 255, .16); color: #fff; }
.side-footer { margin-top: auto; padding: 1rem 1rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, .1); }
.side-user { display: flex; align-items: center; gap: .65rem; color: #fff; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
  background: var(--g-primary-50); color: var(--g-primary-700); flex: 0 0 auto;
}
.sidebar .avatar { background: rgba(255, 255, 255, .18); color: #fff; }

.topbar {
  position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.25rem; background: rgba(244, 247, 248, .88); backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--g-line);
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .search { max-width: 340px; }
.topbar .search .form-control { border-radius: 999px; padding-left: 2.2rem; background: #fff; }
.topbar .search i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--g-muted); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--g-line); background: #fff; color: var(--g-ink); }
.content { padding: 1.25rem; max-width: 1480px; }
@media (min-width: 1200px) { .content { padding: 1.75rem 2rem; } }
@media (max-width: 991.98px) { .content { padding-bottom: 5.5rem; } }

/* mobile tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; justify-content: space-around;
  background: #fff; border-top: 1px solid var(--g-line); padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 18px rgba(16, 40, 48, .06);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; font-size: .68rem; color: var(--g-muted); padding: .2rem 0; }
.tabbar a i { font-size: 1.25rem; }
.tabbar a.active { color: var(--g-primary); font-weight: 600; }

/* ---------- surfaces ---------- */
.card, .panel { background: var(--g-card); border: 1px solid var(--g-line); border-radius: var(--g-radius); box-shadow: var(--g-shadow); }
.panel { padding: 1.15rem 1.25rem; }
.panel-title { font-size: .95rem; font-weight: 700; margin-bottom: .85rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.panel-title small { font-weight: 500; color: var(--g-muted); font-size: .78rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h2 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-head p { margin: .15rem 0 0; color: var(--g-muted); }

/* KPI tiles */
.kpi { background: var(--g-card); border: 1px solid var(--g-line); border-radius: var(--g-radius); box-shadow: var(--g-shadow); padding: 1rem 1.1rem; height: 100%; display: flex; gap: .85rem; align-items: flex-start; }
.kpi-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; flex: 0 0 auto; }
.kpi-label { color: var(--g-muted); font-size: .78rem; font-weight: 500; }
.kpi-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--g-muted); font-size: .76rem; margin-top: .1rem; }
@media (max-width: 575.98px) { .kpi { padding: .8rem; gap: .6rem; } .kpi-icon { width: 34px; height: 34px; font-size: 1rem; } .kpi-value { font-size: 1.1rem; } }
.tone-primary { background: var(--g-primary-50); color: var(--g-primary); }
.tone-success { background: #e4f5ee; color: var(--g-success); }
.tone-warning { background: #fdf3dc; color: #b07d00; }
.tone-danger { background: #fbe7e9; color: var(--g-danger); }
.tone-info { background: #e6f0fd; color: var(--g-info); }
.tone-accent { background: #fdeedf; color: #c56a1c; }
.kpi.alert-ring { border-color: #f3b9bd; }

/* pills / badges */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.plain::before { display: none; }

/* buttons */
.btn { border-radius: 10px; font-weight: 600; }
.btn-genesis, .btn-primary { background: var(--g-primary); border-color: var(--g-primary); color: #fff; }
.btn-genesis:hover, .btn-genesis:focus, .btn-primary:hover { background: var(--g-primary-600); border-color: var(--g-primary-600); color: #fff; }
.btn-soft { background: var(--g-primary-50); color: var(--g-primary); border: 0; }
.btn-soft:hover { background: #d6eaee; color: var(--g-primary-700); }
.form-control, .form-select { border-radius: 10px; border-color: #d8e1e4; }
.form-control:focus, .form-select:focus { border-color: #7fb3bf; box-shadow: 0 0 0 .2rem rgba(14, 90, 107, .12); }
.form-label { font-weight: 600; font-size: .8rem; color: #3f5157; margin-bottom: .3rem; }
.form-section { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--g-muted); font-weight: 700; margin: 0 0 .75rem; }

/* tables */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--g-muted); font-weight: 700; border-bottom-width: 1px; background: #f8fafb; white-space: nowrap; }
.table > :not(caption) > * > * { padding: .65rem .75rem; border-color: var(--g-line); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f3f8f9; }
.table-wrap { background: var(--g-card); border: 1px solid var(--g-line); border-radius: var(--g-radius); box-shadow: var(--g-shadow); overflow: hidden; }
.table-wrap .table-responsive { margin: 0; }
.row-link { font-weight: 600; }
.sub { display: block; color: var(--g-muted); font-size: .76rem; font-weight: 400; }

/* phone: list tables become cards */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-wrap:has(.table-stack) { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table-stack tr { background: #fff; border: 1px solid var(--g-line); border-radius: 12px; margin-bottom: .65rem; padding: .55rem .85rem; box-shadow: var(--g-shadow); }
  .table-stack > :not(caption) > * > * { padding: .3rem 0; border: 0; }
  .table-stack td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-align: right !important; }
  .table-stack td::before { content: attr(data-label); color: var(--g-muted); font-size: .76rem; font-weight: 600; text-align: left; }
  .table-stack td.cell-title { font-size: 1rem; border-bottom: 1px solid var(--g-line); padding-bottom: .45rem; margin-bottom: .2rem; }
  .table-stack td.cell-title::before { display: none; }
  .table-stack td.cell-title .sub { display: inline; margin-left: .35rem; }
}

/* filters */
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: .38rem .85rem; border-radius: 999px; border: 1px solid var(--g-line); background: #fff; color: var(--g-ink); font-weight: 600; font-size: .8rem; white-space: nowrap; }
.chip.active { background: var(--g-primary); border-color: var(--g-primary); color: #fff; }
.chip .count { opacity: .7; margin-left: .25rem; font-weight: 500; }

/* bars */
.bar { background: #edf2f3; border-radius: 999px; height: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; }

/* definition list */
.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: .45rem 1rem; margin: 0; }
.kv dt { color: var(--g-muted); font-weight: 500; font-size: .82rem; }
.kv dd { margin: 0; font-weight: 500; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--g-primary); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--g-line); }
.timeline li:last-child::after { display: none; }

/* score ring */
.score-ring { --p: 0; width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--ring, var(--g-primary)) calc(var(--p) * 1%), #e8eef0 0); }
.score-ring > div { width: 88px; height: 88px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; }
.score-ring strong { font-size: 1.6rem; line-height: 1; }

/* hero / auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: #fff; }
@media (min-width: 992px) { .auth { grid-template-columns: 1.1fr 1fr; } }
.auth-brand { display: none; position: relative; overflow: hidden; color: #fff; padding: 3.5rem;
  background: radial-gradient(circle at 20% 20%, rgba(242, 153, 74, .35), transparent 40%), linear-gradient(150deg, var(--g-primary-700), var(--g-primary) 60%, #138196); }
@media (min-width: 992px) { .auth-brand { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-brand h2 { font-size: 2.2rem; font-weight: 800; line-height: 1.15; max-width: 28rem; }
.auth-feature { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: 1rem; max-width: 26rem; }
.auth-feature i { font-size: 1.2rem; background: rgba(255, 255, 255, .14); border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 380px; }

/* architecture page */
.arch-hero { border-radius: 18px; color: #fff; padding: 2rem; margin-bottom: 1.5rem;
  background: radial-gradient(circle at 85% 15%, rgba(242, 153, 74, .35), transparent 35%), linear-gradient(135deg, var(--g-primary-700), var(--g-primary)); }
.arch-hero h2 { font-weight: 800; font-size: 1.7rem; }
.stat { text-align: center; }
.stat b { display: block; font-size: 1.4rem; }
.stat span { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.diagram { width: 100%; height: auto; }
.code-shell { display: grid; grid-template-columns: 1fr; border: 1px solid var(--g-line); border-radius: var(--g-radius); overflow: hidden; background: #0d1117; min-height: 520px; }
@media (min-width: 992px) { .code-shell { grid-template-columns: 290px 1fr; } }
.code-files { background: #fff; border-right: 1px solid var(--g-line); max-height: 640px; overflow: auto; }
.code-files .grp { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--g-muted); padding: .75rem 1rem .25rem; font-weight: 700; }
.code-files button { display: flex; justify-content: space-between; width: 100%; border: 0; background: none; text-align: left; padding: .35rem 1rem; font-size: .8rem; color: var(--g-ink); }
.code-files button:hover { background: #f1f6f7; }
.code-files button.active { background: var(--g-primary-50); color: var(--g-primary-700); font-weight: 600; }
.code-files button span { color: var(--g-muted); font-size: .72rem; }
.code-view { overflow: auto; max-height: 640px; }
.code-view .code-head { position: sticky; top: 0; background: #161b22; color: #c9d1d9; padding: .55rem 1rem; font-size: .8rem; border-bottom: 1px solid #30363d; }
.code-view pre { margin: 0; }
.code-view pre code.hljs { padding: 1rem 1.1rem; font-size: .8rem; line-height: 1.55; background: #0d1117; }
.layer-card { border-left: 4px solid var(--g-primary); }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { padding: .3rem 0 .3rem 1.6rem; position: relative; }
.check-list li::before { content: "\F26B"; font-family: "bootstrap-icons"; position: absolute; left: 0; color: var(--g-success); }

/* print */
@media print { .sidebar, .topbar, .tabbar, .no-print { display: none !important; } .main { margin: 0 !important; } }

/* avatar menu */
.avatar-btn { border: 0; background: none; padding: 0; border-radius: 50%; }
.avatar-btn:focus-visible { outline: 2px solid var(--g-primary); outline-offset: 2px; }
.avatar-btn .avatar { width: 38px; height: 38px; background: var(--g-primary); color: #fff; }
.user-menu { min-width: 260px; border-radius: 14px; border: 1px solid var(--g-line); box-shadow: 0 12px 32px rgba(16, 40, 48, .14); padding: .5rem; }
.user-menu .dropdown-item { border-radius: 8px; padding: .5rem .75rem; display: flex; align-items: center; gap: .6rem; font-weight: 500; }
.user-menu .dropdown-item i { color: var(--g-muted); width: 1.1rem; text-align: center; }
.user-menu .dropdown-item:active { background: var(--g-primary-50); color: var(--g-ink); }
.user-head { display: flex; gap: .75rem; align-items: center; padding: .5rem .75rem .75rem; }
.release-item { border-left: 3px solid var(--g-line); padding-left: 1rem; margin-bottom: 1.5rem; }
.release-item.latest { border-left-color: var(--g-primary); }
