:root {
  --bg: #0b0d12; --panel: #151922; --panel2: #1d2230; --line: #2a3040;
  --text: #eef1f7; --muted: #8a93a8; --accent: #5b8cff; --accent2: #a46bff;
  --green: #3ad29f; --red: #ff6b6b; --amber: #ffb547;
  --safe-b: env(safe-area-inset-bottom); --safe-t: env(safe-area-inset-top);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 1.2em; font-size: 14px; }
h2 { margin: 0; font-size: 28px; letter-spacing: -.5px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 4px 8px; }

input, button { font: inherit; color: inherit; }
input {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; outline: none; min-width: 0;
}
input:focus { border-color: var(--accent); }
input[type=date] { color-scheme: dark; }
.btn { width: 100%; padding: 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); font-weight: 600; font-size: 16px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: 0; }
.btn.ghost { background: transparent; color: var(--muted); margin-top: 10px; }
.icon-btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; text-decoration: none; font-size: 16px; }
.icon-btn.off { opacity: .4; }

/* login */
.screen { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-box h1 { margin: 18px 0 4px; font-size: 34px; }
.login-box form { display: grid; gap: 12px; margin-top: 28px; }

/* layout */
#app { height: 100%; display: flex; flex-direction: column; }
.tab { display: none; flex: 1; flex-direction: column; min-height: 0; }
.tab.active { display: flex; }
.top { display: flex; justify-content: space-between; align-items: center; padding: calc(var(--safe-t) + 14px) 18px 10px; }
.scroll { flex: 1; overflow-y: auto; padding: 0 16px 24px; -webkit-overflow-scrolling: touch; }

/* chat */
.messages { flex: 1; overflow-y: auto; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 18px; line-height: 1.4; font-size: 16px; white-space: pre-wrap; word-wrap: break-word; animation: pop .2s ease; }
.msg.user { align-self: flex-end; background: var(--accent); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--panel2); border-bottom-left-radius: 6px; }
.msg.typing { color: var(--muted); }
.chip { align-self: flex-start; font-size: 12px; color: var(--green); background: rgba(58,210,159,.1); border: 1px solid rgba(58,210,159,.25); padding: 4px 10px; border-radius: 999px; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 20px; }
.empty .orb { margin: 0 auto 18px; }
.empty p { margin: 6px 0; }
.empty .hint { font-size: 14px; color: #6d768b; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }

.composer { padding: 8px 12px 10px; border-top: 1px solid var(--line); background: var(--bg); }
#chatForm { display: flex; gap: 8px; align-items: center; }
#chatForm input { border-radius: 999px; }
.mic, .send { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; }
.mic { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.mic.on { background: var(--red); animation: pulse 1.2s infinite; }
.send { background: var(--panel2); font-size: 20px; font-weight: 700; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255,107,107,.15); } }

.listening { text-align: center; padding: 10px 0 14px; }
.listening p { margin: 10px 0 0; color: var(--muted); min-height: 1.3em; }
.orb {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto;
  background: conic-gradient(from 0deg, #5b8cff, #a46bff, #ff6bd5, #3ad2c9, #5b8cff);
  filter: blur(.5px); animation: spin 3s linear infinite, breathe 1.6s ease-in-out infinite;
  box-shadow: 0 0 40px rgba(124,107,255,.45);
}
.orb.small { width: 72px; height: 72px; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { scale: 1.12; } }

/* cards */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat small { color: var(--muted); font-size: 12px; }
.stat b { display: block; font-size: 16px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos { color: var(--green); } .neg { color: var(--red); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.form { display: grid; gap: 10px; margin-bottom: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel2); border-radius: 12px; padding: 3px; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 8px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.seg input:checked + span { background: var(--line); color: var(--text); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.list .meta { flex: 1; min-width: 0; }
.list .meta b { display: block; text-transform: capitalize; }
.list .meta small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .amt { font-weight: 600; white-space: nowrap; }
.del { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 4px 6px; }
.day { font-size: 12px; color: var(--muted); padding: 14px 4px 2px; text-transform: uppercase; letter-spacing: .06em; list-style: none; border: 0 !important; }

.bar-item { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.bar-item .head { display: flex; justify-content: space-between; font-size: 15px; }
.bar-item .head b { text-transform: capitalize; }
.bar-item small { color: var(--muted); }
.bar { height: 8px; background: var(--panel2); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--green); }
.bar i.warn { background: var(--amber); } .bar i.over { background: var(--red); }

/* tabbar */
.tabbar { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: rgba(11,13,18,.92); backdrop-filter: blur(20px); padding-bottom: var(--safe-b); }
.tabbar button { background: none; border: 0; color: var(--muted); padding: 8px 0 6px; font-size: 11px; display: grid; gap: 2px; justify-items: center; }
.tabbar button span { font-size: 20px; }
.tabbar button.active { color: var(--accent); }

/* borçlar */
select { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 16px; color: var(--text); appearance: none; -webkit-appearance: none; }
.field { display: grid; gap: 4px; } .field small { color: var(--muted); font-size: 12px; padding-left: 4px; }
.small-line { font-size: 13px; margin: 0 4px 10px; }
.stat.alert { border-color: rgba(255,107,107,.45); background: rgba(255,107,107,.08); }
.stat em { display: block; font-style: normal; color: var(--muted); font-size: 11px; margin-top: 2px; }
.month-h { font-size: 13px; color: var(--muted); margin: 14px 4px 6px; display: flex; justify-content: space-between; }
.inst { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 6px; }
.inst .date { width: 44px; text-align: center; flex: none; line-height: 1.1; }
.inst .date b { display: block; font-size: 20px; } .inst .date small { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.inst .meta { flex: 1; min-width: 0; } .inst .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst .meta small { color: var(--muted); }
.inst .amt { font-weight: 600; white-space: nowrap; }
.inst.paid { opacity: .5; } .inst.paid .amt { text-decoration: line-through; }
.inst.late { border-color: rgba(255,107,107,.5); } .inst.late .date b { color: var(--red); }
.pay { flex: none; border: 0; border-radius: 10px; padding: 8px 12px; font-weight: 600; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.pay.done { background: var(--panel2); color: var(--green); }
.late-box { border: 1px solid rgba(255,107,107,.45); background: rgba(255,107,107,.06); border-radius: 16px; padding: 12px; margin: 6px 0 4px; }
.late-box h4 { margin: 0 0 8px; color: var(--red); font-size: 14px; }
.debt { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 8px; }
.debt summary { list-style: none; cursor: pointer; } .debt summary::-webkit-details-marker { display: none; }
.debt .head { display: flex; justify-content: space-between; gap: 10px; }
.debt .head b { font-size: 16px; } .debt .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; margin-left: 6px; vertical-align: 2px; }
.debt .sub { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.debt .bar i { background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.debt table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.debt td { padding: 7px 4px; border-top: 1px solid var(--line); } .debt td:last-child { text-align: right; }
.debt td.ok { color: var(--green); } .debt td.no { color: var(--red); }
.debt .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.debt .acts .btn { padding: 10px; font-size: 14px; margin: 0; }

/* kurtarma planı */
.rescue-btn { margin: 4px 0 12px; background: rgba(255,181,71,.1); border-color: rgba(255,181,71,.45); color: var(--amber); }
.sheet { position: fixed; inset: 0; z-index: 5; background: var(--bg); display: flex; flex-direction: column; padding-bottom: var(--safe-b); animation: up .22s ease; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.hint-line { font-size: 12px; margin: -4px 4px 0; }
.verdict { border-radius: 18px; padding: 16px; margin: 4px 0 12px; border: 1px solid var(--line); }
.verdict.no_loan { background: rgba(58,210,159,.08); border-color: rgba(58,210,159,.4); }
.verdict.loan { background: rgba(91,140,255,.09); border-color: rgba(91,140,255,.45); }
.verdict.small_gap { background: rgba(255,181,71,.08); border-color: rgba(255,181,71,.45); }
.verdict.restructure { background: rgba(255,107,107,.08); border-color: rgba(255,107,107,.45); }
.verdict h4 { margin: 0 0 10px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.verdict.no_loan h4 { color: var(--green); } .verdict.loan h4 { color: var(--accent); }
.verdict.small_gap h4 { color: var(--amber); } .verdict.restructure h4 { color: var(--red); }
.verdict p { margin: 12px 0 0; line-height: 1.45; font-size: 15px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi { background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px 12px; }
.kpi small { color: var(--muted); font-size: 12px; display: block; }
.kpi b { font-size: 20px; display: block; margin-top: 2px; white-space: nowrap; }
.kpi em { font-style: normal; color: var(--muted); font-size: 12px; }
.kpi.wide { grid-column: 1 / -1; }
.warn-list { list-style: none; padding: 0; margin: 0 0 6px; }
.warn-list li { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; font-size: 14px; line-height: 1.4; }
.scen { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.scen.best { border-color: var(--accent); }
.scen .head { display: flex; justify-content: space-between; align-items: center; }
.scen .head b { font-size: 16px; }
.badge { font-size: 11px; border-radius: 99px; padding: 2px 8px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; }
.badge.best { color: var(--accent); border-color: var(--accent); }
.badge.r-düşük { color: var(--green); border-color: rgba(58,210,159,.5); }
.badge.r-orta { color: var(--amber); border-color: rgba(255,181,71,.5); }
.badge.r-yüksek { color: var(--red); border-color: rgba(255,107,107,.5); }
.scen .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; margin-top: 8px; font-size: 14px; }
.scen .grid span { color: var(--muted); } .scen .grid span b { color: var(--text); font-weight: 600; }
.scen .why { color: var(--muted); font-size: 14px; margin-top: 6px; }
.flow { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); border-radius: 14px; overflow: hidden; }
.flow th, .flow td { padding: 8px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.flow th { color: var(--muted); font-weight: 500; font-size: 12px; } .flow th:first-child, .flow td:first-child { text-align: left; }
.flow td.neg { color: var(--red); } .flow td.pos { color: var(--green); }
.alts { padding-left: 18px; margin: 0; } .alts li { margin-bottom: 8px; line-height: 1.4; font-size: 14px; color: #c9cfdb; }

.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 12px); transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 9; }
