/* ===========================================================================
   LoansHub — premium UI. Used only by the hub (login, launcher, admin).
   The individual tools keep their own look.
   =========================================================================== */

:root {
	--bg: #F6F7F9;
	--surface: #FFFFFF;
	--surface-2: #FBFBFD;
	--border: #ECEDF1;
	--border-strong: #DEDFE5;
	--text: #15171C;
	--text-muted: #6A7180;
	--text-subtle: #9BA1AD;
	--accent: #6366F1;
	--accent-hover: #4F46E5;
	--accent-soft: #EEF0FE;
	--accent-text: #4338CA;
	--danger: #EF4444;
	--danger-soft: #FEF2F2;
	--success: #10B981;
	--shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
	--shadow-sm: 0 2px 6px rgba(16, 24, 40, .06);
	--shadow-md: 0 8px 28px rgba(16, 24, 40, .08);
	--shadow-lg: 0 30px 70px rgba(2, 6, 23, .22);
	--radius: 12px;
	--radius-lg: 16px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
	font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
	background: var(--bg);
	color: var(--text);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

a { color: var(--accent-hover); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.018em; }
svg.icon, .icon { width: 17px; height: 17px; flex: none; }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
	display: inline-flex; align-items: center; gap: 7px;
	height: 38px; padding: 0 15px;
	background: var(--surface); color: var(--text);
	border: 1px solid var(--border-strong); border-radius: 9px;
	font-size: 13.5px; font-weight: 550; cursor: pointer;
	transition: background .12s, border-color .12s, box-shadow .12s, transform .04s;
	text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: #CFD2DA; }
.btn:active { transform: translateY(.5px); }
.btn .icon { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: #F3D2D2; background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); border-color: #ECBDBD; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }

/* ---- Badges ------------------------------------------------------------ */
.badge {
	display: inline-flex; align-items: center;
	padding: 3px 9px; border-radius: 999px;
	font-size: 11.5px; font-weight: 600; line-height: 1;
	background: #F1F2F5; color: var(--text-muted);
}
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }

/* ---- App shell --------------------------------------------------------- */
.app { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }

.sidebar {
	background: var(--surface);
	border-right: 1px solid var(--border);
	padding: 18px 14px;
	display: flex; flex-direction: column;
	position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.sidebar-brand .logo-mark {
	width: 34px; height: 34px; border-radius: 10px;
	background: linear-gradient(140deg, #6366F1, #8B5CF6);
	display: grid; place-items: center; color: #fff;
	box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}
.sidebar-brand > div:last-child { font-size: 16px; font-weight: 700; letter-spacing: -.02em; }

.sidebar-section-label {
	font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em;
	color: var(--text-subtle); padding: 16px 10px 7px;
}
.sidebar-nav {
	display: flex; align-items: center; gap: 11px;
	padding: 9px 11px; margin-bottom: 2px;
	border-radius: 9px; color: var(--text-muted);
	font-size: 13.5px; font-weight: 550; cursor: pointer;
	transition: background .12s, color .12s;
}
.sidebar-nav .icon { color: var(--text-subtle); transition: color .12s; }
.sidebar-nav:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-nav:hover .icon { color: var(--text-muted); }
.sidebar-nav.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.sidebar-nav.active .icon { color: var(--accent); }

.sidebar-spacer { flex: 1; }
.sidebar-user { border-top: 1px solid var(--border); padding: 14px 10px 4px; font-size: 12.5px; color: var(--text-subtle); }
.sidebar-user .who { color: var(--text); font-weight: 600; }
.sidebar-user-btn {
	margin-top: 10px; width: 100%; height: 34px;
	background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
	color: var(--text-muted); font-size: 12.5px; font-weight: 550; cursor: pointer;
	transition: background .12s, color .12s;
}
.sidebar-user-btn:hover { background: var(--surface-2); color: var(--text); }

.main { display: flex; flex-direction: column; min-width: 0; }
.content { width: 100%; max-width: 1120px; margin: 0 auto; padding: 38px 40px 80px; }

/* ---- Page header ------------------------------------------------------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-header h2 { font-size: 23px; font-weight: 680; }
.page-header .subtitle, .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex: none; }

/* ---- Panels ------------------------------------------------------------ */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); margin-bottom: 22px; overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-header h3 { font-size: 15px; font-weight: 640; display: flex; align-items: center; }
.panel-actions { display: flex; gap: 8px; }
.panel-body { padding: 20px; }

/* ---- Cards grid (roles) ----------------------------------------------- */
.institutions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 16px; }
.institution-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 13px; box-shadow: var(--shadow-xs); }
.institution-card h3 { font-size: 14px; font-weight: 640; }
.card-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.card-perms { display: flex; flex-wrap: wrap; gap: 6px; }
.card-footer { display: flex; gap: 8px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }

/* ---- Tables ------------------------------------------------------------ */
.hub-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.hub-table thead th {
	text-align: left; padding: 12px 18px; font-weight: 620;
	font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
	color: var(--text-subtle); background: var(--surface-2);
	border-bottom: 1px solid var(--border);
}
.hub-table tbody td { padding: 13px 18px; border-top: 1px solid var(--border); vertical-align: middle; }
.hub-table tbody tr:first-child td { border-top: 0; }
.hub-table tbody tr:hover td { background: var(--surface-2); }
.hub-table .row-name { font-weight: 600; }
.hub-table .cell-actions { text-align: right; white-space: nowrap; }
.hub-table .cell-actions .btn { margin-left: 6px; }

/* ---- Forms ------------------------------------------------------------- */
.form-section { margin-bottom: 22px; }
.form-section + .form-section { border-top: 1px solid var(--border); padding-top: 20px; }
.form-section-title { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-subtle); margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-field { margin-bottom: 4px; display: flex; flex-direction: column; }
.form-field label { font-size: 12.5px; font-weight: 600; color: #3A414E; margin-bottom: 6px; }
.form-field input[type="text"], .form-field input[type="email"], .form-field input[type="password"], .form-field select {
	height: 42px; padding: 0 13px; border: 1px solid var(--border-strong); border-radius: 9px;
	font-size: 14px; background: var(--surface); color: var(--text);
	transition: border-color .12s, box-shadow .12s; width: 100%;
}
.form-field input:focus, .form-field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .14); }
.form-field .help { font-size: 12px; color: var(--text-subtle); margin-top: 5px; }
.req { color: var(--danger); }

/* segmented toggle */
.toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 9px; padding: 3px; gap: 3px; width: fit-content; }
.toggle button { border: none; background: transparent; padding: 7px 16px; border-radius: 7px; font-size: 13px; font-weight: 550; color: var(--text-muted); cursor: pointer; transition: background .12s, color .12s; }
.toggle button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.toggle.toggle-success button.active.true { color: var(--success); }
.toggle button.active.false { color: var(--text); }

/* checkbox pills (permissions) */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-pill {
	display: inline-flex; align-items: center; padding: 7px 13px;
	border: 1px solid var(--border-strong); border-radius: 999px;
	font-size: 12.5px; font-weight: 550; color: var(--text-muted);
	background: var(--surface); cursor: pointer; user-select: none;
	transition: all .12s;
}
.checkbox-pill:hover { border-color: #CFD2DA; }
.checkbox-pill.checked { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); font-weight: 600; }

/* ---- Modal ------------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center; padding: 6vh 20px; z-index: 100; overflow-y: auto; }
.modal-backdrop.active { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; animation: modalIn .18s ease-out; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 16px; }
.modal-header h3 { font-size: 17px; font-weight: 660; }
.modal-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.modal-close { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; color: var(--text-muted); flex: none; }
.modal-close:hover { background: #F1F2F5; color: var(--text); }
.modal-body { padding: 4px 24px 8px; }
.modal-footer { padding: 16px 24px 22px; }
.footer-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Launcher ---------------------------------------------------------- */
.launcher h1 { font-size: 25px; font-weight: 700; }
.launcher .sub { color: var(--text-muted); font-size: 14.5px; margin-top: 5px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(264px, 1fr)); gap: 18px; margin-top: 30px; }
.tool-card {
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
	padding: 24px; min-height: 152px; display: flex; flex-direction: column; gap: 14px;
	color: inherit; text-decoration: none; box-shadow: var(--shadow-xs);
	transition: border-color .14s, box-shadow .16s, transform .14s;
}
a.tool-card:hover { border-color: #D8DAE2; box-shadow: var(--shadow-md); transform: translateY(-3px); text-decoration: none; }
.tool-card.disabled { opacity: .5; cursor: pointer; box-shadow: none; }
.tool-card.disabled:hover { border-color: var(--border); }
.tool-card.coming-soon { cursor: default; opacity: .55; }
.soon-pill { background: #FEF3E2; color: #B45309; border-radius: 999px; padding: 4px 11px; font-size: 11.5px; font-weight: 600; }
.tool-logo { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 19px; box-shadow: var(--shadow-sm); }
.tool-card h3 { font-size: 16.5px; font-weight: 660; }
.tool-card .desc { font-size: 13px; color: var(--text-muted); line-height: 1.45; }
.tool-card .meta { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.role-pill { background: var(--accent-soft); color: var(--accent-text); border-radius: 999px; padding: 4px 11px; font-size: 11.5px; font-weight: 600; }
.noaccess-pill { background: #F1F2F5; color: var(--text-subtle); border-radius: 999px; padding: 4px 11px; font-size: 11.5px; display: inline-flex; align-items: center; gap: 5px; font-weight: 550; }

/* ---- Toasts ------------------------------------------------------------ */
.toast-container { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: #15171C; color: #fff; padding: 12px 17px; border-radius: 11px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); max-width: 340px; }
.toast.success { background: #0F2E22; box-shadow: 0 16px 40px rgba(16, 185, 129, .25); }
.toast.error { background: #3A1414; box-shadow: 0 16px 40px rgba(239, 68, 68, .25); }

/* ---- Auth (login) ------------------------------------------------------ */
.auth-card { width: 100%; max-width: 408px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 18px 48px rgba(16, 24, 40, .10), 0 2px 8px rgba(16, 24, 40, .04); padding: 38px 34px; animation: modalIn .24s ease-out; }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 28px; }
.auth-brand .logo-mark { width: 44px; height: 44px; border-radius: 13px; background: linear-gradient(140deg, #6366F1, #8B5CF6); display: grid; place-items: center; color: #fff; box-shadow: 0 10px 24px rgba(99, 102, 241, .42); }
.auth-brand .brand-name { font-size: 21px; font-weight: 720; letter-spacing: -.02em; color: var(--text); }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 13.5px; margin-bottom: 28px; }
.auth-field { margin-bottom: 15px; }
.auth-field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 7px; color: #3A414E; }
.auth-field input { width: 100%; height: 46px; padding: 0 15px; border: 1px solid var(--border-strong); border-radius: 11px; font-size: 14px; background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.auth-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .16); }
.auth-pw { position: relative; }
.auth-pw input { padding-right: 46px; }
.auth-pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; background: none; border: none; cursor: pointer; color: var(--text-subtle); border-radius: 8px; transition: color .12s, background .12s; }
.auth-pw-toggle:hover { color: var(--text-muted); background: var(--surface-2); }
.auth-pw-toggle svg { width: 18px; height: 18px; }
.auth-error { background: var(--danger-soft); color: #B91C1C; border-radius: 10px; padding: 11px 14px; font-size: 12.5px; margin-bottom: 16px; border-left: 3px solid var(--danger); }
.auth-row { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 22px; }
.auth-remember { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; user-select: none; }
.auth-remember input[type="checkbox"] {
	appearance: none; -webkit-appearance: none; margin: 0;
	width: 18px; height: 18px; flex: none;
	border: 1.5px solid var(--border-strong); border-radius: 6px;
	background-color: var(--surface); cursor: pointer;
	transition: background-color .14s ease, border-color .14s ease;
}
.auth-remember input[type="checkbox"]:hover { border-color: #BFC3CD; }
.auth-remember input[type="checkbox"]:checked {
	background-color: var(--accent); border-color: var(--accent);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
	background-repeat: no-repeat; background-position: center; background-size: 11px 11px;
}
.auth-remember input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(99, 102, 241, .18); }
.auth-remember:hover { color: var(--text); }
.auth-btn { width: 100%; height: 48px; border-radius: 12px; background: var(--accent); color: #fff; font-size: 14.5px; font-weight: 620; border: none; cursor: pointer; box-shadow: 0 8px 20px rgba(99, 102, 241, .28); transition: background .12s, transform .06s, box-shadow .12s; }
.auth-btn:hover { background: var(--accent-hover); box-shadow: 0 10px 26px rgba(79, 70, 229, .34); }
.auth-btn:active { transform: translateY(1px); }
.auth-foot { text-align: center; margin-top: 22px; font-size: 11.5px; color: var(--text-subtle); }
