/* ==========================================================================
   ŞİRKET PANEL — Tasarım Sistemi
   Native mobil uygulama hissi: sistem fontu, alt sekme çubuğu,
   grouped-list kartlar, dokunmatik hedefler ≥44px.
   ========================================================================== */

:root {
  /* Renkler */
  --bg-app: #0E1015;          /* alt sekme / shell arka planı */
  --bg-page: #F4F5F8;         /* içerik arka planı */
  --bg-card: #FFFFFF;
  --border: #E7E9EE;

  --text-primary: #12141A;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;

  --accent: #3A5FE0;          /* ana marka rengi - güven veren mavi */
  --accent-soft: #EAEEFD;

  --success: #16A34A;
  --success-soft: #E7F7EC;
  --warning: #C8790A;
  --warning-soft: #FDF1DE;
  --danger: #E23F3F;
  --danger-soft: #FBE9E9;

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-card: 0 1px 2px rgba(16,20,30,0.04), 0 8px 24px rgba(16,20,30,0.06);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

button, input, select, textarea { font-family: inherit; }

/* ---------- App Shell ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- Top Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244,245,248,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: calc(var(--safe-top) + 14px) 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.topbar .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.topbar-action {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
}

/* ---------- Content ---------- */
.content {
  flex: 1;
  padding: 8px 20px calc(96px + var(--safe-bottom));
}

/* ---------- Stat cards (dashboard) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 20px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.stat-card .label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-card .value {
  font-size: clamp(16px, 3.5vw, 24px);
  font-weight: 800;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.stat-card.accent .value { color: var(--accent); }
.stat-card.warn .value { color: var(--warning); }
.stat-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Section ---------- */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 20px 4px 8px;
}

/* ---------- Grouped list card (iOS-style) ---------- */
.list-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:active { background: #F7F8FB; }

.avatar {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}

.row-main { flex: 1; min-width: 0; }
.row-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 1px;
}
.row-chevron { color: var(--text-tertiary); flex-shrink: 0; }

/* ---------- Status pill ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill.active { background: var(--success-soft); color: var(--success); }
.pill.active .dot { background: var(--success); }
.pill.pending_payment { background: var(--warning-soft); color: var(--warning); }
.pill.pending_payment .dot { background: var(--warning); }
.pill.suspended { background: var(--danger-soft); color: var(--danger); }
.pill.suspended .dot { background: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; width: auto; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

/* ---------- Inventory tabs ---------- */
.inv-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.inv-tab-btn {
  padding: 8px 18px; border-radius: 20px; border: 1.5px solid var(--border);
  background: var(--bg-card); color: var(--text-secondary); font-size: 13px;
  font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.inv-tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.inv-tab-btn:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* ---------- Kanban Board ---------- */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  align-items: start;
}
@media (min-width: 900px) {
  .kanban-board { grid-template-columns: repeat(4, 1fr); }
}
.kanban-col {
  background: var(--bg-card);
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.kanban-col-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; font-size: 13px; font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.kanban-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kanban-count {
  margin-left: auto; background: var(--border);
  font-size: 11px; font-weight: 700; min-width: 20px; height: 20px;
  border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 6px;
}
.kanban-cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card {
  background: var(--bg-page); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.kanban-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-1px); }
.kanban-add {
  text-align: center; padding: 8px; font-size: 12px;
  color: var(--text-secondary); cursor: pointer; border-radius: 8px;
  border: 1.5px dashed var(--border); transition: all 0.15s;
}
.kanban-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- Finance chart grid (mobile: stack) ---------- */
.fin-chart-grid { grid-template-columns: 1fr !important; }
@media (min-width: 900px) { .fin-chart-grid { grid-template-columns: 1fr 1fr !important; } }

/* ---------- Generic field-group (used in sheets) ---------- */
.field-group { margin-bottom: 14px; }
.field-group label {
  display: block; font-size: 13px; font-weight: 700;
  color: var(--text-secondary); margin-bottom: 6px;
}
.input {
  width: 100%; min-height: 44px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-card); font-size: 14px; color: var(--text-primary);
  box-sizing: border-box;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { cursor: pointer; }

/* ---------- Spinner center ---------- */
.spinner-center { display: flex; justify-content: center; align-items: center; padding: 60px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 15px;
  color: var(--text-primary);
}
.field textarea { padding: 12px 14px; min-height: 80px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Bottom Tab Bar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  z-index: 30;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  position: relative;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }
.tab .badge {
  position: absolute;
  top: 0px; right: calc(50% - 18px);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ---------- Modal sheet (mobil app tarzı alttan açılan panel) ---------- */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(10,12,18,0.45);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet {
  background: var(--bg-page);
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(24px + var(--safe-bottom));
  max-height: 88vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(.32,.72,0,1);
}
.sheet-overlay.open .sheet { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin: 6px auto 14px;
}
.sheet h2 { font-size: 19px; font-weight: 800; margin: 0 0 16px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}
.empty .emoji { font-size: 36px; margin-bottom: 10px; }
.empty .title { font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.empty .desc { font-size: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(100px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1B1D24;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 28px calc(24px + var(--safe-bottom));
  max-width: 480px;
  margin: 0 auto;
}
.login-logo {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 22px;
  margin-bottom: 18px;
}
.login-screen h1 { font-size: 26px; font-weight: 800; margin: 0 0 6px; letter-spacing: -0.02em; }
.login-screen p.sub { color: var(--text-secondary); margin: 0 0 28px; font-size: 15px; }

.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, #ECEEF2 25%, #F5F6F8 37%, #ECEEF2 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ==========================================================================
   DESKTOP — geniş, kullanışlı admin paneli
   Mobilde: tek kolon app-shell + alt sekme çubuğu (yukarıdaki kurallar)
   Masaüstünde (≥ 960px): sol sidebar + geniş çalışma alanı + tablo görünümü
   ========================================================================== */

.sidebar { display: none; }          /* mobilde gizli */
.desktop-col, .desktop-only { display: none; }  /* mobilde gizli */
.desktop-header-row { display: none; }

@media (min-width: 960px) {

  body { background: var(--bg-page); }

  .tabbar { display: none; }
  .sheet-overlay { align-items: center; }
  .sheet {
    border-radius: var(--radius-lg);
    max-width: 520px;
    max-height: 82vh;
    transform: translateY(12px) scale(0.98);
    box-shadow: 0 20px 60px rgba(16,20,30,0.25);
  }
  .sheet-overlay.open .sheet { transform: translateY(0) scale(1); }
  .sheet-handle { display: none; }

  .app {
    max-width: none;
    flex-direction: row;
    min-height: 100vh;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: 264px;
    flex-shrink: 0;
    background: var(--bg-app);
    color: #fff;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
  }
  .sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 26px; }
  .sidebar-logo .mark {
    width: 34px; height: 34px; border-radius: 10px; background: var(--accent);
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px;
  }
  .sidebar-logo .name { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
  .sidebar-logo .name .role { display: block; font-size: 11px; font-weight: 600; color: #9AA3B5; }

  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .sidebar-link {
    display: flex; align-items: center; gap: 12px; padding: 11px 14px;
    border-radius: var(--radius-sm); color: #B7BECF; text-decoration: none;
    font-size: 14px; font-weight: 600; position: relative;
  }
  .sidebar-link svg { width: 19px; height: 19px; flex-shrink: 0; }
  .sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
  .sidebar-link.active { background: var(--accent); color: #fff; }
  .sidebar-link .badge {
    margin-left: auto; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800;
    min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
  }
  .sidebar-footer { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 14px; display: flex; align-items: center; gap: 10px; }
  .sidebar-footer .avatar { background: rgba(255,255,255,0.1); color: #fff; width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
  .sidebar-footer .who { flex: 1; min-width: 0; }
  .sidebar-footer .who .n { font-size: 13px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar-footer .who .e { font-size: 11.5px; color: #8B93A7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar-footer button {
    background: transparent; border: none; color: #8B93A7; cursor: pointer; width: 30px; height: 30px;
    border-radius: var(--radius-sm); flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  }
  .sidebar-footer button:hover { background: rgba(255,255,255,0.08); color: #fff; }

  .content { flex: 1; padding: 0 40px 56px; max-width: 1280px; }

  .topbar { position: sticky; background: var(--bg-page); padding: 30px 40px 20px; margin: 0; border-bottom: 1px solid var(--border); }
  .topbar h1 { font-size: 28px; }
  .topbar .subtitle { font-size: 14px; }
  .topbar-action { width: 40px; height: 40px; }
  .topbar-action.btn-desktop-expand {
    width: auto; border-radius: var(--radius-sm); padding: 0 18px; background: var(--accent); color: #fff;
    border: none; font-size: 14px; font-weight: 700; gap: 8px; min-height: 40px;
  }

  .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .stat-card { padding: 16px 18px; }
  .stat-card .value { font-size: clamp(16px, 1.6vw, 26px); }

  .desktop-header-row {
    display: flex; align-items: center; gap: 12px; padding: 0 16px 10px;
    font-size: 12px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em;
  }
  .list-row { padding: 13px 16px; gap: 16px; }
  .list-row:hover { background: #F7F8FB; }
  .row-title { font-size: 14.5px; }
  .desktop-col, .desktop-only { display: flex; align-items: center; }
  .desktop-col.col-email { color: var(--text-secondary); font-size: 13.5px; }
  .desktop-col.col-users { color: var(--text-secondary); font-size: 13.5px; justify-content: center; }
  .desktop-col.col-balance { font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }

  .col-name { flex: 1.6; min-width: 0; display: flex; align-items: center; gap: 12px; }
  .col-email { flex: 1.4; min-width: 0; }
  .col-users { flex: 0.6; }
  .col-balance { flex: 0.8; }
  .col-status { flex: 0.9; }
  .col-actions { flex: 0.5; display: flex; justify-content: flex-end; }

  .desktop-split { display: flex; gap: 24px; align-items: flex-start; }
  .desktop-split > .main { flex: 1.6; min-width: 0; }
  .desktop-split > .side { flex: 1; min-width: 320px; }

  .login-screen { max-width: 420px; background: var(--bg-card); border-radius: 24px; box-shadow: var(--shadow-card); margin: 40px auto; }
}

@media (min-width: 1280px) {
  .content { padding-left: 56px; padding-right: 56px; }
  .topbar { padding-left: 56px; padding-right: 56px; margin: 0; }
}
