:root {
    --navy-950: #082449;
    --navy-900: #0f3d78;
    --navy-800: #15539c;
    --blue-700: #1769c2;
    --blue-600: #2679d8;
    --blue-100: #e9f2ff;
    --blue-050: #f5f9ff;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --canvas: #eef3f9;
    --border: #dfe6ef;
    --border-strong: #cdd8e6;
    --text: #23344a;
    --text-muted: #6e7d91;
    --success: #16825d;
    --success-bg: #e7f7f0;
    --danger: #c23b3b;
    --danger-bg: #fff0ef;
    --warning: #a66a08;
    --warning-bg: #fff6dd;
    --shadow-sm: 0 1px 2px rgba(15, 43, 78, .05);
    --shadow-md: 0 12px 35px rgba(20, 48, 84, .10);
    --sidebar-expanded: 258px;
    --sidebar-collapsed: 78px;
    --topbar-height: 68px;
    --radius: 14px;
    --radius-sm: 9px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: "Segoe UI", Tahoma, Arial, sans-serif; color: var(--text); background: var(--canvas); font-size: 14px; }
a { color: var(--blue-700); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.gs-icon { width: 21px; height: 21px; display: inline-block; flex: 0 0 auto; }

.app-shell { min-height: 100vh; padding-left: var(--sidebar-expanded); transition: padding-left .22s ease; }
.app-shell.sidebar-collapsed { padding-left: var(--sidebar-collapsed); }
.app-sidebar { position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: var(--sidebar-expanded); display: flex; flex-direction: column; color: #fff; background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 52%, #0b315f 100%); box-shadow: 6px 0 24px rgba(9, 38, 75, .14); transition: width .22s ease, transform .22s ease; overflow: hidden; }
.sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed); }
.sidebar-brand { min-height: 88px; padding: 15px 14px; border-bottom: 1px solid rgba(255,255,255,.10); }
.sidebar-brand-link { min-height: 58px; display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.sidebar-logo-text, .sidebar-logo-image { width: 48px; height: 48px; min-width: 48px; border-radius: 13px; }
.sidebar-logo-text { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2e8aff, #0f63bc); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); font-size: 18px; font-weight: 800; letter-spacing: -.5px; }
.sidebar-logo-image { object-fit: contain; background: #fff; padding: 4px; }
.sidebar-brand-copy { min-width: 0; overflow: hidden; white-space: nowrap; }
.sidebar-brand-copy strong, .sidebar-brand-copy small { display: block; }
.sidebar-brand-copy strong { font-size: 18px; }
.sidebar-brand-copy small { margin-top: 3px; color: rgba(255,255,255,.65); font-size: 11px; }
.sidebar-collapsed .sidebar-brand-copy, .sidebar-collapsed .sidebar-label, .sidebar-collapsed .sidebar-legacy-dot { opacity: 0; width: 0; overflow: hidden; pointer-events: none; }
.sidebar-collapsed .sidebar-brand { padding-left: 15px; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; overflow-x: hidden; }
.sidebar-link, .sidebar-collapse-button { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 13px; position: relative; padding: 9px 13px; margin: 3px 0; border: 0; border-radius: 10px; color: rgba(255,255,255,.78); background: transparent; text-decoration: none; text-align: left; transition: background .16s ease, color .16s ease; white-space: nowrap; }
.sidebar-link:hover, .sidebar-collapse-button:hover { color: #fff; background: rgba(255,255,255,.09); }
.sidebar-link.active { color: #fff; background: linear-gradient(90deg, rgba(45,137,255,.92), rgba(32,106,191,.72)); box-shadow: 0 8px 22px rgba(0,0,0,.15); }
.sidebar-icon { width: 27px; min-width: 27px; height: 27px; display: inline-flex; align-items: center; justify-content: center; }
.sidebar-label { overflow: hidden; text-overflow: ellipsis; transition: opacity .15s ease; }
.sidebar-legacy-dot { position: absolute; right: 12px; width: 7px; height: 7px; border-radius: 50%; background: #f7b84b; box-shadow: 0 0 0 3px rgba(247,184,75,.16); }
.sidebar-footer { padding: 10px; border-top: 1px solid rgba(255,255,255,.10); }
.sidebar-collapse-button { color: rgba(255,255,255,.68); }
.sidebar-collapse-icon { transition: transform .22s ease; }
.sidebar-collapsed .sidebar-collapse-icon { transform: rotate(180deg); }
.sidebar-overlay { display: none; }

.app-main { min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 40; min-height: var(--topbar-height); display: grid; grid-template-columns: minmax(200px, 1fr) minmax(300px, 540px) minmax(310px, 1fr); align-items: center; gap: 18px; padding: 10px 22px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm); backdrop-filter: blur(12px); }
.topbar-left, .topbar-actions { display: flex; align-items: center; min-width: 0; }
.topbar-actions { justify-content: flex-end; gap: 7px; }
.mobile-menu-button { display: none !important; }
.topbar-breadcrumbs { min-width: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; color: var(--text-muted); font-size: 12px; }
.topbar-breadcrumbs a { color: var(--text); text-decoration: none; font-weight: 700; }
.topbar-breadcrumbs strong { overflow: hidden; text-overflow: ellipsis; }
.global-search { min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 12px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 11px; }
.global-search-icon { display: flex; color: #8190a4; }
.global-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); }
.search-shortcut { padding: 3px 6px; border: 1px solid var(--border-strong); border-radius: 5px; color: #8190a4; background: #fff; font-size: 10px; }
.icon-button, .topbar-text-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 10px; color: #52647b; background: transparent; }
.icon-button { width: 40px; }
.icon-button:hover, .topbar-text-button:hover { background: var(--blue-050); color: var(--blue-700); }
.topbar-text-button { padding: 0 11px; }
.notification-dot { position: absolute; transform: translate(9px,-9px); width: 8px; height: 8px; border-radius: 50%; background: #e84949; box-shadow: 0 0 0 3px #fff; }
.quick-create-wrapper, .user-menu-wrapper { position: relative; }
.user-menu-button { min-width: 185px; display: flex; align-items: center; gap: 9px; padding: 4px 8px; border: 0; border-radius: 11px; background: transparent; text-align: left; }
.user-menu-button:hover { background: var(--blue-050); }
.user-avatar { width: 38px; height: 38px; min-width: 38px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; background: linear-gradient(135deg, var(--navy-900), var(--blue-600)); font-size: 12px; font-weight: 800; }
.user-copy { flex: 1; min-width: 0; }
.user-copy strong, .user-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-copy strong { font-size: 12px; }
.user-copy small { margin-top: 2px; color: var(--text-muted); font-size: 10px; }
.user-chevron { color: #8290a2; }
.dropdown-panel { display: none; position: absolute; z-index: 80; top: calc(100% + 9px); right: 0; min-width: 220px; padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); }
.dropdown-panel.open { display: block; }
.dropdown-panel a { display: flex; align-items: center; gap: 8px; padding: 10px 11px; border-radius: 8px; color: var(--text); text-decoration: none; }
.dropdown-panel a:hover { background: var(--blue-050); color: var(--blue-700); }
.dropdown-user-summary { padding: 9px 11px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.dropdown-user-summary strong, .dropdown-user-summary small { display: block; }
.dropdown-user-summary small { margin-top: 3px; color: var(--text-muted); }
.dropdown-panel .danger-link { color: var(--danger); }

.app-content { flex: 1; width: 100%; max-width: 1700px; margin: 0 auto; padding: 24px 26px 34px; }
.app-footer { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 26px; color: #758397; background: rgba(255,255,255,.72); border-top: 1px solid var(--border); font-size: 11px; }
.footer-phase { color: #9aa5b2; }
.mobile-bottom-nav { display: none; }

.page-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.page-hero h1 { margin: 3px 0 6px; color: var(--navy-900); font-size: 30px; line-height: 1.16; }
.page-hero p { margin: 0; color: var(--text-muted); }
.compact-hero h1 { font-size: 28px; }
.eyebrow { color: var(--blue-700) !important; font-size: 11px; font-weight: 800; letter-spacing: 1.25px; }
.hero-actions { display: flex; align-items: center; gap: 9px; }
.primary-button, .secondary-button, .row-action-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border-radius: 9px; text-decoration: none; font-weight: 700; }
.primary-button { color: #fff; border: 1px solid var(--blue-700); background: linear-gradient(180deg, var(--blue-600), var(--blue-700)); box-shadow: 0 6px 16px rgba(31,105,193,.18); }
.primary-button:hover { filter: brightness(.97); }
.secondary-button { color: var(--text); border: 1px solid var(--border-strong); background: #fff; }
.secondary-button:hover { color: var(--blue-700); border-color: #adc8e8; background: var(--blue-050); }
.text-button { padding: 6px 8px; border: 0; color: var(--blue-700); background: transparent; text-decoration: none; font-weight: 700; }
.full-width { width: 100%; }

.alert { margin-bottom: 17px; padding: 13px 15px; border: 1px solid; border-radius: 10px; }
.alert pre { margin: 7px 0 0; white-space: pre-wrap; font: 12px/1.45 Consolas, monospace; }
.alert-error { color: #7a2a24; background: var(--danger-bg); border-color: #efb3ad; }
.alert-warning { color: #76550e; background: var(--warning-bg); border-color: #ead18a; }
.alert-info { color: #295779; background: #eef7ff; border-color: #b8d7ef; }

.kpi-grid-modern { display: grid; grid-template-columns: repeat(5, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card { position: relative; min-height: 135px; padding: 17px; overflow: hidden; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.metric-card span, .metric-card strong, .metric-card small { display: block; }
.metric-card > span { color: var(--text-muted); font-size: 12px; }
.metric-card > strong { margin: 14px 0 8px; color: var(--navy-900); font-size: 24px; letter-spacing: -.5px; }
.metric-card small { color: #8995a5; font-size: 10px; }
.metric-card small a { text-decoration: none; }
.metric-icon { position: absolute; right: 14px; top: 14px; width: 39px; height: 39px; display: flex; align-items: center; justify-content: center; color: var(--blue-700); background: var(--blue-050); border-radius: 11px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; }
.panel-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-header { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 17px; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; color: var(--navy-900); font-size: 16px; }
.panel-header p { margin: 4px 0 0; color: var(--text-muted); font-size: 11px; }
.panel-header > a { text-decoration: none; font-weight: 700; font-size: 12px; }
.responsive-table-wrapper { width: 100%; overflow: auto; }
.modern-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.modern-table th, .modern-table td { padding: 10px 12px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: middle; white-space: nowrap; }
.modern-table th { color: #6c7a8d; background: #fbfcfe; font-size: 10px; text-transform: uppercase; letter-spacing: .3px; }
.modern-table tbody tr:hover { background: var(--blue-050); }
.modern-table tbody tr:last-child td { border-bottom: 0; }
.table-key { color: var(--blue-700); text-decoration: none; font-weight: 800; }
.money-cell { text-align: right !important; font-variant-numeric: tabular-nums; }
.negative-value { color: #d13a3a !important; font-weight: 700; }
.positive-value { color: #1768bd !important; font-weight: 700; }
.balance-value { color: #9b6508; font-weight: 700; }
.status-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 60px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.status-active { color: #126b4c; background: var(--success-bg); }
.status-inactive { color: #9a3731; background: var(--danger-bg); }
.status-neutral { color: #576578; background: #eef1f5; }
.empty-cell { padding: 34px !important; text-align: center !important; color: var(--text-muted); }

.migration-panel { padding-bottom: 10px; }
.migration-step { display: flex; gap: 11px; padding: 12px 16px; }
.migration-step > span { width: 29px; height: 29px; min-width: 29px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: #7c8999; background: #edf1f6; font-weight: 800; }
.migration-step strong, .migration-step small { display: block; }
.migration-step small { margin-top: 3px; color: var(--text-muted); line-height: 1.35; }
.migration-step.completed > span { color: #fff; background: var(--success); }
.migration-step.active { background: var(--blue-050); }
.migration-step.active > span { color: #fff; background: var(--blue-700); }

.diagnostic-card { max-width: 900px; overflow: hidden; }
.diagnostic-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.diagnostic-row span { color: var(--text-muted); }
.check-ok { color: var(--success); }
.check-bad { color: var(--danger); }

.right-drawer { position: fixed; z-index: 100; top: 0; right: 0; bottom: 0; width: min(430px, 94vw); display: flex; flex-direction: column; transform: translateX(105%); background: #fff; box-shadow: -14px 0 50px rgba(10,42,79,.18); transition: transform .24s ease; }
.right-drawer.open { transform: translateX(0); }
.drawer-overlay { position: fixed; z-index: 90; inset: 0; display: none; background: rgba(10,29,53,.32); backdrop-filter: blur(2px); }
.drawer-overlay.open { display: block; }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px; border-bottom: 1px solid var(--border); }
.drawer-header h2 { margin: 0; color: var(--navy-900); font-size: 19px; }
.drawer-header p { margin: 4px 0 0; color: var(--text-muted); font-size: 11px; }
.drawer-tabs { display: flex; gap: 20px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.drawer-tabs button { min-height: 47px; border: 0; border-bottom: 2px solid transparent; color: var(--text-muted); background: transparent; }
.drawer-tabs button.active { color: var(--blue-700); border-color: var(--blue-700); font-weight: 700; }
.drawer-section-title { display: flex; align-items: center; justify-content: space-between; padding: 17px 20px 4px; }
.drawer-help { margin: 0; padding: 0 20px 11px; color: var(--text-muted); font-size: 11px; }
.column-settings-list { flex: 1; overflow-y: auto; padding: 0 14px 16px; }
.column-setting-item { min-height: 47px; display: grid; grid-template-columns: 22px minmax(0, 1fr) 58px 31px; align-items: center; gap: 7px; padding: 6px 8px; margin: 3px 0; border: 1px solid var(--border); border-radius: 9px; background: #fff; }
.column-setting-item.dragging { opacity: .55; border-color: var(--blue-600); background: var(--blue-050); }
.drag-handle { color: #9aa5b4; cursor: grab; font-weight: 700; }
.column-toggle { display: flex; align-items: center; gap: 8px; min-width: 0; }
.column-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.column-width-select { height: 29px; border: 1px solid var(--border-strong); border-radius: 6px; background: #fff; }
.pin-control { display: flex; align-items: center; justify-content: center; }
.pin-control input { display: none; }
.pin-control span { width: 27px; height: 27px; display: flex; align-items: center; justify-content: center; border-radius: 6px; color: #8996a6; background: #f1f4f8; }
.pin-control input:checked + span { color: #fff; background: var(--blue-700); }
.drawer-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 20px; border-top: 1px solid var(--border); box-shadow: 0 -8px 24px rgba(20,48,84,.06); }
.drawer-footer strong, .drawer-footer small { display: block; }
.drawer-footer small { margin-top: 3px; color: var(--text-muted); }

.toast-container { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { min-width: 250px; max-width: 380px; padding: 12px 15px; transform: translateY(12px); opacity: 0; color: #fff; background: var(--navy-900); border-radius: 9px; box-shadow: var(--shadow-md); transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #a73434; }

.empty-state { max-width: 620px; margin: 80px auto; text-align: center; }
.empty-state-icon { width: 58px; height: 58px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; border-radius: 50%; color: #fff; background: var(--danger); font-size: 27px; font-weight: 800; }

.login-page { background: #eaf1f9; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(390px, .85fr); }
.login-presentation { display: flex; align-items: center; justify-content: center; padding: 60px; color: #fff; background: radial-gradient(circle at 20% 20%, rgba(60,147,255,.35), transparent 34%), linear-gradient(135deg, #082449, #0f4d94); }
.login-presentation-content { width: 100%; max-width: 660px; }
.presentation-brand { width: 66px; height: 66px; display: flex; align-items: center; justify-content: center; margin-bottom: 32px; border: 1px solid rgba(255,255,255,.28); border-radius: 18px; background: rgba(255,255,255,.12); backdrop-filter: blur(10px); font-size: 21px; font-weight: 800; }
.presentation-brand img { width: 54px; height: 54px; object-fit: contain; }
.login-presentation .eyebrow { color: #8fc3ff !important; }
.login-presentation h1 { margin: 8px 0 12px; font-size: clamp(42px, 7vw, 76px); letter-spacing: -3px; }
.login-presentation > div > p:not(.eyebrow) { max-width: 520px; color: rgba(255,255,255,.72); font-size: 18px; }
.login-feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 40px; }
.login-feature-grid div { padding: 15px; border: 1px solid rgba(255,255,255,.15); border-radius: 13px; background: rgba(255,255,255,.07); }
.login-feature-grid strong, .login-feature-grid span { display: block; }
.login-feature-grid span { margin-top: 5px; color: rgba(255,255,255,.65); font-size: 11px; line-height: 1.4; }
.login-form-side { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 34px; background: #f8fafc; }
.login-card-modern { width: 100%; max-width: 440px; padding: 32px; background: #fff; border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-md); }
.login-card-header { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.login-card-header h2 { margin: 0; color: var(--navy-900); font-size: 25px; }
.login-card-header p { margin: 4px 0 0; color: var(--text-muted); }
.login-mini-logo { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; border-radius: 12px; color: #fff; background: var(--navy-900); font-weight: 800; }
.modern-login-form { display: grid; gap: 15px; }
.modern-login-form label { display: grid; gap: 6px; color: #4a5c72; font-size: 12px; font-weight: 700; }
.modern-login-form input { min-height: 44px; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 9px; outline: none; }
.modern-login-form input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(38,121,216,.12); }
.login-help { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.login-footer-text { margin-top: 18px; color: #7f8c9e; font-size: 11px; }

.sidebar-count-badge { position: absolute; right: 10px; min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; border-radius: 999px; color: #fff; background: #e14b45; font-size: 10px; font-weight: 800; box-shadow: 0 0 0 3px rgba(225,75,69,.14); }
.sidebar-collapsed .sidebar-count-badge { right: 5px; top: 4px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 9px; }
