/*
 * Aylık Gelir Gider — arayüz stilleri.
 * Eski tek dosyalık sürümün görünümü korunmuştur.
 */

:root {
  --ink: #17212b;
  --muted: #657181;
  --line: #d9e1e8;
  --panel: #ffffff;
  --soft: #f5f7f8;
  --blue: #1665d8;
  --green: #1f8a5b;
  --red: #c54747;
  --amber: #b76b18;
  --teal: #0d7f85;
  --shadow: 0 12px 30px rgba(23, 33, 43, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f1f4f6;
  letter-spacing: 0;
}
button, input, select { font: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 34px;
  border-radius: 7px;
  padding: 7px 10px;
  cursor: pointer;
}
button:hover { border-color: #b9c8d4; }
button.primary { background: var(--blue); color: white; border-color: var(--blue); }
button.danger { color: var(--red); }
input, select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 7px;
  padding: 7px 9px;
  color: var(--ink);
}
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--green); }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 650; }
.app { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(241, 244, 246, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 16px;
  align-items: center;
}
.brand h1 { margin: 0; font-size: 22px; line-height: 1.1; }
.brand .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.month-tools {
  display: grid;
  grid-template-columns: 38px 180px 38px auto auto;
  gap: 8px;
  align-items: center;
}
.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
}
.side {
  display: grid;
  gap: 12px;
  align-content: start;
}
.nav {
  display: grid;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  box-shadow: var(--shadow);
}
.nav button {
  text-align: left;
  border-color: transparent;
  background: transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav button.active { background: #eaf2ff; color: #0f54b5; }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line);
  flex: 0 0 auto;
}
.nav button.active .dot { background: var(--blue); }
.mini-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
}
.mini-panel h3 { margin: 0; font-size: 13px; }
.metric-small {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.metric-small strong { color: var(--ink); font-size: 13px; }
.content { display: grid; gap: 18px; min-width: 0; }
.dashboard {
  display: grid;
  gap: 14px;
}
.kpi-group {
  display: grid;
  gap: 12px;
}
.kpi-group.plan {
  grid-template-columns: repeat(5, minmax(145px, 1fr));
}
.kpi-group.real {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
  min-height: 104px;
  display: grid;
  align-content: space-between;
  gap: 10px;
}
.kpi span { color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi strong { font-size: clamp(18px, 2vw, 25px); line-height: 1; white-space: nowrap; }
.kpi .bar {
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.kpi .bar i { display: block; height: 100%; width: var(--w, 0%); background: var(--blue); }
.kpi.income .bar i { background: var(--green); }
.kpi.expense .bar i { background: var(--red); }
.kpi.card .bar i { background: var(--amber); }
.kpi.net strong.negative { color: var(--red); }
.kpi.net strong.positive { color: var(--green); }
.kpi.cash .bar i { background: var(--teal); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel.income-panel {
  border-color: #b9dccb;
  background: #fbfffc;
}
.panel.income-panel .panel-head,
.panel.income-panel th,
.panel.income-panel tfoot td,
.panel.income-panel .grid-form {
  background: #eef8f2;
}
.panel.income-panel .panel-head {
  border-bottom-color: #b9dccb;
}
.panel.income-panel h2 {
  color: #17613f;
}
.panel.expense-panel {
  border-color: #efc4c4;
  background: #fffcfc;
}
.panel.expense-panel .panel-head,
.panel.expense-panel th,
.panel.expense-panel tfoot td,
.panel.expense-panel .grid-form {
  background: #fff0f0;
}
.panel.expense-panel .panel-head {
  border-bottom-color: #efc4c4;
}
.panel.expense-panel h2 {
  color: #9d3030;
}
.panel-head {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  background: white;
}
table.summary-table {
  min-width: 0;
  table-layout: fixed;
}
th, td {
  border-bottom: 1px solid #edf1f4;
  padding: 9px;
  vertical-align: middle;
  text-align: left;
  font-size: 13px;
}
th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #fbfcfd;
  position: sticky;
  top: 0;
  z-index: 1;
}
td.amount, th.amount { text-align: right; }
tfoot td {
  background: #f7faf9;
  font-weight: 800;
  border-top: 1px solid var(--line);
}
.status-pill {
  display: inline-grid;
  place-items: center;
  min-width: 78px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 750;
  background: #f8e9e9;
  color: var(--red);
}
.status-pill.ok { background: #e8f5ee; color: var(--green); }
.grid-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
  padding: 14px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.grid-form .wide { grid-column: span 2; }
.grid-form .actions { align-self: end; display: flex; gap: 8px; }
.hidden { display: none !important; }
.section { display: none; }
.section.active { display: grid; gap: 18px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}
.summary-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  padding: 14px;
  background: #fbfcfd;
  border-top: 1px solid var(--line);
}
.summary-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
}
.summary-box span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.summary-box strong { display: block; margin-top: 7px; font-size: 20px; }
.notice {
  border-left: 4px solid var(--teal);
  background: #eef8f8;
  color: #17484c;
  padding: 11px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.cash-alert {
  border-left-color: var(--red);
  background: #fff0f0;
  color: #7d2b2b;
}
.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.compact-input { max-width: 120px; margin-left: auto; }
.pay-cell {
  display: grid;
  grid-template-columns: 22px minmax(92px, 1fr);
  gap: 8px;
  align-items: center;
}
.due-soon { color: var(--amber); font-weight: 800; }
.overdue { color: var(--red); font-weight: 800; }
.ok-text { color: var(--green); font-weight: 800; }
.text-cell { color: var(--ink); font-weight: 650; }
.muted-cell { color: var(--muted); }
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 43, .42);
}
.modal.open { display: grid; }
.modal-card {
  width: min(820px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 26px 70px rgba(23, 33, 43, .28);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.scope-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 14px;
}
.scope-options label {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.scope-options input { width: 16px; min-height: 16px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
}

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .side { grid-template-columns: 1fr; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-group.plan, .kpi-group.real { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .summary-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar-inner { grid-template-columns: 1fr; }
  .month-tools { grid-template-columns: 38px 1fr 38px; }
  .shell { padding: 12px; }
  .nav { grid-template-columns: 1fr 1fr; }
  .kpi-group.plan, .kpi-group.real, .summary-row { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .grid-form .wide { grid-column: span 2; }
}

/* --- Rails sürümü için ek stiller --------------------------------------- */

/* Bağlantıları buton görünümüne getir (eski sürümde hepsi <button> idi) */
.month-tools a,
.panel-actions a,
.row-actions a,
.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 34px;
  border-radius: 7px;
  padding: 7px 10px;
  text-decoration: none;
  cursor: pointer;
}
.month-tools a:hover,
.panel-actions a:hover,
.row-actions a:hover,
.nav a:hover { border-color: #b9c8d4; }
.panel-actions a.primary { background: var(--blue); color: white; border-color: var(--blue); }
.nav a {
  text-align: left;
  justify-content: space-between;
  border-color: transparent;
  background: transparent;
}
.nav a.active { background: #eaf2ff; color: #0f54b5; }
.nav a.active .dot { background: var(--blue); }

/* button_to bir <form> üretir; ızgara içinde tam genişlik kaplasın */
form.button_to { display: contents; }
form.button_to button { width: 100%; }
.month-tools form { margin: 0; }
.month-tools input[type="month"] { min-width: 0; }

/* Satır içi düzenleme formları */
.row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input, .inline-form select { min-width: 90px; }
td.actions { white-space: nowrap; }

/* Formlar */
.form-panel { display: grid; gap: 14px; }
.form-errors {
  background: #fdecec;
  border: 1px solid #f2c2c2;
  color: var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.form-errors ul { margin: 6px 0 0; padding-left: 18px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Giriş ekranı */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 26px;
  display: grid;
  gap: 16px;
}
.auth-card h1 { margin: 0; font-size: 20px; }
.auth-card .sub { color: var(--muted); font-size: 13px; }
.auth-card .field { display: grid; gap: 6px; }
.auth-card .remember { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.auth-card .remember input { width: 18px; }
.auth-links { display: flex; justify-content: space-between; font-size: 13px; }
.auth-links a { color: var(--blue); }

/* Bildirimler */
.notice {
  background: #e8f5ee;
  border: 1px solid #bfe3ce;
  color: var(--green);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}
.notice.cash-alert { background: #fdecec; border-color: #f2c2c2; color: var(--red); }

/* input[type=submit] de buton gibi görünsün */
input[type="submit"] {
  width: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 34px;
  border-radius: 7px;
  padding: 7px 14px;
  cursor: pointer;
}
input[type="submit"]:hover { border-color: #b9c8d4; }
input[type="submit"].primary { background: var(--blue); color: white; border-color: var(--blue); }
.auth-card input[type="submit"] { width: 100%; }

/* Kenar çubuğundaki bağlantılar da buton görünümünde */
.mini-panel a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 34px;
  border-radius: 7px;
  padding: 7px 10px;
  text-decoration: none;
}
.mini-panel a:hover { border-color: #b9c8d4; }

/* --- Faz 2: sadeleştirilmiş hesap kartları ------------------------------ */

.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 14px 16px;
}
.balance-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 14px;
  display: grid;
  gap: 4px;
  align-content: start;
}
.balance-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.balance-name { font-size: 13px; font-weight: 650; color: var(--muted); }
.balance-amount { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.balance-local { font-size: 13px; color: var(--muted); }
.balance-updated { font-size: 11px; color: var(--muted); }
.balance-detail { margin-top: 8px; }
.balance-detail summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  color: var(--blue);
  list-style: none;
}
.balance-detail summary::-webkit-details-marker { display: none; }
.balance-detail summary::before { content: "▸ "; }
.balance-detail[open] summary::before { content: "▾ "; }
.balance-detail[open] { border-top: 1px solid var(--line); padding-top: 8px; }
.balance-detail .metric-small { font-size: 12px; }
.balance-detail-all { padding: 0 16px 14px; }
.balance-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--soft);
  font-size: 13px;
  color: var(--muted);
}
.balance-total strong { font-size: 20px; color: var(--ink); }

/* --- Faz 3: harcama defteri -------------------------------------------- */

.expenses-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.expense-summary { display: grid; gap: 16px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}
.filter-bar label { min-width: 130px; }
.filter-bar a { align-self: center; font-size: 13px; color: var(--blue); }

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.bulk-bar select { width: auto; min-width: 170px; }
.bulk-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.bulk-check input { width: 18px; }

.inline-form select { min-width: 140px; font-size: 13px; }
select.needs-category { border-color: var(--amber); background: #fff8ef; }

.category-chart { display: grid; gap: 12px; padding: 14px 16px; }
.category-row { display: grid; gap: 4px; }
.category-label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.category-label span:nth-child(2) { flex: 1; }
.category-amount { font-weight: 650; }
.category-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.category-bar {
  height: 7px;
  border-radius: 4px;
  background: var(--soft);
  overflow: hidden;
}
.category-bar i { display: block; height: 100%; border-radius: 4px; }
.category-meta { font-size: 11px; color: var(--muted); }
.category-meta .positive { color: var(--green); }
.category-meta .negative { color: var(--red); }

.subscription-total { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
td .sub { display: block; font-size: 11px; color: var(--muted); }

@media (max-width: 1100px) {
  .expenses-layout { grid-template-columns: 1fr; }
}
