:root {
  --primary: #2d6a4f;
  --primary-light: #40916c;
  --primary-dark: #1b4332;
  --accent: #52b788;
  --accent-soft: #95d5b2;
  --bg: #f0f7f4;
  --bg-card: #ffffff;
  --text: #1a2e25;
  --text-muted: #5c7368;
  --border: #d8e9e0;
  --shadow: 0 4px 24px rgba(45, 106, 79, 0.08);
  --shadow-lg: 0 12px 40px rgba(45, 106, 79, 0.12);
  --radius: 14px;
  --sidebar-w: 260px;
  --transition: 0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-light); }

/* Sidebar */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand .logo {
  width: 42px; height: 42px;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
}

.sidebar-brand h1 { font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
.sidebar-brand small { opacity: 0.7; font-size: 0.75rem; display: block; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0; }

.nav-section { margin-bottom: 0.5rem; }

.nav-section-title {
  padding: 0.5rem 1.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.5;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  color: rgba(255,255,255,0.85);
  font-size: 0.9rem;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left-color: var(--accent-soft);
}

.nav-link .icon { width: 20px; text-align: center; opacity: 0.8; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  opacity: 0.6;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.topbar {
  background: var(--bg-card);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }

.menu-toggle {
  display: none;
  background: none; border: none;
  font-size: 1.4rem; cursor: pointer;
  color: var(--primary);
}

.page-title { font-size: 1.35rem; font-weight: 600; color: var(--primary-dark); }

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

.topbar-right { display: flex; align-items: center; gap: 1rem; }

.user-badge {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.8rem;
  background: var(--bg);
  border-radius: 50px;
  font-size: 0.85rem;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 0.8rem;
}

.content-area { padding: 2rem; }

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-header h2, .card-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.card-body { padding: 1.5rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(45, 106, 79, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(45, 106, 79, 0.35);
  color: #fff;
}

.btn-secondary {
  background: var(--bg);
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); color: var(--primary-dark); }

.btn-danger {
  background: #e63946;
  color: #fff;
}

.btn-danger:hover { background: #c1121f; color: #fff; }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 10px;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.form-group label .required { color: #e63946; }

.form-control {
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.2);
}

select.form-control { cursor: pointer; }

textarea.form-control { min-height: 100px; resize: vertical; }

.form-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.form-section:last-child { border-bottom: none; margin-bottom: 0; }

.form-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Tables */
.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  background: var(--bg);
  padding: 0.85rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--primary-dark);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: rgba(149, 213, 178, 0.08); }

.table-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success { background: #d8f3dc; color: #1b4332; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #cce5ff; color: #004085; }
.badge-danger { background: #f8d7da; color: #721c24; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 46, 37, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 1.1rem; color: var(--primary-dark); }

.modal-close {
  background: none; border: none;
  font-size: 1.5rem; cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-body { padding: 1.5rem; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* Search & filters */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search-box input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.5;
}

/* Multi-select chips */
.chip-select { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

.chip {
  padding: 0.35rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
}

.chip.selected, .chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--primary-dark);
}

/* File upload area */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}

.upload-zone:hover {
  border-color: var(--accent);
  background: rgba(149, 213, 178, 0.1);
}

.upload-zone .icon { font-size: 2rem; margin-bottom: 0.5rem; }

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.file-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-align: center;
}

.file-item .thumb {
  height: 100px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.file-item .name {
  padding: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: transform var(--transition);
}

.stat-card:hover { transform: translateY(-2px); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.green { background: #d8f3dc; }
.stat-icon.blue { background: #cce5ff; }
.stat-icon.orange { background: #ffe5d0; }
.stat-icon.purple { background: #e2d9f3; }

.stat-info h3 { font-size: 1.75rem; font-weight: 700; color: var(--primary-dark); line-height: 1.2; }
.stat-info p { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Profile header */
.profile-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
  border-radius: var(--radius);
  padding: 2rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.profile-avatar {
  width: 80px; height: 80px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  font-weight: 600;
  border: 3px solid rgba(255,255,255,0.3);
}

.profile-info h2 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.profile-info p { opacity: 0.85; font-size: 0.9rem; }

.profile-meta {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.profile-meta span { font-size: 0.85rem; opacity: 0.9; }

/* Info grid for profile tabs */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.info-item {
  padding: 1rem;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.info-item label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.25rem;
}

.info-item span { font-weight: 500; color: var(--text); }

/* Line items (invoice style) */
.line-items { margin-top: 1rem; }

.line-item {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.line-item-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }

/* Checkbox groups */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.checkbox-item input { accent-color: var(--primary); width: 16px; height: 16px; }

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.conditional-block { display: none; }
.conditional-block.show { display: contents; }

.conditional-block-wrap {
  display: none;
  grid-column: 1 / -1;
}

.conditional-block-wrap.show {
  display: block;
}

.conditional-block-wrap.show .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.step-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--primary-dark);
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

/* Kasa */
.kasa-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.kasa-tab {
  padding: 0.65rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all var(--transition);
}

.kasa-tab.active, .kasa-tab:hover {
  border-color: var(--primary);
  background: rgba(149, 213, 178, 0.15);
  color: var(--primary-dark);
  font-weight: 600;
}

.kasa-balance {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.kasa-balance.negative { color: #e63946; }

.transaction-in { color: #2d6a4f; font-weight: 600; }
.transaction-out { color: #e63946; font-weight: 600; }

.line-item-ayni {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.line-item-nakdi {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

/* Responsive tables — mobil kart görünümü */
@media (max-width: 768px) {
  .table-wrapper { overflow-x: visible; }

  .data-table.responsive thead { display: none; }

  .data-table.responsive tbody tr {
    display: block;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .data-table.responsive tbody tr:hover { background: var(--bg-card); }

  .data-table.responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    text-align: right;
  }

  .data-table.responsive td:last-child { border-bottom: none; }

  .data-table.responsive td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
  }

  .data-table.responsive td.table-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .data-table.responsive td.table-actions::before { margin-bottom: 0.25rem; }

  .data-table.responsive td.table-actions .btn { width: 100%; justify-content: center; }
}

/* Responsive */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .content-area { padding: 1.25rem; }
  .line-item, .line-item-header,
  .line-item-ayni, .line-item-nakdi {
    grid-template-columns: 1fr;
  }
  .line-item-header { display: none; }
}

@media (max-width: 576px) {
  .topbar { padding: 1rem; flex-wrap: wrap; gap: 0.75rem; }
  .topbar-right { width: 100%; justify-content: flex-end; }
  .profile-header { flex-direction: column; text-align: center; }
  .stats-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .kasa-tabs { flex-direction: column; }
  .kasa-tab { text-align: center; }
}
