:root {
  --bg:        #f2f4f1;
  --surface:   #ffffff;
  --line:      #d9e0d6;
  --line-soft: #eaeee7;
  --ink:       #1c2b23;
  --ink-soft:  #63756a;
  --ink-mute:  #8d9c92;
  --brand:     #17513a;
  --brand-mid: #1e6b46;
  --brand-soft:#e5efe8;
  --red:       #a83a32;
  --red-soft:  #f7e8e6;
  --amber:     #8a6d1f;
  --amber-soft:#f5eeda;
  --blue:      #2b5f8a;
  --blue-soft: #e5eef5;
  --radius:    8px;
  --radius-sm: 5px;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --shadow: 0 1px 2px rgba(28,43,35,.05), 0 2px 8px rgba(28,43,35,.04);
  --sidebar-w: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-mid); }
[hidden] { display: none !important; }

/* ============================================================ giriş ekranı */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--bg);
  background-image: radial-gradient(circle at 25% 15%, rgba(30,107,70,.07), transparent 45%),
                    radial-gradient(circle at 80% 85%, rgba(43,95,138,.06), transparent 45%);
  overflow-y: auto;
}
.gate-box {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px 30px; width: 100%; max-width: 420px; margin: auto;
}
.gate-logo {
  display: flex; align-items: center; gap: 11px; margin-bottom: 6px;
}
.gate-logo .mark {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 19px; font-weight: 700; flex: none;
}
.gate-logo h1 { font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.gate-sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 22px; line-height: 1.6; }

/* ================================================================ formlar */
.f { margin-bottom: 14px; }
.f label {
  display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .8px; color: var(--ink-soft); margin-bottom: 5px;
}
.f input, .f select, .f textarea {
  width: 100%; font-family: var(--sans); font-size: 14px; color: var(--ink);
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); transition: border-color .12s, box-shadow .12s;
}
.f textarea { resize: vertical; min-height: 72px; }
.f input:focus, .f select:focus, .f textarea:focus {
  outline: none; border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px rgba(30,107,70,.13); background: var(--surface);
}
.f .hint { font-size: 11.5px; color: var(--ink-mute); margin-top: 4px; }
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  padding: 9px 17px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-mid); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand-mid); color: var(--brand); }
.btn-danger { background: var(--surface); color: var(--red); border-color: var(--line); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red); }
.btn-sm { font-size: 12.5px; padding: 6px 12px; }
.btn-block { width: 100%; }

.alert {
  padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13px;
  margin-bottom: 14px; line-height: 1.5; border: 1px solid transparent;
}
.alert-err  { background: var(--red-soft);   color: var(--red);   border-color: #eccbc7; }
.alert-info { background: var(--blue-soft);  color: var(--blue);  border-color: #cfe0ed; }
.alert-warn { background: var(--amber-soft); color: var(--amber); border-color: #e8dcb8; }

/* ================================================================== düzen */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sb-head {
  padding: 16px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px;
}
.sb-head .mark {
  width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: 16px; font-weight: 700; flex: none;
}
.sb-head .firm { min-width: 0; }
.sb-head .firm strong { display: block; font-size: 13.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-head .firm span { font-size: 11px; color: var(--ink-mute); }

.sb-nav { flex: 1; overflow-y: auto; padding: 10px 0 16px; }
.sb-group {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--ink-mute); padding: 14px 18px 6px;
}
.sb-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 18px; border: none; background: none; cursor: pointer;
  font-family: var(--sans); font-size: 13.5px; color: var(--ink-soft);
  text-align: left; border-left: 3px solid transparent; transition: background .1s, color .1s;
}
.sb-item:hover { background: var(--line-soft); color: var(--ink); }
.sb-item.active {
  background: var(--brand-soft); color: var(--brand); font-weight: 600;
  border-left-color: var(--brand);
}
.sb-item .ico { width: 18px; text-align: center; font-size: 14px; flex: none; }
.sb-item .ad { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-item .soon, .sb-subitem .soon {
  margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: .5px;
  background: var(--line-soft); color: var(--ink-mute); padding: 2px 6px; border-radius: 10px;
  flex: none;
}
/* açılır ok */
.sb-item .ac {
  margin-left: auto; font-size: 10px; color: var(--ink-mute); flex: none;
  transition: transform .16s;
}
.sb-item.active .ac { transform: rotate(90deg); color: var(--brand); }

/* alt başlıklar */
.sb-sub { display: none; }
.sb-sub.open { display: block; }
.sb-subitem {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 18px 6px 49px; border: none; background: none; cursor: pointer;
  font-family: var(--sans); font-size: 12.8px; color: var(--ink-soft);
  text-align: left; border-left: 3px solid transparent; transition: background .1s, color .1s;
  position: relative;
}
.sb-subitem::before {
  content: ''; position: absolute; left: 30px; top: 0; bottom: 0;
  border-left: 1px solid var(--line);
}
.sb-subitem:hover { background: var(--line-soft); color: var(--ink); }
.sb-subitem.active {
  background: var(--brand-soft); color: var(--brand); font-weight: 600;
  border-left-color: var(--brand);
}
.sb-subitem.active::before { border-left-color: var(--brand-mid); }
.sb-subitem .ad { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-foot { border-top: 1px solid var(--line-soft); padding: 12px 18px; }
.sb-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sb-user .av {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.sb-user .who { min-width: 0; }
.sb-user .who strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user .who span { font-size: 11px; color: var(--ink-mute); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 24px; height: 58px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.topbar .spacer { flex: 1; }
.burger { display: none; background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); width: 34px; height: 34px; cursor: pointer; font-size: 16px; }
.content { padding: 24px; flex: 1; }
.content-inner { max-width: 1100px; }

/* ================================================================ kartlar */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.panel-head h3 { font-size: 14.5px; font-weight: 700; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 18px; }

/* ------------------------------------------- ana sayfa kısayol kutucukları */
.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.tile {
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--brand);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 17px 18px 15px;
  cursor: pointer; text-align: left; font-family: var(--sans); color: inherit;
  display: flex; flex-direction: column; gap: 7px; min-height: 132px;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 18px rgba(28,43,35,.11), 0 2px 5px rgba(28,43,35,.06);
}
.tile:focus-visible { outline: 2px solid var(--brand-mid); outline-offset: 2px; }
.tile .ico { font-size: 23px; line-height: 1; }
.tile .ad  { font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.tile .alt { font-size: 12px; color: var(--ink-mute); line-height: 1.45; }
.tile .git {
  margin-top: auto; padding-top: 8px; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; gap: 5px;
}
.tile .git .ok { transition: transform .12s; }
.tile:hover .git .ok { transform: translateX(3px); }

.tile.t-red   { border-top-color: var(--red); }
.tile.t-red   .git { color: var(--red); }
.tile.t-green { border-top-color: var(--brand-mid); }
.tile.t-green .git { color: var(--brand-mid); }
.tile.t-blue  { border-top-color: var(--blue); }
.tile.t-blue  .git { color: var(--blue); }
.tile.t-amber { border-top-color: var(--amber); }
.tile.t-amber .git { color: var(--amber); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px; box-shadow: var(--shadow); border-left: 4px solid var(--brand);
}
.stat .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .9px; color: var(--ink-soft); margin-bottom: 6px; }
.stat .val { font-family: var(--mono); font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 11.5px; color: var(--ink-mute); margin-top: 3px; }
.stat.b-blue  { border-left-color: var(--blue); }
.stat.b-red   { border-left-color: var(--red); }
.stat.b-amber { border-left-color: var(--amber); }

/* ================================================================ tablolar */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .9px;
  color: var(--ink-soft); text-align: left; padding: 10px 14px;
  background: var(--bg); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--bg); }
table.tbl .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl .actions { text-align: right; white-space: nowrap; }

/* ------------------------------------------------- fatura kalem tablosu */
table.tbl-kalem { min-width: 860px; }
table.tbl-kalem td { padding: 6px 8px; }
table.tbl-kalem th { padding: 9px 8px; }
.kalem-input {
  width: 100%; font-family: var(--sans); font-size: 13px; color: var(--ink);
  padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg);
}
.kalem-input:focus {
  outline: none; border-color: var(--brand-mid);
  box-shadow: 0 0 0 2px rgba(30,107,70,.14); background: var(--surface);
}
.kalem-input.sag { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.tbl-kalem .tutar { font-weight: 600; white-space: nowrap; }
table.tbl-kalem .btn-del {
  background: none; border: none; color: var(--ink-mute); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 4px 7px; border-radius: var(--radius-sm);
}
table.tbl-kalem .btn-del:hover { background: var(--red-soft); color: var(--red); }
table.tbl-kalem td:nth-child(2) { width: 92px; }
table.tbl-kalem td:nth-child(3) { width: 104px; }
table.tbl-kalem td:nth-child(4) { width: 122px; }
table.tbl-kalem td:nth-child(5) { width: 82px; }
table.tbl-kalem td:nth-child(6) { width: 92px; }

/* --------------------------------------------------------- fatura toplamı */
.totals { max-width: 380px; margin-left: auto; }
.total-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 6px 0; font-size: 14px;
}
.total-row .lbl { color: var(--ink-soft); }
.total-row .val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.total-row.ince { font-size: 12.5px; padding: 3px 0; }
.total-row.ince .lbl, .total-row.ince .val { color: var(--ink-mute); }
.total-row.eksi .val { color: var(--red); }
.total-row.sonuc {
  border-top: 2px solid var(--ink); margin-top: 8px; padding-top: 11px;
}
.total-row.sonuc .lbl { font-weight: 700; color: var(--ink); font-size: 13px; letter-spacing: .5px; }
.total-row.sonuc .val { font-size: 20px; font-weight: 700; color: var(--brand); }

.tag {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  padding: 2px 9px; border-radius: 11px; white-space: nowrap;
}
.tag-green { background: var(--brand-soft); color: var(--brand); }
.tag-blue  { background: var(--blue-soft);  color: var(--blue); }
.tag-gray  { background: var(--line-soft);  color: var(--ink-soft); }
.tag-red   { background: var(--red-soft);   color: var(--red); }

/* ============================================================ boş durumlar */
.empty { text-align: center; padding: 46px 24px; color: var(--ink-soft); }
.empty .ico { font-size: 34px; display: block; margin-bottom: 12px; opacity: .5; }
.empty strong { display: block; font-size: 15.5px; color: var(--ink); margin-bottom: 6px; }
.empty p { font-size: 13px; max-width: 460px; margin: 0 auto; line-height: 1.65; }

.todo-list { max-width: 520px; margin: 16px auto 0; text-align: left; }
.todo-list li {
  list-style: none; padding: 8px 0 8px 26px; position: relative;
  font-size: 13px; color: var(--ink-soft); border-bottom: 1px solid var(--line-soft);
}
.todo-list li:last-child { border-bottom: none; }
.todo-list li::before {
  content: '☐'; position: absolute; left: 4px; top: 8px; color: var(--ink-mute);
}

/* ================================================================== modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(28,43,35,.45); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 470px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22); margin: auto;
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; }
.modal-head h3 { font-size: 15.5px; font-weight: 700; flex: 1; }
.modal-close { background: none; border: none; font-size: 21px; color: var(--ink-mute); cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--red); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); display: flex; gap: 9px; justify-content: flex-end; }

/* ================================================================== toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: var(--radius-sm);
  font-size: 13.5px; z-index: 120; box-shadow: 0 6px 20px rgba(0,0,0,.24);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: var(--red); }

.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------- görünüm geçiş animasyonu */
#view > * { animation: girisAnim .2s ease-out both; }
#view > *:nth-child(2) { animation-delay: .03s; }
#view > *:nth-child(3) { animation-delay: .06s; }
#view > *:nth-child(4) { animation-delay: .09s; }
@keyframes girisAnim {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}
.modal { animation: modalAnim .16s ease-out both; }
@keyframes modalAnim {
  from { opacity: 0; transform: translateY(-10px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------ yükleme iskeleti */
.skel-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; }
.skel {
  background: linear-gradient(90deg, var(--line-soft) 25%, var(--bg) 50%, var(--line-soft) 75%);
  background-size: 400% 100%; border-radius: var(--radius-sm);
  animation: skelKay 1.3s ease-in-out infinite; height: 13px;
}
.skel.w-25 { width: 25%; } .skel.w-15 { width: 15%; } .skel.w-40 { width: 40%; }
.skel.w-20 { width: 20%; } .skel.t-lg { height: 20px; }
@keyframes skelKay { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Sekme arkaplandayken tazelenirken üstte ince çizgi */
.tazeleme-cizgi {
  position: fixed; top: 0; left: 0; height: 2px; width: 100%; z-index: 200;
  background: linear-gradient(90deg, transparent, var(--brand-mid), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  animation: tazeKay .9s ease-in-out infinite;
}
@keyframes tazeKay {
  from { background-position: -40% 0; } to { background-position: 140% 0; }
}

/* ================================================================= mobil */
.sb-backdrop { display: none; }
@media (max-width: 880px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
    transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.16);
  }
  .sidebar.open { transform: translateX(0); }
  .sb-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(28,43,35,.4); z-index: 55; }
  .burger { display: grid; place-items: center; }
  .content { padding: 16px; }
  .f-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
