:root {
  --bg: #f6f5f2;
  --bg-panel: #ffffff;
  --bg-sidebar: #232323;
  --text: #2b2b2b;
  --text-muted: #7a7a76;
  --text-inverse: #e8e6e1;
  --border: #e6e4de;
  --teal: #4a7c74;
  --teal-soft: #eaf1ef;
  --orange: #c97a3d;
  --orange-soft: #f7ece1;
  --danger: #b5533f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.03);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 8px 28px 8px;
}
.brand-mark {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  letter-spacing: 1px;
  color: #fff;
}
.brand-sub {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--teal);
  font-weight: 600;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  all: unset;
  cursor: pointer;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: #b9b7b2;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--teal); color: #fff; font-weight: 500; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 10px 6px;
}

/* ---------- Content ---------- */

.content {
  flex: 1;
  min-width: 0;
  padding: 32px 40px;
  max-width: 1560px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.topbar h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.btn {
  all: unset;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  background: var(--teal);
  color: #fff;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn.secondary {
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12px; }

/* ---------- Cards / panels ---------- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.panel h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 14px 0;
  color: var(--text);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.stat-value { font-size: 22px; font-weight: 700; }
.stat-value.teal { color: var(--teal); }
.stat-value.orange { color: var(--orange); }
.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  color: var(--text);
}
.stat-row span:last-child { font-weight: 600; }

/* ---------- Tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover { background: #fafaf8; }
tbody tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.pill.teal { background: var(--teal-soft); color: var(--teal); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.gray { background: #ecece8; color: var(--text-muted); }

.due-soon { color: var(--danger); font-weight: 600; }

.row-actions { display: flex; gap: 6px; }
.icon-btn {
  all: unset;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 6px;
  border-radius: 5px;
}
.icon-btn:hover { background: var(--border); color: var(--text); }

.empty-state {
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.company-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}
.tab {
  all: unset;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.tab.active { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ---------- Modal / form ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,30,28,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 24px 26px;
  width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.18);
}
.modal h3 { margin: 0 0 16px 0; font-size: 15px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.form-field input, .form-field select, .form-field textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fdfdfc;
  color: var(--text);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none;
  border-color: var(--teal);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.subtle-link {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}

/* ---------- Eklemeler ---------- */

/* Hücre / alan altındaki küçük, soluk ikinci satır */
.sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

/* Satır sonundaki Düzenle / Sil butonları */
.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

/* "← geri dön" bağlantısı (button olarak üretiliyor) */
button.subtle-link {
  all: unset;
  cursor: pointer;
  display: inline-block;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline;
}

/* Formda uzun seçenek metinleri taşmasın */
.form-field { min-width: 0; }
.form-field select,
.form-field input,
.form-field textarea { width: 100%; text-overflow: ellipsis; }
.modal { width: 560px; max-width: 94vw; }

/* ---------- Yan menü grupları ve vade vurguları ---------- */

.nav-group-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #8a8883;
  padding: 18px 10px 6px 10px;
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.nav-item.action { color: #d9d6cf; }
.nav-item.action:hover { background: var(--teal); color: #fff; }

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 20px; }

tbody tr.row-urgent td { background: #f8e0db; }
tbody tr.row-soon td { background: #fbf4d4; }
tbody tr.row-urgent:hover td { background: #f4d5ce; }
tbody tr.row-soon:hover td { background: #f7edbd; }

.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 2px; vertical-align: middle; }
.legend-dot.urgent { background: #e8b4aa; }
.legend-dot.soon { background: #ecdc8e; }

/* ---------- Sabit yan menü, ödeme hücresi, soluk değerler ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: flex-start;
  overflow-y: auto;
}

.muted { color: var(--text-muted); }

.pay-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 104px; }
.pay-cell .pay-btn { width: 104px; text-align: center; box-sizing: border-box; }
.pay-cell .sub { width: 104px; text-align: center; }
.pay-sub { display: flex; gap: 2px; width: 104px; justify-content: center; }

.limit-bar { height: 6px; background: #ecece8; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.limit-fill { height: 100%; background: var(--teal); border-radius: 3px; }
.limit-fill.hot { background: var(--danger); }

.alert-box { background:#fbf4d4; border:1px solid #e8d98b; border-radius:8px; padding:12px 14px; margin-bottom:16px; font-size:13px; }

.gd-cols { display:grid; grid-template-columns:1fr 1fr; gap:14px; align-items:start; }
.gd-item { border-bottom:1px solid var(--border, #e5e7eb); }
.gd-line { display:flex; justify-content:space-between; gap:12px; padding:10px 4px; }
.gd-line.clickable { cursor:pointer; }
.gd-line.clickable:hover { background:rgba(127,127,127,.08); }
.gd-amt { text-align:right; font-weight:600; white-space:nowrap; }
.gd-detail { padding:4px 0 10px 14px; overflow-x:auto; }
.gd-total { display:flex; justify-content:space-between; gap:12px; padding:12px 4px 4px; font-size:1.05em; }
@media (max-width:1100px){ .gd-cols{ grid-template-columns:1fr; } }

.reminder-bar { padding:0 24px; }
.reminder-bar:empty { display:none; }
.reminder-box { margin-top:12px; margin-bottom:0; }
.reminder-title { font-weight:700; margin-bottom:6px; }
.reminder-row { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:5px 0; border-top:1px solid #e8d98b; }

/* ---------- Çok kullanıcılı sürüm eklemeleri ---------- */

.hidden { display: none !important; }

/* Yalnız görüntüleyen kullanıcıda yazma düğmeleri, tüm şirketlere yetkisi olmayanda ortak kayıt düğmeleri gizlenir
   (yetki kontrolü sunucuda yapılır; bu yalnızca görünüm). */
body.readonly .w { display: none !important; }
body.notfull .wf { display: none !important; }
body:not(.is-admin) .admin-only { display: none !important; }

.sidebar-user {
  margin-top: auto;
  padding: 18px 10px 0 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user-name { font-size: 13px; color: #fff; font-weight: 500; }
.sidebar-user-role { font-size: 11px; color: #8a8883; margin-top: 2px; }
.sidebar-user-actions { display: flex; gap: 12px; margin-top: 8px; }
.nav-link {
  all: unset;
  cursor: pointer;
  font-size: 12px;
  color: #b9b7b2;
  text-decoration: underline;
}
.nav-link:hover { color: #fff; }
.nav { margin-bottom: 18px; }

.auth-root {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  width: 420px;
  max-width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
}
.auth-card .brand { padding: 0 0 18px 0; }
.auth-card .brand-mark { color: var(--text); }
.auth-card h2 { font-size: 16px; margin: 0 0 6px 0; }
.auth-card .form-field { margin-bottom: 12px; }
.auth-card .btn { display: block; text-align: center; width: 100%; box-sizing: border-box; margin-top: 6px; }
.auth-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }
.auth-note { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.45; }

.view-error { border-color: #e8b4aa; background: #fdf3f1; }

.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.check-row:last-child { border-bottom: none; }
.check-icon { width: 20px; font-weight: 700; }
.check-icon.ok { color: var(--teal); }
.check-icon.bad { color: var(--danger); }
.check-icon.warn { color: var(--orange); }

.checkbox-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 4px 0; }
.checkbox-list label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); font-weight: 400; }
.form-field input[type="checkbox"] { width: auto; }

.secret-box {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 18px;
  letter-spacing: 1px;
  background: var(--teal-soft);
  border: 1px dashed var(--teal);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  margin: 10px 0;
  user-select: all;
}
.audit-changes { font-size: 11px; color: var(--text-muted); word-break: break-word; max-width: 520px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.import-table td, .import-table th { font-size: 12px; padding: 6px 8px; }
.status-ok { color: var(--teal); font-weight: 600; }
.status-warn { color: var(--danger); font-weight: 600; }
.warn-list { margin: 8px 0 0 0; padding-left: 18px; font-size: 12px; color: var(--text); }
.warn-list li { margin-bottom: 4px; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .content { padding: 20px 16px; }
  .grid-2, .grid-3, .grid-4, .gd-cols { grid-template-columns: 1fr; }
  .panel { overflow-x: auto; }
}
