/* ========================================
   Workpen – Design System (Eitherist tarzında)
   İşletme defter ve ticari ilişki takibi
   ======================================== */

:root {
  /* Light theme (default) */
  --bg-primary: #f6f5f3;
  --bg-secondary: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #5f6368;
  --text-muted: #80868b;
  --border-color: #dadce0;
  --accent: #1a5f4a;
  --accent-hover: #237a62;
  --accent-soft: rgba(26, 95, 74, 0.12);
  --accent-negative: #c44d4d;
  --accent-negative-soft: rgba(196, 77, 77, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --search-bg: #ffffff;
  --chip-bg: #f1f3f4;
  --chip-bg-active: #1a5f4a;
  --chip-text-active: #ffffff;
  --result-bg: #ffffff;
  --btn-secondary-bg: #e8eaed;
  --btn-secondary-hover: #dadce0;
  --btn-secondary-text: #3c4043;
  --btn-primary-bg: #1a5f4a;
  --btn-primary-hover: #237a62;
  --btn-primary-text: #ffffff;
}

[data-theme="dark"] {
  --bg-primary: #282828;
  --bg-secondary: #1a1a1a;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #a0a0a0;
  --border-color: #3c4043;
  --accent: #2d9d7a;
  --accent-hover: #38b58a;
  --accent-soft: rgba(45, 157, 122, 0.15);
  --accent-negative: #e85d4c;
  --accent-negative-soft: rgba(232, 93, 76, 0.15);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --search-bg: #3c4043;
  --chip-bg: #303134;
  --chip-bg-active: #2d9d7a;
  --chip-text-active: #1a1a1a;
  --result-bg: #383838;
  --btn-secondary-bg: #5b5b5b;
  --btn-secondary-hover: #6b6b6b;
  --btn-secondary-text: #e8eaed;
  --btn-primary-bg: #2d9d7a;
  --btn-primary-hover: #38b58a;
  --btn-primary-text: #1a1a1a;
}

/* ========================================
   Base
   ======================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
}

body > main {
  flex: 1;
  padding-bottom: 2rem;
}

/* ========================================
   Yükleme ekranı
   ======================================== */

.loader-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 9999;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loader-overlay.loader-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
  animation: loader-spin 0.8s linear infinite;
}

@keyframes loader-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ========================================
   Main
   ======================================== */

.main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.5rem;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}


/* ========================================
   Sections
   ======================================== */

.dashboard-section {
  width: 100%;
  margin-bottom: 2rem;
}

.dashboard-quick-actions {
  margin-bottom: 1rem;
}

.quick-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.quick-action-btn {
  flex: 1;
  min-width: 5.5rem;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.quick-action-btn:hover {
  background: var(--btn-secondary-bg);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-action-link {
  font-size: 0.85rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0;
}

.section-action-link:hover {
  text-decoration: underline;
}

.section-header-row .section-title {
  margin: 0;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.75rem 0;
  margin: 0 0 0.75rem 0;
}

.section-hint,
.section-empty {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  margin: 1rem 0 0;
  padding: 1rem;
}

/* ========================================
   AI Asistan
   ======================================== */

.ai-assistant-section {
  margin-bottom: 1.5rem;
}

.ai-assistant {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-assistant-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.875rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-assistant-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.ai-assistant-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
}

.ai-assistant-input::placeholder {
  color: var(--text-muted);
}

.search-mode-trigger {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: 0.4rem;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s;
}

.search-mode-trigger:hover {
  border-color: var(--accent);
  background: var(--chip-bg);
}

.search-mode-label {
  white-space: nowrap;
}

.search-mode-chevron {
  flex-shrink: 0;
  opacity: 0.8;
}

.search-mic-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.7;
  transition: color 0.2s, opacity 0.2s;
}

.search-mic-icon:hover {
  color: var(--accent);
  opacity: 1;
}

.search-mic-icon.listening {
  color: var(--accent);
  opacity: 1;
  animation: search-mic-pulse 1s ease-in-out infinite;
}

@keyframes search-mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.search-send-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.7;
  transition: color 0.2s, opacity 0.2s;
}

.search-send-icon:hover {
  color: var(--accent);
  opacity: 1;
}

.ai-assistant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.ai-assistant-chips[hidden] {
  display: none !important;
}

.ai-assistant-chip {
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border-color);
  background: var(--chip-bg);
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--text-secondary);
  border-radius: 1rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.ai-assistant-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
}

.ai-assistant-response {
  position: relative;
  padding: 1rem 1.25rem;
  padding-top: 2rem;
  background: var(--accent-soft);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  min-height: 1rem;
}

.ai-assistant-response-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 0.35rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.ai-assistant-response-close:hover {
  color: var(--text-primary);
  background: var(--chip-bg);
}

.ai-assistant-response[hidden] {
  display: none !important;
}

.ai-assistant-response-content {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
}

.ai-assistant-response-content.loading {
  color: var(--text-muted);
}

.search-result-contact-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.5rem 0;
  cursor: pointer;
  border-radius: 0.35rem;
  transition: background 0.15s;
}

.search-result-contact-row:hover {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .search-result-contact-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.search-result-contact-row:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

.search-result-contact-name {
  font-weight: 500;
  color: var(--text-primary);
}

.search-result-contact-defter {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.5;
}

/* ========================================
   Ledger grid
   ======================================== */

.ledger-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

.ledger-card-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  align-items: stretch;
}

.ledger-card-btn,
.ledger-card-add-tx {
  padding: 0.5rem 1.1rem;
  border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2);
  font-family: inherit;
  font-size: 0.7rem;
  color: #fff;
  border-radius: 0.4rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.ledger-card-btn:hover,
.ledger-card-add-tx:hover {
  background: rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.7);
}

.ledger-card {
  aspect-ratio: 4 / 5;
  position: relative;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  perspective: 600px;
}

.ledger-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

.ledger-card-flipped .ledger-card-inner {
  transform: rotateY(180deg);
}

.ledger-card-front,
.ledger-card-back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  border-radius: 0.75rem;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.ledger-card-front {
  justify-content: center;
}

.ledger-card-back {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: rotateY(180deg);
}

.ledger-card:hover .ledger-card-front,
.ledger-card:hover .ledger-card-back {
  box-shadow: var(--shadow-md);
}

.ledger-card:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

.ledger-card-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  padding: 0.25rem;
}

.ledger-card .ledger-card-label {
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.ledger-card-add {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chip-bg) !important;
  border: 2px dashed var(--border-color);
  opacity: 0.85;
}

.ledger-card-add[hidden] {
  display: none !important;
}

.ledger-card-add:hover {
  opacity: 1;
}

.ledger-card-add .ledger-card-label {
  color: var(--text-muted);
  text-shadow: none;
}

.transaction-type-card {
  aspect-ratio: 5 / 3;
}

.transaction-type-card .ledger-card-label {
  font-size: 0.85rem;
}

.contact-card {
  flex-direction: column;
  gap: 0.25rem;
}

.contact-card .ledger-card-label {
  font-size: 0.9rem;
}

.contact-card-meta {
  font-size: 0.75rem;
  opacity: 0.9;
}

.transaction-type-card-pale {
  opacity: 0.72;
}

.ledgers-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ledgers-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.ledgers-list-item:hover {
  box-shadow: var(--shadow-sm);
}

.ledgers-list-item-color {
  width: 3rem;
  height: 3rem;
  min-width: 3rem;
  border-radius: 0.5rem;
  flex-shrink: 0;
}

.ledgers-list-item-body {
  flex: 1;
  min-width: 0;
}

.ledgers-list-item-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.ledgers-list-item-units {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ledgers-list-item-edit {
  flex-shrink: 0;
}

.ledgers-list-item-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  min-width: 1.75rem;
  color: var(--text-muted);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.ledgers-list-item-drag-handle:active {
  cursor: grabbing;
}
.ledgers-list-item-draggable:hover .ledgers-list-item-drag-handle {
  color: var(--text-primary);
}
.ledgers-list-item-dragging {
  opacity: 0.6;
}
.ledgers-list-item-drag-over {
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: 0.5rem;
}

/* ========================================
   Activity list
   ======================================== */

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
}

.activity-item-type {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 0.35rem;
}

.activity-item-type.alacak {
  background: var(--accent-soft);
  color: var(--accent);
}

.activity-item-type.borc {
  background: var(--accent-negative-soft);
  color: var(--accent-negative);
}

.activity-item-content {
  flex: 1;
  min-width: 0;
}

.activity-item-contact {
  font-size: 0.9rem;
  font-weight: 500;
}

.activity-item-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.activity-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.activity-item-ledger {
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.activity-item-right .activity-item-note {
  text-align: right;
  margin-top: 0.15rem;
}

.activity-item-defter-nos {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.activity-item-defter-no {
  line-height: 1.2;
}

.activity-list-modal {
  max-height: 70vh;
  overflow-y: auto;
}

/* Ayrıntılı son hareketler - filtreler ve tablo */
.transactions-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.transactions-filters .filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.transactions-filters .filter-group-search {
  flex: 1 1 100%;
  min-width: 12rem;
}

.transactions-filters .filter-group-search .form-input {
  min-width: 12rem;
}

.transactions-filters .filter-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.transactions-filters .form-select {
  min-width: 8rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--bg-primary);
}

.transactions-detail-list-wrap {
  max-height: 60vh;
  overflow-y: auto;
}

.transactions-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.transactions-detail-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-color);
}

.transactions-detail-th-amount {
  text-align: right !important;
}

.transactions-detail-row {
  border-bottom: 1px solid var(--border-color);
}

.transactions-detail-row:hover {
  background: var(--chip-bg);
}

.transactions-detail-row td {
  padding: 0.65rem 0.75rem;
}

.transactions-detail-row td:last-child {
  text-align: right;
}

.transactions-detail-date {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.transactions-detail-ledger {
  font-weight: 500;
}

.transactions-detail-contact {
  font-weight: 500;
}

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

.transactions-detail-amount {
  font-weight: 600;
}

.activity-item-amount {
  font-size: 0.95rem;
  font-weight: 600;
}

.activity-item-amount.positive {
  color: var(--accent);
}

.activity-item-amount.negative {
  color: var(--accent-negative);
}

/* ========================================
   Page Modal (Eitherist tarzı)
   ======================================== */

.page-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.page-modal-backdrop:not([hidden]) {
  opacity: 1;
  visibility: visible;
}

#transactionModalBackdrop:not([hidden]),
#addToLedgerModalBackdrop:not([hidden]),
#contactModalBackdrop:not([hidden]) {
  z-index: 1001;
}

body.page-modal-open {
  overflow: hidden;
}

.page-modal {
  background: var(--bg-secondary);
  border-radius: 1rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-modal-sm {
  max-width: 360px;
}

.page-modal-wide {
  max-width: 480px;
}

.page-modal-wide#transactionModal {
  max-width: 560px;
}

.page-modal-wide#transactionModal .page-modal-body {
  padding: 1.5rem 1.5rem 1.75rem;
}

/* Raporlar modalı */
.reports-summary {
  margin-bottom: 1.5rem;
}

.reports-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.reports-stat {
  padding: 0.5rem 1rem;
  background: var(--chip-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.reports-ledgers {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.reports-ledgers-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.reports-ledger-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
}

.reports-ledger-item.reports-ledger-total {
  margin-top: 0.5rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--chip-bg) 0%, color-mix(in oklch, var(--chip-bg) 90%, var(--accent) 10%) 100%);
}

.reports-ledger-name {
  font-size: 0.95rem;
}

.reports-ledger-balance.positive {
  color: var(--color-positive, #16a34a);
}

.reports-ledger-balance.negative {
  color: var(--color-negative, #dc2626);
}

.transaction-form-history {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

.transaction-form-history-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--text-primary);
}

.transaction-form-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.page-modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.page-modal-back {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0.5rem;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.page-modal-back:hover {
  color: var(--text-primary);
  background: var(--chip-bg);
}

.page-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.page-modal-title {
  flex: 1;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
}

.page-modal-close {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0.5rem;
  transition: color 0.2s, background 0.2s;
}

.page-modal-close:hover {
  color: var(--text-primary);
  background: var(--chip-bg);
}

.page-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* ========================================
   Form
   ======================================== */

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--search-bg);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Searchable select */
.searchable-select-wrap {
  position: relative;
  width: 100%;
}

.searchable-select-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  overflow: hidden;
}

.searchable-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  text-align: left;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--search-bg);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s;
}

.searchable-select-trigger:hover {
  border-color: var(--text-muted);
}

.searchable-select-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  outline: none;
}

.searchable-select-trigger::after {
  content: "▼";
  font-size: 0.65rem;
  opacity: 0.7;
  margin-left: 0.5rem;
}

.searchable-select-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--result-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.searchable-select-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: none;
  border-bottom: 1px solid var(--border-color);
  background: var(--search-bg);
  color: var(--text-primary);
}

.searchable-select-search:focus {
  outline: none;
}

.searchable-select-list {
  max-height: 12rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
}

.searchable-select-list li {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  color: var(--text-primary);
}

.searchable-select-list li:hover,
.searchable-select-list li[aria-selected="true"] {
  background: var(--accent-soft);
}

.searchable-select-list li.searchable-select-empty {
  color: var(--text-muted);
  cursor: default;
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
}

.form-group-conditional {
  display: none;
}

.form-group-conditional.visible {
  display: flex;
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.color-swatch {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--border-color);
}

.unit-product-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.unit-product-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  background: var(--chip-bg);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.unit-product-chip:hover {
  background: var(--chip-bg-active);
  border-color: var(--chip-bg-active);
  color: var(--chip-text-active);
}

.unit-product-chip.selected {
  background: var(--chip-bg-active);
  border-color: var(--chip-bg-active);
  color: var(--chip-text-active);
}

.unit-product-chip input {
  margin: 0;
}

.form-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-input-wrap .form-input {
  flex: 1;
  min-width: 0;
}

.form-suffix {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Profil sayfası */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.profile-identity {
  min-width: 0;
  flex: 1;
}

.profile-name {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 0.2rem 0;
}

.profile-email {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
  word-break: break-all;
}

.profile-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.75rem 0;
}

.profile-user-id-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.profile-user-id {
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
  word-break: break-all;
}

.profile-copy-id-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 0.35rem;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.profile-copy-id-btn:hover {
  background: var(--chip-bg);
  color: var(--text-primary);
}

.profile-personal-meta {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.profile-info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.profile-info-row:last-child {
  border-bottom: none;
}

.profile-info-label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.profile-info-value {
  color: var(--text-secondary);
  text-align: right;
  word-break: break-all;
}

/* Şirket modal */
.company-members-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.company-members-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.company-member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--chip-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
}

.company-member-info {
  min-width: 0;
}

.company-member-id {
  font-size: 0.8rem;
  font-family: ui-monospace, monospace;
  color: var(--text-secondary);
  word-break: break-all;
}

.company-member-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.2rem;
}

.company-member-remove {
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  color: var(--accent-negative);
  background: transparent;
  border: 1px solid var(--accent-negative);
  border-radius: 0.35rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.company-member-remove:hover {
  background: var(--accent-negative-soft);
}

.company-info-section {
  margin-bottom: 1.5rem;
}

.company-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.company-nav-btn {
  flex: 1;
  min-width: 9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.company-nav-btn-icon svg {
  flex-shrink: 0;
}

/* Settings list – profil dropdown ile aynı tasarım dili */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.settings-list-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

.settings-list-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.settings-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0.4rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.settings-list-item .settings-list-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  opacity: 0.9;
}

.settings-list-item:hover {
  background: var(--chip-bg);
  color: var(--text-primary);
}

.settings-list-item:hover .settings-list-icon {
  color: var(--accent);
  opacity: 1;
}

.settings-list-item-danger {
  color: var(--accent-negative);
}

.settings-list-item-danger .settings-list-icon {
  color: var(--accent-negative);
}

.settings-list-item-danger:hover {
  background: var(--accent-negative-soft);
  color: var(--accent-negative);
}

.settings-list-item-danger:hover .settings-list-icon {
  color: var(--accent-negative);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.company-sub-view {
  animation: fadeIn 0.2s ease;
}

.company-sub-view-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.company-sub-view-header .page-modal-back {
  flex-shrink: 0;
}

.company-sub-view-header .btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.company-sub-view-header .btn-sm svg {
  flex-shrink: 0;
}

.company-pool-section {
  margin-bottom: 1.5rem;
}

.pool-table-wrap {
  overflow-x: auto;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
}

.pool-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.pool-table th,
.pool-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.pool-table th {
  background: var(--chip-bg);
  font-weight: 600;
  color: var(--text-secondary);
}

.pool-table tbody tr:last-child td {
  border-bottom: none;
}

.pool-table .pool-action-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 0.35rem;
  border: 1px solid var(--accent-primary);
  background: transparent;
  color: var(--accent-primary);
  cursor: pointer;
}

.pool-table .pool-action-btn:hover {
  background: var(--accent-primary-soft);
}

.pool-table .pool-action-btn.pool-action-remove {
  border-color: var(--accent-negative);
  color: var(--accent-negative);
}

.pool-table .pool-action-btn.pool-action-remove:hover {
  background: var(--accent-negative-soft);
}

.pool-table .pool-action-btn.pool-action-customize {
  border-color: var(--text-muted);
  color: var(--text-secondary);
  margin-right: 0.35rem;
}

.pool-table .pool-action-btn.pool-action-customize:hover {
  background: var(--border-color);
}

/* Toplu ilişki ekle – Excel benzeri tablo */
.bulk-contacts-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.bulk-contacts-table-wrap {
  overflow-x: auto;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  max-height: 20rem;
  overflow-y: auto;
}

.bulk-contacts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.bulk-contacts-table th,
.bulk-contacts-table td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.bulk-contacts-table th {
  background: var(--chip-bg);
  font-weight: 600;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.bulk-contacts-table td {
  background: var(--bg-secondary);
}

.bulk-contacts-table tbody tr:hover td {
  background: var(--chip-bg);
}

.bulk-contacts-table .bulk-contacts-input {
  width: 100%;
  min-width: 6rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: 0.35rem;
  background: var(--bg-secondary);
}

.bulk-contacts-table .bulk-contacts-input:focus {
  outline: none;
  border-color: var(--accent);
}

.bulk-contacts-table .bulk-contacts-select {
  width: 100%;
  min-width: 9rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: 0.35rem;
  background: var(--bg-secondary);
}

.bulk-contacts-table .bulk-row-remove {
  padding: 0.25rem;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0.25rem;
}

.bulk-contacts-table .bulk-row-remove:hover {
  color: var(--accent-negative);
  background: var(--accent-negative-soft);
}

.id-list-table-wrap {
  overflow-x: auto;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  max-height: 20rem;
  overflow-y: auto;
}

.transaction-entries-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transaction-entry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--chip-bg);
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
}

.transaction-entry-color {
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  flex-shrink: 0;
}

.transaction-entry-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.transaction-entry-label {
  font-weight: 500;
  color: var(--text-primary);
}

.transaction-entry-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.transaction-entry-actions {
  display: flex;
  gap: 0.35rem;
}

.company-member-assigned-role {
  font-size: 0.75rem;
  color: var(--accent-primary);
  margin-top: 0.15rem;
}

.company-member-assigned-select {
  margin-top: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.35rem;
  background: var(--input-bg);
  color: var(--text-primary);
  max-width: 10rem;
}

.company-members-section {
  margin-bottom: 1rem;
}

.company-add-member-inline {
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.company-add-member-inline[hidden] {
  display: none !important;
}

.form-details-toggle {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-details-toggle[hidden] {
  display: none !important;
}

.ledger-entries-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.ledger-entry-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ledger-entry-row .ledger-entry-ledger,
.ledger-entry-row .searchable-select-wrap {
  flex: 1;
  min-width: 0;
}

.ledger-entry-row .ledger-entry-no {
  width: 5rem;
  flex-shrink: 0;
}

.ledger-entry-row .ledger-entry-remove {
  flex-shrink: 0;
  min-width: 2rem;
}

.transaction-form .form-group {
  margin-bottom: 1rem;
}

.transaction-form .form-group:last-of-type {
  margin-bottom: 0;
}

.transaction-form .form-actions {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.form-actions .btn-primary,
.form-actions .btn-secondary {
  flex: 1;
}

/* ========================================
   Buttons
   ======================================== */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: none;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.btn-secondary:hover {
  background: var(--btn-secondary-hover);
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  background: var(--accent-negative);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: #a83d3d;
}

.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  background: transparent;
  color: var(--accent-negative);
  border: 1px solid var(--accent-negative);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-danger-outline:hover {
  background: var(--accent-negative-soft);
}

.company-danger-zone {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.company-danger-zone .btn-danger {
  width: 100%;
}

.profile-leave-company {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

.btn-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ========================================
   Ledger detail
   ======================================== */

.page-modal.ledger-detail-modal {
  max-width: 560px;
}

.ledger-detail-header {
  border-left: 4px solid var(--accent);
}

.ledger-detail-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.ledger-detail-body {
  padding: 1.25rem 1.5rem 1.75rem;
}

.ledger-detail-hero {
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--chip-bg) 0%, color-mix(in oklch, var(--chip-bg) 90%, var(--accent) 10%) 100%);
  border-radius: 1rem;
  border: 1px solid var(--border-color);
}

.ledger-detail-hero-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.ledger-detail-hero-balances {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ledger-hero-balance-item {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.ledger-hero-balance-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ledger-hero-balance-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.ledger-hero-balance-value {
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ledger-hero-balance-value.positive {
  color: var(--accent);
}

.ledger-hero-balance-value.negative {
  color: var(--accent-negative);
}

.ledger-hero-balance-status {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.ledger-detail-section {
  margin-bottom: 1.5rem;
}

.ledger-detail-section:last-child {
  margin-bottom: 0;
}

.ledger-detail-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.75rem;
}

.ledger-detail-table-wrap {
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  overflow: hidden;
}

.ledger-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ledger-detail-table th,
.ledger-detail-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.ledger-detail-table th {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  background: var(--chip-bg);
}

.ledger-detail-table tr:last-child td {
  border-bottom: none;
}

.ledger-contact-th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.ledger-contact-th-sortable:hover {
  color: var(--text-primary);
}

.ledger-contact-th-sortable .sort-arrow {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.65em;
  opacity: 0.5;
}

.ledger-contact-th-sortable.sort-asc .sort-arrow,
.ledger-contact-th-sortable.sort-desc .sort-arrow {
  opacity: 1;
}

.ledger-contact-th-sortable.sort-asc .sort-arrow::before {
  content: "▲";
}

.ledger-contact-th-sortable.sort-desc .sort-arrow::before {
  content: "▼";
}

.ledger-contact-th-sortable:not(.sort-asc):not(.sort-desc) .sort-arrow::before {
  content: "↕";
  opacity: 0.4;
}

.ledger-contact-row {
  cursor: pointer;
  transition: background 0.15s;
}

.ledger-contact-row:hover {
  background: var(--chip-bg);
}

.ledger-contact-name {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
}

.ledger-contact-no {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.ledger-contact-balance-cell {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
}

.ledger-contact-balance-part {
  font-weight: 600;
}

.ledger-contact-balance-part.positive {
  color: var(--accent);
}

.ledger-contact-balance-part.negative {
  color: var(--accent-negative);
}

.ledger-contact-balance {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ledger-contact-balance.positive {
  color: var(--accent);
}

.ledger-contact-balance.negative {
  color: var(--accent-negative);
}

.ledger-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.ledger-stat-card {
  padding: 1rem;
  background: var(--chip-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
}

.ledger-stat-card-compact {
  padding: 0.85rem;
}

.ledger-stat-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.ledger-stat-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.ledger-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 0.2rem 0;
  color: var(--text-muted);
}

.ledger-stat-row span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.ledger-stat-row.ledger-stat-net {
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--text-primary);
}

.ledger-stat-total {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.ledger-stat-total:not(:first-of-type) {
  margin-top: 0.15rem;
}

.ledger-stat-total.alacak {
  color: var(--accent);
}

.ledger-stat-total.borc {
  color: var(--accent-negative);
}

/* ========================================
   Contact detail
   ======================================== */

.contact-detail-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.contact-detail-section {
  margin-bottom: 1.5rem;
}

.contact-detail-section:last-child {
  margin-bottom: 0;
}

.contact-detail-hero {
  margin-bottom: 0;
}

.contact-detail-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 0.75rem 0;
}

.contact-detail-info-card {
  padding: 1rem 1.25rem;
  background: var(--chip-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
}

.contact-detail-info-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.contact-detail-info-row {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.5rem;
  align-items: start;
  font-size: 0.9rem;
}

.contact-detail-info-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.contact-detail-info-value {
  word-break: break-word;
}

.contact-detail-info-value-block {
  display: block;
  line-height: 1.5;
}

.contact-detail-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.contact-detail-ledgers {
  margin-top: 0.25rem;
}

.contact-detail-ledgers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.contact-ledger-card {
  padding: 1rem;
  background: var(--chip-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.contact-ledger-card:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.contact-ledger-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.contact-ledger-balances {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.contact-ledger-balance-row {
  font-size: 0.9rem;
}

.contact-ledger-balance-value.positive {
  color: var(--accent);
  font-weight: 600;
}

.contact-ledger-balance-value.negative {
  color: var(--accent-negative);
  font-weight: 600;
}

.contact-detail-transactions {
  margin-top: 0.25rem;
}

.balance-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
}

.balance-value.positive {
  color: var(--accent);
}

.balance-value.negative {
  color: var(--accent-negative);
}

.balance-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.balance-hint {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.transaction-history {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transaction-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--chip-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
}

.transaction-item-type {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
}

.transaction-item-type.alacak {
  background: var(--accent-soft);
  color: var(--accent);
}

.transaction-item-type.borc {
  background: var(--accent-negative-soft);
  color: var(--accent-negative);
}

.transaction-item-content {
  flex: 1;
  min-width: 0;
}

.transaction-item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.transaction-item-contact {
  font-size: 0.85rem;
  font-weight: 500;
}

.transaction-item-note {
  font-size: 0.9rem;
}

.transaction-item-amount {
  font-weight: 600;
  flex-shrink: 0;
}

.transaction-item-amount.positive {
  color: var(--accent);
}

.transaction-item-amount.negative {
  color: var(--accent-negative);
}

/* Hareket ayrıntı modalı */
.transaction-detail-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.transaction-detail-row {
  display: grid;
  grid-template-columns: 5rem 1fr;
  align-items: start;
  gap: 0.75rem;
}
.transaction-detail-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.transaction-detail-value {
  font-size: 1rem;
}
.transaction-detail-value.amount {
  font-weight: 600;
  font-size: 1.1rem;
}
.transaction-detail-value.amount.positive { color: var(--accent); }
.transaction-detail-value.amount.negative { color: var(--accent-negative); }
.transaction-detail-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* ========================================
   Auth header & modal
   ======================================== */

.auth-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 200;
  padding: 0.25rem 1rem;
  background: var(--bg-primary);
}

.auth-header-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.auth-header-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.auth-header-logo-img {
  height: clamp(1.75rem, 5vw, 2rem);
  width: auto;
  display: block;
}

.auth-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.btn-profile:hover {
  color: var(--text-primary);
  background: var(--chip-bg);
  border-color: var(--text-muted);
}

.auth-header.auth-authenticated .btn-profile {
  display: none !important;
}

.auth-header:not(.auth-authenticated) .auth-user-menu {
  display: none !important;
}

.auth-company-badge {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--chip-bg);
  padding: 0.2rem 0.5rem;
  border-radius: 0.35rem;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-user-trigger {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.35rem;
  background: transparent;
  border: none;
  border-radius: 0.35rem;
  font-family: inherit;
  font-size: 0.72rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-user-trigger:hover {
  background: var(--chip-bg);
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  height: 24px;
}

.user-name {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.65rem;
  line-height: 1.1;
  font-weight: 500;
}

.user-company {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.55rem;
  line-height: 1.1;
  color: var(--text-muted);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 300;
}

.profile-dropdown[hidden] {
  display: none !important;
}

.profile-menu {
  background: var(--bg-secondary);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  padding: 0.25rem;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0.4rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.profile-menu-item .profile-menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  opacity: 0.9;
}

.profile-menu-item:hover {
  background: var(--chip-bg);
  color: var(--text-primary);
}

.profile-menu-item:hover .profile-menu-icon {
  color: var(--accent);
  opacity: 1;
}

.profile-menu-item-logout {
  margin-top: 0.25rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

.profile-menu-item-logout + .profile-menu-item-logout {
  border-top: none;
  margin-top: 0;
  padding-top: 0.6rem;
}

.profile-menu-item-logout:hover {
  background: var(--chip-bg);
}

.profile-menu-item-edit {
  border-top: 1px solid var(--border-color);
  margin-top: 0.25rem;
  padding-top: 0.5rem;
}

.profile-menu-item-edit:hover {
  background: var(--chip-bg);
}

.profile-menu-edit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.profile-menu-edit-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--chip-bg);
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
}

.profile-menu-edit-item-label {
  flex: 1;
  font-size: 0.95rem;
}

.profile-menu-edit-item-actions {
  display: flex;
  gap: 0.25rem;
}

.profile-menu-edit-item-actions button {
  padding: 0.35rem 0.5rem;
  border: none;
  background: var(--bg-secondary);
  border-radius: 0.35rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1;
}

.profile-menu-edit-item-actions button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.profile-menu-edit-item-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.profile-menu-edit-item[data-fixed="true"] .profile-menu-edit-item-actions {
  display: none;
}

/* Login sonrası bekleme ekranı */
.login-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-loading-overlay[hidden] {
  display: none !important;
}

.login-loading-content {
  text-align: center;
  color: var(--text-primary);
}

.login-loading-logo {
  height: 2.5rem;
  width: auto;
  margin-bottom: 1rem;
  opacity: 0.95;
}

.login-loading-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Auth modal */
.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.auth-modal-backdrop:not([hidden]) {
  opacity: 1;
  visibility: visible;
}

body.auth-modal-open {
  overflow: hidden;
}

.auth-modal {
  background: var(--bg-secondary);
  border-radius: 1rem;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
}

.auth-modal.auth-modal-sm {
  max-width: 320px;
}

.auth-modal-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1.25rem 1.5rem;
}

.auth-modal-logo {
  height: 2rem;
  width: auto;
  display: block;
}

.auth-modal-close {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0.5rem;
  transition: color 0.2s, background 0.2s;
}

.auth-modal-close[hidden] {
  display: none;
}

.auth-modal-close:hover {
  color: var(--text-primary);
  background: var(--chip-bg);
}

.auth-modal-body {
  padding: 1rem 1.25rem 1.25rem;
}

.auth-explanation {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.auth-error {
  display: none;
  font-size: 0.85rem;
  color: var(--accent-negative);
  margin-bottom: 0.75rem;
}

.auth-form-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--text-primary);
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.auth-tab {
  flex: 1;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.auth-tab:hover {
  color: var(--text-primary);
}

.auth-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.auth-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.auth-form-group input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--search-bg);
  transition: border-color 0.2s;
}

.auth-form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-submit {
  margin-top: 0.25rem;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.auth-submit:hover:not(:disabled) {
  background: var(--accent-hover);
}

.auth-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.auth-providers {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-providers[hidden] {
  display: none !important;
}

.auth-email-view {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-email-view[hidden] {
  display: none !important;
}

.auth-back {
  align-self: flex-start;
  background: none;
  border: none;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0;
  transition: color 0.2s;
}

.auth-back:hover {
  color: var(--text-primary);
}

.btn-provider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-provider + .btn-provider {
  margin-top: 0.5rem;
}

.btn-email {
  background: var(--search-bg);
  color: var(--text-primary);
}

.btn-email:hover:not(:disabled) {
  background: var(--chip-bg);
  border-color: var(--text-muted);
}

.btn-google {
  background: var(--search-bg);
  color: var(--text-primary);
}

.btn-google:hover:not(:disabled) {
  background: var(--chip-bg);
  border-color: var(--text-muted);
}

.btn-apple {
  background: #000;
  color: #fff;
  border-color: #000;
}

.btn-apple:hover:not(:disabled) {
  background: #333;
  border-color: #333;
}

[data-theme="dark"] .btn-apple,
[data-theme="dim"] .btn-apple {
  background: #fff;
  color: #000;
  border-color: #fff;
}

.auth-footer {
  margin: 1rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.auth-footer .footer-nav {
  margin-bottom: 0.25rem;
}

.auth-footer .footer-copyright {
  margin: 0;
  font-size: 0.55rem;
  color: var(--text-muted);
}

/* Giriş gerekli uyarısı */
.login-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  min-height: 200px;
}

.login-prompt p {
  margin: 0;
  color: var(--text-secondary);
}

.login-prompt[hidden] {
  display: none !important;
}

/* Şirket kurulum modalı */
.company-setup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.company-setup-backdrop[hidden] {
  display: none !important;
}

.company-setup-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.company-setup-create[hidden],
.company-setup-join[hidden] {
  display: none !important;
}

/* ========================================
   Footer
   ======================================== */

.site-footer {
  width: 100%;
  flex-shrink: 0;
  padding: 0.35rem 0.5rem;
  border-top: 1px solid var(--border-color);
}

.footer-inner {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.footer-info {
  margin: 0 0 0.25rem;
  font-size: 0.6rem;
  color: var(--text-muted);
}

.footer-info a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-info a:hover {
  color: var(--accent);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.75rem;
  margin-bottom: 0.25rem;
}

.footer-link {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--accent);
}

.footer-link-btn {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.footer-copyright {
  margin: 0;
  font-size: 0.55rem;
  color: var(--text-muted);
}
