/* ==========================================================================
   Teymensel Muhasebe — Finansal Yönetim, RBAC & BirFatura GİB Arayüzü
   ========================================================================== */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --hover: #f8fafc;
  --border: #e2e8f0;
  --border-soft: #eef2f6;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-soft: #e8f0fe;
  --green: #0f9d58;
  --green-soft: #e6f4ea;
  --red: #d93025;
  --red-soft: #fce8e6;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --purple: #6d28d9;
  --purple-soft: #ede9fe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, .18);
}

[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #20242e;
  --hover: #1d212b;
  --border: #2a303d;
  --border-soft: #222733;
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --primary: #60a5fa;
  --primary-hover: #93c5fd;
  --primary-soft: rgba(96, 165, 250, .14);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, .14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, .14);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, .14);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, .15);
  --shadow: 0 2px 6px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 52px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none !important;
  transition: .14s;
}
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-lg { padding: 11px 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
[data-theme="dark"] .btn-primary { color: #081c36; font-weight: 600; }
.btn-green { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-tonal { background: var(--primary-soft); color: var(--primary); }
.btn-text { background: transparent; color: var(--muted); }
.btn-text:hover { background: var(--surface-2); color: var(--text); }
.btn-text.danger { color: var(--red); }
.icon-btn { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: inline-grid; place-items: center; font-size: 16px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ===================== LOGIN ===================== */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-badge { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, #1a73e8, #6d28d9); color: #fff; font-weight: 800; font-size: 18px; display: inline-grid; place-items: center; flex: none; }
.login-brand-name { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.login-brand-name span { color: var(--muted); font-weight: 500; }
.login-brand-sub { font-size: 12px; color: var(--muted); }
.divider { display: flex; align-items: center; gap: 10px; margin: 20px 0 16px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.login-form .field { margin-bottom: 12px; }
.demo-panel { margin-top: 20px; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border); text-align: center; font-size: 12.5px; }
.demo-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.login-links { margin-top: 20px; text-align: center; font-size: 12px; color: var(--muted); display: flex; justify-content: center; gap: 8px; }
.alert-box { padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-box.danger { background: var(--red-soft); color: var(--red); }

/* ===================== APP SHELL ===================== */
.preview-banner {
  position: sticky;
  top: 0;
  z-index: 90;
  background: #b45309;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  flex-wrap: wrap;
}
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 70;
}
.sb-head { padding: 16px 16px 14px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; }
.sb-brand { display: flex; align-items: center; gap: 10px; color: var(--text) !important; text-decoration: none !important; }
.sb-brand strong { display: block; font-size: 15px; line-height: 1.2; }
.sb-brand small { display: block; font-size: 11.5px; color: var(--muted); }
.sb-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 3px; }
.nav-sec { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 12px 4px; }
.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13.5px;
  text-align: left;
  text-decoration: none !important;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-count { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.nav-btn.active .nav-count { background: var(--primary); color: #fff; }
.sb-foot { padding: 12px; border-top: 1px solid var(--border-soft); }
.sb-role-box { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 12px; margin-bottom: 10px; }
.sb-role-box strong { display: block; font-size: 13px; color: var(--text); }
.sb-role-box span { color: var(--muted); }
.sb-ecos { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; padding: 0 4px; }
.sb-ecos a { color: var(--muted); }

.content-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-l, .topbar-r { display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-h1 { margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.policy-pill { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); white-space: nowrap; }

.main-body { padding: 22px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ===================== CARDS, GRIDS, TABLES ===================== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-lbl { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-val { font-size: 23px; font-weight: 700; margin: 6px 0 3px; letter-spacing: -.02em; }
.kpi-val.green { color: var(--green); }
.kpi-val.red { color: var(--red); }
.kpi-val.primary { color: var(--primary); }
.kpi-sub { font-size: 12px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 20px; }
.grid-even { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow); overflow: hidden; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-pad { padding: 18px 20px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type="search"], .toolbar select {
  height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); outline: none; font-size: 13px;
}
.toolbar input[type="search"] { flex: 1; min-width: 200px; }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 11px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
table.tbl td { padding: 10px 11px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.tbl tr:hover td { background: var(--hover); }
.num { text-align: right; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }
.badge.muted { background: var(--surface-2); color: var(--muted); }

/* Dual-bar monthly chart */
.dual-chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; align-items: end; height: 150px; padding-top: 10px; }
.dc-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.dc-bars { display: flex; align-items: flex-end; gap: 5px; height: 112px; width: 100%; justify-content: center; }
.dc-b { width: 18px; border-radius: 4px 4px 0 0; min-height: 3px; transition: height .3s; }
.dc-b.inc { background: var(--green); }
.dc-b.exp { background: var(--red); opacity: .82; }
.dc-lbl { font-size: 12px; color: var(--muted); font-weight: 500; }

/* Progress bars for categories */
.prog-row { margin-bottom: 12px; }
.prog-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.prog-track { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 999px; background: var(--primary); }

/* BirFatura Endpoint Code Card */
.ep-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border-soft); font-size: 12.5px; flex-wrap: wrap; }
.ep-row:first-child { border-top: 0; }
.ep-url { font-family: ui-monospace, Menlo, monospace; background: var(--surface-2); padding: 4px 8px; border-radius: 6px; font-size: 12px; word-break: break-all; }

/* ===================== FORMS & MODAL ===================== */
.modal-scrim, .sb-scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 120; opacity: 0; pointer-events: none; transition: opacity .18s; }
.modal-scrim.open, .sb-scrim.open { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%) scale(.97);
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 36px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 140;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: .18s;
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal.modal-wide { width: min(920px, calc(100vw - 24px)); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px 20px 22px; overflow-y: auto; }

/* ===================== ŞİRKETİM & BELGE KASASI ===================== */
.co-hero {
  background: linear-gradient(135deg, var(--surface) 0%, var(--primary-soft) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.co-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.co-title { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.co-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.co-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.co-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.co-chip-lbl { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.co-chip-val { font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 6px; word-break: break-word; }
.copy-mini { border: 0; background: var(--surface-2); color: var(--primary); font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; flex: none; }
.copy-mini:hover { background: var(--primary); color: #fff; }

.kv-list { display: flex; flex-direction: column; }
.kv-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.kv-row:last-child { border-bottom: 0; }
.kv-k { color: var(--muted); flex: 0 0 42%; font-size: 12.5px; }
.kv-v { text-align: right; font-weight: 500; word-break: break-word; flex: 1; }

.doc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.doc-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.doc-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.doc-icon {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--red-soft); color: var(--red);
  display: inline-grid; place-items: center; font-weight: 800; font-size: 11px; flex: none;
}
.doc-icon.img { background: var(--primary-soft); color: var(--primary); }
.doc-title { font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.doc-desc { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--muted); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.pdf-frame { width: 100%; height: 72vh; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }

.smmm-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 14px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.check-card { display: flex; align-items: flex-start; gap: 8px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); cursor: pointer; font-size: 12.5px; }
.check-card input { margin-top: 2px; accent-color: var(--primary); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border-soft); }

.tax-preview-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; font-size: 12px; }
.tax-preview-box strong { display: block; font-size: 14px; margin-top: 2px; }

.sk { height: 110px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--hover) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sk 1.1s infinite; margin-bottom: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px); background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 9px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: .2s; z-index: 200; max-width: calc(100vw - 24px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); }

.mobile-only { display: none; }
@media (max-width: 960px) {
  .mobile-only { display: inline-grid; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-102%); transition: transform .22s; }
  body.sb-open .sidebar { transform: none; }
  body.sb-open .sb-scrim { opacity: 1; pointer-events: auto; }
  .kpi-grid, .co-chips { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-even, .form-grid, .check-grid, .tax-preview-box, .doc-grid { grid-template-columns: 1fr; }
  .main-body { padding: 14px; }
}
