/* =========================================================================
   Defter ERP - arayüz stilleri
   Renk sistemi doğrulanmış paletten türetilmiştir (aydınlık + karanlık mod).
   ========================================================================= */

:root {
  color-scheme: light;
  --surface-1: #ffffff;          /* kart yüzeyi */
  --surface-2: #f7f7f5;          /* sayfa zemini */
  --surface-3: #f0efec;          /* vurgulu satır */
  --sidebar: #14243a;
  --sidebar-text: #c8d4e4;
  --sidebar-active: #ffffff;

  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-1-wash: rgba(42, 120, 214, 0.10);

  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 1px 3px rgba(11, 11, 11, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --surface-2: #0d0d0d;
  --surface-3: #232322;
  --sidebar: #0f1620;
  --sidebar-text: #a7b4c6;
  --sidebar-active: #ffffff;

  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-1-wash: rgba(57, 135, 229, 0.14);

  --good: #0ca30c;
  --good-text: #0ca30c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ giriş */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(160deg, #14243a 0%, #1f3a5f 100%);
  padding: 24px;
}
.login-card {
  background: var(--surface-1); border-radius: 14px; padding: 34px 32px;
  width: min(400px, 100%); box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p.sub { margin: 0 0 22px; color: var(--text-secondary); font-size: 13px; }

/* ---------------------------------------------------------------- düzen */
.app { display: none; min-height: 100vh; }
.app.ready { display: grid; grid-template-columns: 232px 1fr; }

.sidebar {
  background: var(--sidebar); color: var(--sidebar-text);
  padding: 18px 0 40px; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; display: flex; flex-direction: column;
}
.sidebar .brand {
  padding: 0 20px 18px; font-size: 18px; font-weight: 650; color: #fff;
  display: flex; align-items: center; gap: 9px;
}
.sidebar .brand small { font-weight: 400; font-size: 11px; opacity: .6; display: block; }
.nav-group { margin-top: 14px; }
.nav-group h4 {
  margin: 0 0 4px; padding: 0 20px; font-size: 10.5px; letter-spacing: .09em;
  text-transform: uppercase; color: rgba(255, 255, 255, .38); font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 20px;
  color: var(--sidebar-text); cursor: pointer; font-size: 13.5px;
  border-left: 3px solid transparent; user-select: none;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active {
  background: rgba(255, 255, 255, .10); color: var(--sidebar-active);
  border-left-color: var(--series-1); font-weight: 550;
}
.nav-item .ico { width: 17px; text-align: center; opacity: .85; font-size: 14px; }
.nav-badge {
  margin-left: auto; background: var(--series-2); color: #fff; border-radius: 9px;
  padding: 1px 6px; font-size: 10.5px; font-weight: 600;
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 13px 24px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 17px; font-weight: 620; }
.topbar .spacer { flex: 1; }
.content { padding: 22px 24px 60px; }

/* ---------------------------------------------------------------- bileşen */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; gap: 10px; margin: -2px 0 14px;
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 620; }
.card-head .spacer { flex: 1; }
.card-sub { color: var(--text-secondary); font-size: 12px; margin: -8px 0 12px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app.ready { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 232px; height: 100vh;
             transform: translateX(-100%); transition: transform .18s; }
  .sidebar.open { transform: none; }
  .grid.cols-4 { grid-template-columns: 1fr; }
}

/* stat tile */
.stat { background: var(--surface-1); border: 1px solid var(--border);
        border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow); }
.stat .label { color: var(--text-secondary); font-size: 12px; margin-bottom: 6px; }
.stat .value { font-size: 25px; font-weight: 620; letter-spacing: -.015em; line-height: 1.15; }
.stat .value.hero { font-size: 42px; }
.stat .delta { font-size: 12px; margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.stat .delta.up { color: var(--good-text); }
.stat .delta.down { color: var(--critical); }
.stat .delta .muted { color: var(--text-muted); }
.stat .foot { color: var(--text-muted); font-size: 11.5px; margin-top: 6px; }

/* tablo */
.table-wrap { overflow-x: auto; margin: 0 -18px -16px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 8px 12px; color: var(--text-secondary);
  font-weight: 600; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .04em; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
table.data td {
  padding: 9px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle;
}
table.data tbody tr:hover { background: var(--surface-3); }
table.data td.num, table.data th.num {
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.data td.strong { font-weight: 600; }
table.data tr.clickable { cursor: pointer; }
table.data tfoot td { font-weight: 650; border-top: 2px solid var(--axis); border-bottom: none; }
.empty { padding: 34px 12px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* rozetler */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 20px; font-size: 11.5px; font-weight: 550; white-space: nowrap;
  border: 1px solid transparent;
}
.badge.gray   { background: var(--surface-3); color: var(--text-secondary); }
.badge.blue   { background: rgba(42,120,214,.12); color: var(--series-1); }
.badge.green  { background: rgba(12,163,12,.12); color: var(--good-text); }
.badge.orange { background: rgba(235,104,52,.13); color: var(--series-2); }
.badge.red    { background: rgba(208,59,59,.12); color: var(--critical); }
.badge.yellow { background: rgba(250,178,25,.16); color: #8a6100; }
:root[data-theme="dark"] .badge.yellow { color: var(--warning); }

/* form */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--text-secondary);
                     margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--axis);
  border-radius: var(--radius-sm); font-size: 13.5px; font-family: inherit;
  background: var(--surface-1); color: var(--text-primary);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--series-1);
  box-shadow: 0 0 0 3px var(--series-1-wash);
}
input[readonly] { background: var(--surface-3); color: var(--text-secondary); }
textarea { min-height: 70px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--axis);
  background: var(--surface-1); color: var(--text-primary); font-size: 13.5px;
  font-family: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 11, 11, .5);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--surface-1); border-radius: 12px; width: min(720px, 100%);
  max-height: 88vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, .32);
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border);
              display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border);
              display: flex; gap: 9px; justify-content: flex-end; }
.modal.wide { width: min(1000px, 100%); }

/* bildirim */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200;
          display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface-1); border: 1px solid var(--border); border-left: 4px solid var(--series-1);
  border-radius: var(--radius-sm); padding: 11px 15px; box-shadow: 0 6px 20px rgba(0,0,0,.16);
  font-size: 13px; max-width: 380px; animation: slide-in .16s ease-out;
}
.toast.error { border-left-color: var(--critical); }
.toast.success { border-left-color: var(--good); }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } }

/* grafik */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--font); }
.chart .axis-label { fill: var(--text-muted); font-size: 11px; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .value-label { fill: var(--text-secondary); font-size: 11px; font-weight: 550; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px;
                color: var(--text-secondary); }
.chart-legend .key { display: flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 11px; height: 11px; border-radius: 3px; }
.chart-tooltip {
  position: fixed; pointer-events: none; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px;
  font-size: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.16); z-index: 300;
  white-space: nowrap; opacity: 0; transition: opacity .1s;
}
.chart-tooltip.show { opacity: 1; }
.chart-tooltip b { font-variant-numeric: tabular-nums; }

/* çeşitli */
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 8px 14px; cursor: pointer; font-size: 13.5px; color: var(--text-secondary);
       border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--series-1); border-bottom-color: var(--series-1); font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; font-size: 13px; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; font-weight: 550; }
.spinner {
  width: 15px; height: 15px; border: 2px solid var(--grid); border-top-color: var(--series-1);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--text-muted); }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.progress { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--series-1); }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px;
         border-left: 3px solid var(--warning); background: rgba(250,178,25,.10); }
.alert.error { border-left-color: var(--critical); background: rgba(208,59,59,.09); }
.alert.info { border-left-color: var(--series-1); background: var(--series-1-wash); }
