:root {
  --navy: #0b4b6b;
  --navy-deep: #08384f;
  --green: #159659;
  --green-soft: #e7f7ef;
  --orange: #ff9b1a;
  --orange-soft: #fff3df;
  --ink: #173042;
  --muted: #667987;
  --line: #dce5ea;
  --bg: #f4f7f9;
  --card: #ffffff;
  --danger: #b52f3a;
  --danger-soft: #fdebed;
  --warning: #9a6112;
  --warning-soft: #fff4db;
  --shadow: 0 14px 35px rgba(20, 53, 71, .08);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #073b55 0%, #0b4b6b 67%, #0d5b77 100%);
  color: #fff;
  padding: 20px 16px;
  overflow: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px 20px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand img { width: 54px; height: 54px; border-radius: 14px; object-fit: cover; background: #fff; }
.brand strong { display: block; font-size: 1.02rem; letter-spacing: .01em; }
.brand span { display: block; margin-top: 2px; color: rgba(255,255,255,.72); font-size: .78rem; }
.nav { display: grid; gap: 6px; margin-top: 18px; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; color: rgba(255,255,255,.82);
  background: transparent; border-radius: 12px; padding: 11px 12px; text-align: left; transition: .18s ease;
}
.nav button:hover, .nav button.active { color: #fff; background: rgba(255,255,255,.12); transform: translateX(2px); }
.nav-icon { width: 22px; text-align: center; font-size: 1.05rem; }
.sidebar-spacer { flex: 1; }
.demo-badge { margin: 16px 5px 6px; padding: 12px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); border-radius: 14px; font-size: .78rem; color: rgba(255,255,255,.85); }
.demo-badge strong { display: block; color: #fff; margin-bottom: 3px; }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 8; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 76px; padding: 14px 28px; background: rgba(244,247,249,.91); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(220,229,234,.85);
}
.page-title h1 { margin: 0; font-size: clamp(1.3rem, 2vw, 1.75rem); }
.page-title p { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.company-chip { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: #fff; border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 6px 16px rgba(25,54,70,.05); }
.company-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: var(--green); font-weight: 800; }
.company-chip strong { display: block; font-size: .82rem; }
.company-chip span { display: block; color: var(--muted); font-size: .72rem; }
.menu-toggle { display: none; }

.content { padding: 24px 28px 48px; max-width: 1540px; margin: 0 auto; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 1.12rem; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.grid { display: grid; gap: 16px; }
.grid-5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(300px, .85fr); }
.card { background: var(--card); border: 1px solid rgba(220,229,234,.9); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.metric { padding: 18px; min-height: 130px; position: relative; overflow: hidden; }
.metric::after { content: ""; position: absolute; right: -24px; bottom: -32px; width: 88px; height: 88px; border-radius: 50%; background: rgba(13,79,107,.06); }
.metric-label { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .8rem; }
.metric-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px; background: #edf4f7; color: var(--navy); }
.metric-value { margin-top: 13px; font-size: clamp(1.2rem, 1.8vw, 1.65rem); font-weight: 800; letter-spacing: -.02em; }
.metric-note { margin-top: 4px; color: var(--muted); font-size: .75rem; }
.metric-note.good { color: var(--green); }
.metric-note.bad { color: var(--danger); }

.btn { border: 1px solid transparent; border-radius: 11px; padding: 9px 13px; font-weight: 700; font-size: .84rem; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 7px 16px rgba(23,48,66,.10); }
.btn-primary { color: #fff; background: var(--navy); }
.btn-success { color: #fff; background: var(--green); }
.btn-outline { color: var(--navy); background: #fff; border-color: var(--line); }
.btn-ghost { color: var(--muted); background: transparent; }
.btn-danger { color: var(--danger); background: var(--danger-soft); }
.btn-sm { padding: 6px 9px; font-size: .75rem; border-radius: 9px; }
.icon-btn { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 11px; border: 1px solid var(--line); background: #fff; color: var(--navy); }

.table-wrap { overflow: auto; border-radius: 14px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 680px; background: #fff; }
th, td { padding: 12px 13px; border-bottom: 1px solid #e8eef1; text-align: left; font-size: .82rem; vertical-align: middle; }
th { color: var(--muted); font-weight: 750; background: #f8fafb; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfcfd; }
.amount-positive { color: var(--green); font-weight: 800; }
.amount-negative { color: var(--danger); font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
.tiny { font-size: .7rem; }
.right { text-align: right; }
.center { text-align: center; }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 8px; font-size: .7rem; font-weight: 800; white-space: nowrap; }
.badge-good { color: #0f6b43; background: var(--green-soft); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-neutral { color: #526570; background: #edf2f5; }
.badge-blue { color: var(--navy); background: #eaf3f8; }

.alert-list { display: grid; gap: 10px; }
.alert { display: flex; gap: 11px; padding: 13px; border-radius: 13px; background: #f7fafb; border: 1px solid var(--line); }
.alert-icon { flex: 0 0 auto; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--orange-soft); }
.alert strong { display: block; font-size: .82rem; }
.alert p { margin: 3px 0 0; color: var(--muted); font-size: .75rem; }

.chart { height: 260px; display: flex; flex-direction: column; }
.chart-bars { flex: 1; display: flex; align-items: end; gap: 10px; padding: 8px 4px 0; border-bottom: 1px solid var(--line); }
.chart-month { flex: 1; display: flex; align-items: end; justify-content: center; gap: 4px; height: 100%; min-width: 34px; }
.bar { width: 40%; min-height: 3px; border-radius: 7px 7px 2px 2px; position: relative; transition: height .25s ease; }
.bar:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: .66rem; white-space: nowrap; padding: 4px 6px; border-radius: 6px; z-index: 3; }
.bar-income { background: var(--green); }
.bar-expense { background: var(--orange); }
.chart-labels { display: flex; gap: 10px; padding: 8px 4px 0; color: var(--muted); font-size: .67rem; }
.chart-labels span { flex: 1; min-width: 34px; text-align: center; }
.legend { display: flex; gap: 14px; margin-top: 13px; color: var(--muted); font-size: .72rem; }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 3px; }
.legend .income::before { background: var(--green); }
.legend .expense::before { background: var(--orange); }

.progress { height: 9px; overflow: hidden; border-radius: 999px; background: #e8eff2; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.progress.orange > span { background: var(--orange); }
.progress.danger > span { background: var(--danger); }
.progress-row { margin-top: 13px; }
.progress-meta { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: .73rem; color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 13px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label { color: #425967; font-weight: 720; font-size: .76rem; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 10px 11px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: #68a3bd; box-shadow: 0 0 0 3px rgba(13,79,107,.10); }
textarea { min-height: 100px; resize: vertical; }
.input-help { color: var(--muted); font-size: .68rem; }

.factor-hero { display: grid; grid-template-columns: 160px 1fr; gap: 22px; align-items: center; }
.factor-gauge { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; position: relative; background: conic-gradient(var(--green) var(--gauge), #e6edf0 0); }
.factor-gauge::before { content: ""; width: 112px; height: 112px; border-radius: 50%; background: #fff; position: absolute; }
.factor-gauge-content { position: relative; z-index: 1; text-align: center; }
.factor-gauge-content strong { display: block; font-size: 1.65rem; }
.factor-gauge-content span { color: var(--muted); font-size: .7rem; }
.factor-summary h3 { margin: 0 0 5px; font-size: 1.12rem; }
.factor-summary p { margin: 0; color: var(--muted); font-size: .82rem; }
.kpi-line { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 15px; }
.kpi-line div { min-width: 110px; }
.kpi-line span { display: block; color: var(--muted); font-size: .68rem; }
.kpi-line strong { display: block; margin-top: 2px; font-size: .9rem; }

.chat-layout { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 16px; }
.chat-card { min-height: 620px; display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.chat-head strong { display: block; }
.chat-head span { color: var(--muted); font-size: .73rem; }
.chat-messages { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 18px; overflow-y: auto; background: linear-gradient(180deg, #f9fbfc, #f4f8fa); }
.message { max-width: min(78%, 690px); border-radius: 16px; padding: 10px 12px; font-size: .82rem; white-space: pre-wrap; }
.message.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.message.user { align-self: flex-end; color: #fff; background: var(--navy); border-bottom-right-radius: 4px; }
.message small { display: block; opacity: .65; margin-top: 4px; font-size: .62rem; }
.chat-input { display: flex; gap: 9px; padding: 14px; border-top: 1px solid var(--line); background: #fff; }
.chat-input input { flex: 1; }
.quick-list { display: grid; gap: 8px; }
.quick-command { border: 1px solid var(--line); background: #fff; border-radius: 11px; padding: 10px; text-align: left; font-size: .75rem; color: var(--ink); }
.quick-command:hover { border-color: #9abac8; background: #f8fbfc; }

.plan-card { padding: 18px; position: relative; overflow: hidden; }
.plan-card.featured { border: 2px solid var(--green); }
.plan-card h3 { margin: 0; }
.plan-price { margin: 12px 0 4px; font-size: 1.7rem; font-weight: 850; }
.plan-price span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.plan-card ul { padding-left: 18px; margin: 14px 0 0; color: var(--muted); font-size: .78rem; }
.plan-card li { margin: 6px 0; }
.ribbon { position: absolute; top: 13px; right: -31px; transform: rotate(35deg); width: 120px; text-align: center; padding: 5px; color: #fff; background: var(--green); font-size: .63rem; font-weight: 800; }

.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 15px; background: #edf3f6; font-size: 1.25rem; }

.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; background: rgba(8,32,45,.48); backdrop-filter: blur(3px); }
.modal { width: min(640px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 20px; box-shadow: 0 30px 70px rgba(5,30,43,.28); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #f9fbfc; border-radius: 0 0 20px 20px; }
.close { border: 0; background: transparent; font-size: 1.2rem; color: var(--muted); }

.toast { position: fixed; z-index: 60; right: 22px; bottom: 22px; max-width: 380px; transform: translateY(130px); opacity: 0; padding: 13px 15px; color: #fff; background: var(--ink); border-radius: 13px; box-shadow: 0 15px 35px rgba(0,0,0,.18); transition: .25s ease; font-size: .82rem; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.good { background: var(--green); }
.toast.bad { background: var(--danger); }

.callout { padding: 14px 16px; border-radius: 14px; border: 1px solid #d6e6ed; background: #edf6fa; color: #27566a; font-size: .78rem; }
.callout.warning { border-color: #eed9a9; background: var(--warning-soft); color: #76531b; }
.callout.danger { border-color: #f2c8ce; background: var(--danger-soft); color: #7f2630; }
.callout strong { display: block; margin-bottom: 3px; }

.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin-top: 16px; }
.stat-box { padding: 12px; border-radius: 13px; background: #f6f9fa; border: 1px solid var(--line); }
.stat-box span { display: block; color: var(--muted); font-size: .68rem; }
.stat-box strong { display: block; margin-top: 3px; font-size: .95rem; }

.split-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.money-flow { display: grid; gap: 9px; }
.flow-step { display: grid; grid-template-columns: 35px 1fr auto; align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; }
.flow-num { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #eaf3f7; color: var(--navy); font-weight: 800; }
.flow-step strong { display: block; font-size: .8rem; }
.flow-step span { display: block; color: var(--muted); font-size: .69rem; }

.switch-row { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row strong { display: block; font-size: .82rem; }
.switch-row span { display: block; margin-top: 2px; color: var(--muted); font-size: .7rem; }
.switch { position: relative; width: 45px; height: 25px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; border-radius: 999px; background: #cbd7dc; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 19px; height: 19px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.18); transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.2fr .8fr; background: #fff; }
.login-visual { padding: 60px; color: #fff; background: linear-gradient(145deg, #08384f, #0d5b77 62%, #148651); position: relative; overflow: hidden; }
.login-visual::before, .login-visual::after { content: ""; position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.13); }
.login-visual::before { width: 520px; height: 520px; left: -170px; bottom: -270px; }
.login-visual::after { width: 420px; height: 420px; right: -160px; top: -150px; }
.login-brand { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.login-brand img { width: 74px; height: 74px; object-fit: cover; border-radius: 18px; background: #fff; }
.login-brand strong { font-size: 1.3rem; }
.login-hero { max-width: 620px; margin-top: 90px; position: relative; z-index: 1; }
.login-hero h1 { margin: 0 0 16px; font-size: clamp(2.1rem, 5vw, 4rem); line-height: 1.06; letter-spacing: -.04em; }
.login-hero p { margin: 0; color: rgba(255,255,255,.82); font-size: 1.06rem; }
.login-points { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 30px; }
.login-points div { padding: 12px; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.15); border-radius: 13px; font-size: .78rem; }
.login-form-wrap { display: grid; place-items: center; padding: 40px; }
.login-form { width: min(420px, 100%); }
.login-form h2 { margin: 0; font-size: 1.8rem; }
.login-form > p { color: var(--muted); margin: 7px 0 24px; }
.login-form .field { margin-bottom: 13px; }
.login-form .btn { width: 100%; padding: 12px; margin-top: 4px; }
.login-note { margin-top: 16px; padding: 12px; border-radius: 12px; background: #f6f9fa; color: var(--muted); font-size: .72rem; }

@media (max-width: 1180px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-card { min-height: 540px; }
}
@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; left: 0; top: 0; width: 270px; transform: translateX(-105%); transition: .22s ease; box-shadow: 20px 0 45px rgba(3,29,42,.25); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .topbar { padding: 12px 18px; }
  .content { padding: 20px 18px 38px; }
  .grid-main, .split-panel { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-form-wrap { min-height: 100vh; }
}
@media (max-width: 680px) {
  .grid-5, .grid-4, .grid-3, .grid-2, .form-grid, .form-grid-3, .stat-row { grid-template-columns: 1fr; }
  .company-chip { display: none; }
  .factor-hero { grid-template-columns: 1fr; text-align: center; }
  .factor-gauge { margin: 0 auto; }
  .kpi-line { justify-content: center; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .message { max-width: 91%; }
  .content { padding-left: 12px; padding-right: 12px; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .modal-backdrop { padding: 8px; }
}
