:root {
  --bg: #0b0f14;
  --panel: #111823;
  --panel-2: #16202d;
  --border: #1f2b3a;
  --text: #e7eef7;
  --muted: #8b9aab;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, .14);
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover { background: #1c2839; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: #3f7bf0; }
button.ghost { background: transparent; }
button.danger { color: #ffb4b4; border-color: rgba(239, 68, 68, .4); }
button.danger:hover { background: rgba(239, 68, 68, .12); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], textarea, select {
  width: 100%;
  background: #0e1620;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 72px; }

.hidden { display: none !important; }

/* ---------- Giriş ekranı ---------- */

.auth-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(79, 140, 255, .18), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(34, 197, 94, .12), transparent 60%),
    var(--bg);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #22c55e);
  display: grid; place-items: center; font-weight: 800; color: #08111d;
}
.brand h1 { font-size: 19px; margin: 0; letter-spacing: .2px; }
.auth-sub { color: var(--muted); margin: 6px 0 18px; font-size: 13.5px; }

.tabs { display: flex; gap: 6px; background: #0e1620; padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.tabs button { flex: 1; background: transparent; border: 0; color: var(--muted); padding: 8px; border-radius: 9px; }
.tabs button.active { background: var(--panel-2); color: var(--text); font-weight: 600; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.form-error { color: #ffb4b4; font-size: 13px; min-height: 18px; margin: 4px 0 10px; }

/* ---------- Uygulama ---------- */

.app { display: grid; grid-template-columns: 268px 1fr; height: 100%; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-top { padding: 16px 16px 10px; }
.side-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.side-user .who { min-width: 0; }
.side-user .who b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.side-scroll { overflow: auto; padding: 6px 10px 10px; flex: 1; min-height: 0; }
.side-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted);
  margin: 14px 8px 8px; display: flex; justify-content: space-between; align-items: center;
}

.list-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent;
}
.list-row:hover { background: #16202d; }
.list-row.active { background: var(--accent-soft); border-color: rgba(79, 140, 255, .35); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.list-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.list-row .count { font-size: 11.5px; color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(17, 24, 35, .9), rgba(17, 24, 35, .6));
  backdrop-filter: blur(6px);
  flex-wrap: wrap;
}
.topbar h2 { margin: 0; font-size: 17px; flex: 1; min-width: 120px; }
.search { position: relative; width: min(280px, 100%); }
.search input { padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); opacity: .5; }

.chips { display: flex; gap: 6px; padding: 12px 20px 0; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px;
}
.chip.active { background: var(--accent-soft); border-color: rgba(79, 140, 255, .45); color: #cfe0ff; }

.content { padding: 14px 20px 40px; overflow: auto; flex: 1; min-height: 0; }

.composer {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 10px 0 16px;
}
.composer .row2 { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.composer .row2 input[type="date"] { width: 160px; }
.composer .row2 select { width: 150px; }

.task {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.task:hover { border-color: #27405c; }
.task .check {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid #38506b;
  background: transparent; padding: 0; display: grid; place-items: center; flex: 0 0 auto; margin-top: 2px;
}
.task .check:hover { border-color: var(--accent); }
.task.done .check { background: var(--ok); border-color: var(--ok); color: #04140a; font-weight: 800; }
.task .body { flex: 1; min-width: 0; }
.task .title { font-size: 14.5px; overflow-wrap: anywhere; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task .notes { font-size: 12.5px; color: var(--muted); margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.task .meta { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); background: #0e1620;
}
.badge.p3 { color: #ffc9c9; border-color: rgba(239, 68, 68, .45); background: rgba(239, 68, 68, .12); }
.badge.p2 { color: #ffe1ad; border-color: rgba(245, 158, 11, .45); background: rgba(245, 158, 11, .12); }
.badge.p1 { color: #bcd4ff; border-color: rgba(79, 140, 255, .45); background: var(--accent-soft); }
.badge.overdue { color: #ffc9c9; border-color: rgba(239, 68, 68, .5); background: rgba(239, 68, 68, .14); }
.task .actions { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.task:hover .actions, .task:focus-within .actions { opacity: 1; }
.task .actions button { padding: 5px 9px; font-size: 12px; }

.empty { color: var(--muted); text-align: center; padding: 40px 10px; font-size: 14px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1b2432; border: 1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; font-size: 13.5px;
}
.toast.err { border-color: rgba(239, 68, 68, .5); color: #ffc3c3; }

.footer-note { color: var(--muted); font-size: 11.5px; padding: 10px 20px 18px; }

/* ---------- Mobil ---------- */

.menu-btn { display: none; }

@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 82%; max-width: 320px; z-index: 40;
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 12px 14px 32px; }
  .topbar { padding: 12px 14px; }
  .chips { padding: 10px 14px 0; }
  .composer .row2 input[type="date"], .composer .row2 select { width: 100%; }
  .search { width: 100%; order: 3; }
}

/* ---------- Sekmeler ---------- */
.tabs-inline { display: flex; gap: 4px; background: #0e1620; padding: 4px; border-radius: 12px; }
.tabs-inline .tab { background: transparent; border: 0; color: var(--muted); padding: 6px 12px; border-radius: 9px; font-size: 13px; }
.tabs-inline .tab.active { background: var(--panel-2); color: var(--text); font-weight: 600; }

/* ---------- Sohbet ---------- */
.chat-wrap { display: flex; flex-direction: column; height: calc(100dvh - 74px); min-height: 0; }
.chat-list { flex: 1; overflow-y: auto; padding: 18px 20px 8px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: min(640px, 86%); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 9px 13px; }
.msg.mine { align-self: flex-end; background: var(--accent-soft); border-color: rgba(79,140,255,.35); }
.msg.ai { align-self: flex-start; background: #101a26; border-color: #20303f; }
.msg.thinking { opacity: .65; font-style: italic; }
.msg-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 3px; }
.msg-head b { font-size: 12.5px; color: #cfe0ff; }
.msg-time { font-size: 10.5px; color: var(--muted); }
.msg-body { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 8px; padding: 10px 20px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-form textarea { flex: 1; min-height: 44px; max-height: 140px; resize: none; }
.chat-hint { font-size: 11.5px; color: var(--muted); padding: 0 20px 14px; }

/* ---------- Bütçe ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.stat-k { font-size: 11.5px; color: var(--muted); }
.stat-v { font-size: 18px; }
.stat-v.ok { color: #7ee2a8; }
.stat-v.danger { color: #ffb4b4; }
.budget-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.budget-form input, .budget-form select { width: auto; min-width: 130px; flex: 1; }
.budget-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 7px; background: var(--panel); }
.btype { font-size: 10.5px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); }
.btype.income { color: #7ee2a8; border-color: rgba(34,197,94,.4); }
.btype.expense { color: #ffb4b4; border-color: rgba(239,68,68,.4); }
.bbody { flex: 1; min-width: 0; }
.btitle { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bmeta { font-size: 11px; color: var(--muted); }
.bamount { font-size: 13.5px; white-space: nowrap; }
.bamount.income { color: #7ee2a8; }
.bamount.expense { color: #ffd0d0; }

/* ---------- Aile ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.invite-row { display: flex; gap: 10px; align-items: center; }
.invite-row code { font-size: 20px; letter-spacing: 3px; background: #0e1620; border: 1px dashed var(--border); border-radius: 10px; padding: 8px 14px; }
.member { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.member:last-child { border-bottom: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: #cfe0ff; display: grid; place-items: center; font-weight: 700; }
.muted-sm { font-size: 11.5px; color: var(--muted); margin: 0 0 10px; }

@media (max-width: 780px) {
  .stats { grid-template-columns: 1fr; }
  .tabs-inline { order: 4; width: 100%; justify-content: space-between; }
  .chat-list { padding: 12px 14px 8px; }
  .chat-form { padding: 8px 14px; }
}
