:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1e2a3a;
  --sidebar-text: #c8d6e5;
  --sidebar-hover: #2d3f55;
  --sidebar-active: #3d7fcf;
  --topbar-height: 56px;
}

* { -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: 'Segoe UI', sans-serif; background: #f0f4f8; -webkit-text-size-adjust: 100%; }

/* ---- Login ---- */
.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e2a3a 0%, #3d7fcf 100%);
  padding: 1rem;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 2rem;
  width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* ---- Layout ---- */
#sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-width);
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 1040;
  overflow-y: auto;
  transition: transform 0.25s ease;
  /* iOS PWA notch / home indicator icin */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.sidebar-header {
  padding: 1rem; font-size: 1.05rem; font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #fff; display: flex; align-items: center; gap: 0.5rem;
}
.sidebar-logout-btn {
  background: rgba(220,53,69,0.15); color: #ff6b7a; border: 1px solid rgba(220,53,69,0.3);
  padding: 0.3rem 0.55rem; line-height: 1; border-radius: 6px;
}
.sidebar-logout-btn:hover, .sidebar-logout-btn:active {
  background: rgba(220,53,69,0.85); color: #fff; border-color: rgba(220,53,69,0.9);
}
.sidebar-user-bar {
  padding: 0.6rem 1rem; display: flex; align-items: center;
  background: rgba(0,0,0,0.15); color: #c8d6e5;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 0.85rem;
}
.sidebar-user-bar .bi-person-circle { font-size: 1.4rem; }
#sidebar .nav-link {
  color: var(--sidebar-text); padding: 0.7rem 1rem;
  border-radius: 6px; margin: 1px 6px; font-size: 0.92rem;
  transition: background 0.15s;
}
#sidebar .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
#sidebar .nav-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar-footer {
  margin-top: auto; padding: 1rem; border-top: 1px solid rgba(255,255,255,0.08);
}
.user-info { font-size: 0.85rem; color: var(--sidebar-text); }

#mainContent {
  margin-left: var(--sidebar-width); min-height: 100vh; padding: 1.5rem;
  /* iOS PWA home indicator (alt) icin */
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}

/* ---- Topbar (sadece mobil) ---- */
#topbar {
  display: none; background: var(--sidebar-bg);
  color: #fff; align-items: center; gap: 0.5rem;
  position: sticky; top: 0; z-index: 1030;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  /* iOS PWA status bar / notch icin safe-area */
  padding: env(safe-area-inset-top) calc(0.75rem + env(safe-area-inset-right)) 0 calc(0.75rem + env(safe-area-inset-left));
  min-height: calc(var(--topbar-height) + env(safe-area-inset-top));
}
#topbar .topbar-title { font-weight: 700; flex: 1; font-size: 1rem; }
#sidebarToggle, #topbarLogout {
  background: transparent; border: 0; color: #fff; font-size: 1.5rem;
  width: 42px; height: 42px; border-radius: 6px; display: flex;
  align-items: center; justify-content: center;
}
#sidebarToggle:active, #topbarLogout:active { background: rgba(255,255,255,0.15); }
#topbarLogout { color: #ff9aa5; font-size: 1.35rem; }
#topbarLogout:hover, #topbarLogout:active { background: rgba(220,53,69,0.4); color: #fff; }

#sidebarBackdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1035;
}
#sidebarBackdrop.show { display: block; }

/* ---- Cards ---- */
.stat-card {
  background: #fff; border-radius: 12px; padding: 1rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 4px solid transparent;
  display: flex; align-items: center; gap: 0.9rem;
}
.stat-card .stat-icon { font-size: 2rem; opacity: 0.8; }
.stat-card .stat-val { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 0.78rem; color: #6c757d; margin-top: 2px; }
.stat-card.blue { border-color: #3d7fcf; } .stat-card.blue .stat-icon { color: #3d7fcf; }
.stat-card.green { border-color: #28a745; } .stat-card.green .stat-icon { color: #28a745; }
.stat-card.orange { border-color: #fd7e14; } .stat-card.orange .stat-icon { color: #fd7e14; }
.stat-card.red { border-color: #dc3545; } .stat-card.red .stat-icon { color: #dc3545; }

/* ---- Page header ---- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.5rem;
}
.page-header h4 { margin: 0; font-weight: 700; color: #1e2a3a; font-size: 1.25rem; }

/* ---- Table ---- */
.table-card {
  background: #fff; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); overflow: hidden;
}
.table-card .table { margin: 0; font-size: 0.875rem; }
/* ---- Uzun malzeme adi hucresi ---- */
.mat-name-cell {
  min-width: 260px;
  max-width: 480px;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
@media (max-width: 768px) {
  .mat-name-cell { min-width: 200px; max-width: 100%; }
}

.table-card .table thead th {
  background: #f8f9fa; border-bottom: 2px solid #dee2e6;
  font-weight: 600; color: #495057; white-space: nowrap;
}
.table-card .table tbody tr:hover { background: #f0f7ff; }

/* ---- Badges ---- */
.badge-IN { background: #d4edda; color: #155724; }
.badge-OUT { background: #f8d7da; color: #721c24; }
.badge-RETURN { background: #d1ecf1; color: #0c5460; }
.badge-ADJUST { background: #fff3cd; color: #856404; }
.badge-PENDING { background: #fff3cd; color: #856404; }
.badge-APPROVED { background: #d4edda; color: #155724; }
.badge-REJECTED { background: #f8d7da; color: #721c24; }
.badge-FULFILLED { background: #d1ecf1; color: #0c5460; }
.badge-CANCELLED { background: #e2e3e5; color: #383d41; }
.badge-status { padding: 3px 8px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }

/* ---- Stock level ---- */
.stock-zero { color: #dc3545; font-weight: 700; }
.stock-low { color: #fd7e14; font-weight: 600; }
.stock-ok { color: #28a745; }

/* ---- Search bar ---- */
.search-bar { max-width: 340px; }

/* ---- Pagination ---- */
.pagination-wrapper { padding: 0.75rem 1rem; background: #f8f9fa; border-top: 1px solid #dee2e6; flex-wrap: wrap; }

/* ---- Scrollable table ---- */
.table-responsive { max-height: 65vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.table-responsive thead th { position: sticky; top: 0; z-index: 1; }

/* ---- Form card ---- */
.form-card {
  background: #fff; border-radius: 12px; padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ---- Toast ---- */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; max-width: calc(100vw - 2rem); }

/* ---- Movement type icons ---- */
.mv-IN { color: #28a745; } .mv-OUT { color: #dc3545; }
.mv-RETURN { color: #17a2b8; } .mv-ADJUST { color: #fd7e14; }

/* iOS Safari icin form/input zoom engelle */
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], select, textarea {
  font-size: 16px;
}

/* ============ RESPONSIVE ============ */
/* Tablet (max 991px) */
@media (max-width: 991px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.4); }
  #mainContent { margin-left: 0; padding: 1rem; }
  #topbar { display: flex; }
  .search-bar { max-width: 100%; flex: 1 1 100%; }
}

/* Mobil (max 575px) */
@media (max-width: 575px) {
  #mainContent { padding: 0.75rem; }
  .page-header h4 { font-size: 1.1rem; }
  .stat-card { padding: 0.8rem; gap: 0.6rem; }
  .stat-card .stat-icon { font-size: 1.6rem; }
  .stat-card .stat-val { font-size: 1.3rem; }
  .stat-card .stat-label { font-size: 0.72rem; }
  .form-card { padding: 1rem; }
  .table-card .table { font-size: 0.78rem; }
  .table-card .table thead th, .table-card .table tbody td { padding: 0.45rem 0.4rem; }
  .badge-status { font-size: 0.7rem; padding: 2px 6px; }
  .modal-dialog { margin: 0.5rem; }
  .modal-body { padding: 1rem; }
  .btn-sm { padding: 0.3rem 0.6rem; font-size: 0.82rem; }
  /* Buton metinleri kucult */
  .page-header .btn { font-size: 0.82rem; }
  .login-card { padding: 1.5rem; }
}

/* Cok kucuk telefonlar (max 380px) */
@media (max-width: 380px) {
  .stat-card .stat-val { font-size: 1.15rem; }
  .table-card .table { font-size: 0.72rem; }
}
