:root {
  --bg: #fff8fb;
  --panel: #ffffff;
  --panel-soft: #fff1f6;
  --sidebar: #f8dce7;
  --accent: #d56591;
  --accent-dark: #b94873;
  --text: #402934;
  --muted: #806a75;
  --border: #f0dbe4;
  --danger: #c74d67;
  --warning: #bd862c;
  --success: #328367;
  --blue: #617dc2;
  --shadow: 0 18px 46px rgba(116, 63, 84, .12);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
h1, h2, h3, p { margin-top: 0; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 20%, #f9d8e6, transparent 32%), radial-gradient(circle at 88% 82%, #f4c9db, transparent 28%), #fff9fb; }
.login-card { width: min(1080px, 100%); height: min(660px, calc(100vh - 48px)); min-height: 520px; display: grid; grid-template-columns: 1.08fr .92fr; grid-template-rows: auto 1fr; gap: 22px 52px; overflow: hidden; padding: 36px; border: 1px solid var(--border); border-radius: 28px; background: linear-gradient(120deg, #fff 0 54%, #fff1f6 54%); box-shadow: var(--shadow); }
.login-brand { grid-column: 1; grid-row: 1; }
.login-brand, .sidebar-brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 13px; color: var(--accent); background: #fff; box-shadow: 0 7px 20px rgba(152, 71, 103, .13); }
.brand-mark svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark svg circle { fill: currentColor; stroke: none; }
.login-brand strong, .login-brand span, .sidebar-brand strong, .sidebar-brand span { display: block; }
.login-brand strong, .sidebar-brand strong { font-size: 17px; }
.login-brand span, .sidebar-brand span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.login-copy { grid-column: 1; grid-row: 2; align-self: center; padding: 20px 0; }
.eyebrow, .section-heading > div > span, .panel-heading > div > span, .modal-heading > div > span { color: var(--accent-dark); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.login-copy h1 { max-width: 520px; margin: 14px 0; font-size: clamp(2.3rem, 5vw, 4.3rem); line-height: 1.02; letter-spacing: -.05em; }
.login-copy p { max-width: 480px; color: var(--muted); font-size: 16px; line-height: 1.6; }
.login-form { grid-column: 2; grid-row: 1 / 3; width: 100%; max-width: 420px; align-self: center; justify-self: end; display: grid; gap: 17px; padding: 30px; border: 1px solid var(--border); border-radius: 20px; background: rgba(255,255,255,.86); box-shadow: 0 12px 32px rgba(128, 66, 90, .08); }
label { display: grid; gap: 7px; color: var(--text); font-size: 12px; font-weight: 700; }
input, select { width: 100%; min-height: 45px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--text); background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(213, 101, 145, .12); }
.button { min-height: 43px; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font-weight: 800; }
.button.primary { color: #fff; background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { color: var(--text); border-color: var(--border); background: #fff; }
.form-message { min-height: 17px; margin: 0; color: var(--danger); font-size: 12px; font-weight: 700; }
.form-message.success { color: var(--success); }

.app { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; min-width: 0; display: flex; flex-direction: column; gap: 26px; padding: 24px 16px; background: var(--sidebar); }
.sidebar-brand { padding: 0 8px; }
.sidebar-brand > div:last-child { min-width: 0; }
.sidebar-brand strong, .sidebar-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-nav { display: grid; gap: 5px; }
.nav-label { padding: 15px 11px 5px; color: #9d7182; font-size: 10px; font-weight: 800; letter-spacing: .09em; }
.main-nav button { width: 100%; min-height: 46px; display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: center; gap: 11px; border: 0; border-radius: 11px; padding: 10px 12px; color: #654653; background: transparent; text-align: left; font-weight: 700; }
.nav-icon { width: 22px; height: 22px; display: grid; place-items: center; color: #956177; }
.nav-icon svg, .sidebar-user button svg, .icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-nav button:hover { background: rgba(255,255,255,.5); }
.main-nav button.active { color: #54283a; background: #fff; box-shadow: 0 7px 18px rgba(145, 78, 105, .11); }
.main-nav button.active .nav-icon { color: var(--accent-dark); }
.sidebar-user { margin-top: auto; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 12px; border-radius: 13px; background: rgba(255,255,255,.55); }
.sidebar-user strong, .sidebar-user span { display: block; }
.sidebar-user strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user div > span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.sidebar-user button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; color: var(--muted); background: transparent; }
.sidebar-user button svg { width: 17px; height: 17px; }
.user-avatar { width: 32px; height: 32px; display: grid !important; place-items: center; border-radius: 50%; color: #fff; background: var(--accent); font-size: 10px; font-weight: 800; }

.main-content { min-width: 0; }
.topbar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 28px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.93); backdrop-filter: blur(12px); }
.topbar h1 { margin-bottom: 3px; font-size: 21px; letter-spacing: -.02em; }
.topbar p { margin: 0; color: var(--muted); font-size: 12px; }
.mobile-kicker { display: none; }
.top-actions { display: flex; align-items: end; gap: 9px; }
.branch-filter { min-width: 190px; }
.branch-filter span, .date-field span { color: var(--muted); font-size: 10px; }
.branch-filter select, .date-field input { min-height: 40px; background: var(--panel-soft); }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--panel-soft); }
.content-wrap { padding: 24px 28px 34px; }
.view { display: grid; gap: 18px; }
.welcome-row, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.welcome-row h2, .section-heading h2 { margin-bottom: 4px; font-size: 19px; }
.welcome-row p, .section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.section-heading > div > span { display: block; margin-bottom: 8px; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { min-width: 0; padding: 17px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); box-shadow: 0 4px 18px rgba(125, 69, 92, .04); }
.metric > span, .metric small { display: block; color: var(--muted); font-size: 11px; }
.metric strong { display: block; margin: 9px 0 5px; font-size: 23px; letter-spacing: -.035em; }
.metric.accent { color: #fff; border-color: var(--accent); background: var(--accent); }
.metric.accent > span, .metric.accent small { color: rgba(255,255,255,.82); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .65fr); gap: 14px; }
.panel { min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: 15px; background: var(--panel); box-shadow: 0 4px 18px rgba(125, 69, 92, .04); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 15px; }
.panel-heading h3 { margin: 5px 0 0; font-size: 15px; }
.text-button { border: 0; padding: 5px; color: var(--accent-dark); background: transparent; font-size: 11px; font-weight: 800; }
.performance-list { display: grid; gap: 7px; }
.performance-item { display: grid; grid-template-columns: minmax(150px, 1fr) 90px 115px 90px; align-items: center; gap: 10px; padding: 11px 9px; border-top: 1px solid var(--border); font-size: 11px; }
.performance-item:first-child { border-top: 0; }
.performance-branch strong, .performance-branch span { display: block; }
.performance-branch strong { font-size: 12px; }
.performance-branch span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.performance-item > span, .performance-item > strong { text-align: right; }
.status-pill { display: inline-flex; width: max-content; align-items: center; gap: 5px; border-radius: 99px; padding: 5px 8px; color: var(--muted); background: var(--panel-soft); font-size: 10px; }
.status-pill.open { color: var(--success); background: #eaf7f2; }
.status-pill.closed, .status-pill.approved { color: var(--blue); background: #eef1fb; }
.status-pill.danger { color: var(--danger); background: #fff0f3; }
.financial-list { display: grid; gap: 2px; }
.financial-list > div { display: flex; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.financial-list span { color: var(--muted); }
.soft-note { display: grid; gap: 3px; margin-top: 16px; padding: 13px; border-radius: 11px; background: var(--panel-soft); }
.soft-note strong { font-size: 12px; }
.soft-note span { color: var(--muted); font-size: 10px; }
.alerts-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.alert-card { padding: 13px 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.alert-card strong, .alert-card span { display: block; }
.alert-card strong { font-size: 11px; }
.alert-card span { margin-top: 3px; color: var(--muted); font-size: 10px; }

.branch-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 13px; }
.branch-card { display: grid; gap: 14px; padding: 17px; border: 1px solid var(--border); border-radius: 15px; background: var(--panel); }
.branch-card.inactive { opacity: .62; }
.branch-card-head { display: flex; justify-content: space-between; gap: 12px; }
.branch-card-head h3 { margin-bottom: 3px; font-size: 15px; }
.branch-card-head p { margin: 0; color: var(--muted); font-size: 10px; }
.branch-code { height: max-content; border-radius: 7px; padding: 5px 7px; color: var(--accent-dark); background: var(--panel-soft); font-size: 9px; font-weight: 800; }
.branch-details { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.branch-details span strong { color: var(--text); }
.branch-card-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 11px; border-top: 1px solid var(--border); }
.edit-branch { border: 0; padding: 6px; color: var(--accent-dark); background: transparent; font-size: 11px; font-weight: 800; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 10px; color: var(--muted); font-weight: 700; text-align: left; white-space: nowrap; }
td { padding: 13px 10px; border-top: 1px solid var(--border); }
.danger-text { color: var(--danger); font-weight: 800; }
th:nth-child(n+3), td:nth-child(n+3) { text-align: right; }
.empty-state { display: grid; place-items: center; gap: 4px; min-height: 180px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--text); }
.audit-list { display: grid; }
.audit-item { display: grid; grid-template-columns: 37px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 12px 2px; border-top: 1px solid var(--border); }
.audit-item:first-child { border-top: 0; }
.audit-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--accent-dark); background: var(--panel-soft); }
.audit-item strong, .audit-item span { display: block; }
.audit-item strong { font-size: 11px; }
.audit-item span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.audit-item time { color: var(--muted); font-size: 10px; }
.settings-panel { max-width: 560px; }
.settings-panel form { display: grid; gap: 14px; }

.modal { width: min(980px, calc(100vw - 28px)); max-height: calc(100vh - 30px); overflow: auto; border: 0; border-radius: 20px; padding: 0; color: var(--text); background: #fff; box-shadow: 0 30px 90px rgba(83, 39, 57, .28); }
.modal::backdrop { background: rgba(64, 41, 52, .35); backdrop-filter: blur(3px); }
.modal form { padding: 23px; }
.modal-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.modal-heading h2 { margin: 5px 0 3px; font-size: 20px; }
.modal-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.modal-close { width: 36px; height: 36px; border: 0; border-radius: 9px; color: var(--muted); background: var(--panel-soft); font-size: 22px; }
.form-section { margin-top: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 13px; }
.form-section h3 { margin-bottom: 13px; font-size: 13px; }
.form-section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.form-section-title h3 { margin-bottom: 3px; }
.form-section-title p, .field-help { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.field-help { margin-top: 11px; }
.isolation-badge { flex: 0 0 auto; border-radius: 99px; padding: 6px 9px; color: var(--success); background: #eaf7f2; font-size: 9px; font-weight: 800; }
.admin-section { background: linear-gradient(135deg, #fff 0%, var(--panel-soft) 100%); }
.form-grid { display: grid; gap: 12px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input { width: 18px; min-height: 18px; accent-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 17px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: 380px; transform: translateY(130%); border-radius: 11px; padding: 12px 16px; color: #fff; background: var(--text); box-shadow: var(--shadow); font-size: 12px; font-weight: 700; opacity: 0; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.user-modal { width: min(720px, calc(100vw - 28px)); }

@media (max-width: 980px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .login-card { height: auto; min-height: 0; grid-template-columns: 1fr; grid-template-rows: auto; background: #fff; }
  .login-brand, .login-copy, .login-form { grid-column: auto; grid-row: auto; }
  .login-form { max-width: none; justify-self: stretch; }
  .login-form { padding: 20px; }
  .login-copy h1 { font-size: 2.5rem; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; }
  .sidebar-brand, .sidebar-user, .nav-label { display: none; }
  .main-nav { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; overflow: visible; }
  .main-nav button { width: 100%; min-width: 0; min-height: 54px; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 6px 2px; text-align: center; font-size: 0; }
  .main-nav button::after { content: attr(data-short); max-width: 100%; overflow: hidden; color: inherit; font-size: 9px; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
  .nav-text { display: none; }
  .nav-icon { width: 20px; height: 20px; }
  .nav-icon svg { width: 18px; height: 18px; }
  .welcome-row, .section-heading { align-items: flex-start; flex-direction: column; }
  .topbar { align-items: center; flex-wrap: wrap; padding: 15px 17px; }
  .topbar > div:first-child { min-width: 190px; flex: 1; }
  .mobile-kicker { display: block; margin-bottom: 4px; color: var(--accent-dark); font-size: 9px; font-weight: 800; }
  .top-actions { width: auto; }
  .branch-filter { flex: 1; min-width: 0; }
  .content-wrap { padding: 17px; }
  .alerts-row { grid-template-columns: 1fr; }
  .performance-item { grid-template-columns: minmax(130px, 1fr) auto; }
  .performance-item > span:nth-of-type(2), .performance-item > strong { display: none; }
  .form-grid.cols-2, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .login-screen { padding: 10px; }
  .login-card { min-height: 0; padding: 22px; border-radius: 20px; }
  .login-copy { padding: 8px 0; }
  .login-copy h1 { font-size: 2rem; }
}
