* { box-sizing: border-box; }

.page-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 9999;
  transition: width 0.2s ease, opacity 0.3s ease;
  box-shadow: 0 0 8px var(--accent);
  pointer-events: none;
}
.page-loading-bar.done { opacity: 0; }

:root {
  --brand: #004aad;
  --brand-dark: #00285e;
  --accent: #2f7dfa;
  --accent-dark: #1a5fd6;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --text: #1a2233;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);

  --green-bg: #dcfce7; --green-text: #166534;
  --orange-bg: #fef3c7; --orange-text: #92400e;
  --blue-bg: #dbeafe; --blue-text: #1e40af;
  --red-bg: #fee2e2; --red-text: #991b1b;
  --gray-bg: #f1f5f9; --gray-text: #64748b;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1a2436;
  --surface-alt: #161f30;
  --text: #e6eaf2;
  --text-muted: #94a3b8;
  --border: #2a3650;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);

  --green-bg: rgba(34, 197, 94, 0.16); --green-text: #4ade80;
  --orange-bg: rgba(245, 158, 11, 0.16); --orange-text: #fbbf24;
  --blue-bg: rgba(59, 130, 246, 0.16); --blue-text: #60a5fa;
  --red-bg: rgba(239, 68, 68, 0.16); --red-text: #f87171;
  --gray-bg: rgba(148, 163, 184, 0.16); --gray-text: #94a3b8;
}

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: inherit; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: relative;
  transition: width 0.2s ease;
}

.sidebar-collapse-toggle {
  position: absolute;
  top: 18px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  box-shadow: var(--shadow);
}
.sidebar-collapse-toggle svg { width: 14px; height: 14px; transition: transform 0.2s ease; }

.sidebar .brand-block {
  padding: 0 20px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 12px;
  overflow: hidden;
}
.sidebar .brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar .brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}
.sidebar .brand-text { line-height: 1.2; white-space: nowrap; }
.sidebar .brand-text .name { font-size: 15px; font-weight: 700; }
.sidebar .brand-text .tagline { font-size: 11px; color: rgba(255, 255, 255, 0.65); }

.sidebar nav { display: flex; flex-direction: column; flex: 1; gap: 2px; padding: 0 10px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.logout-form { padding: 12px 20px 0; }
.logout-form button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  transition: background-color 0.15s ease;
}
.logout-form button:hover { background: rgba(239, 68, 68, 0.35); border-color: transparent; }

/* Collapsed sidebar (desktop only) */
html[data-sidebar-collapsed="1"] .sidebar { width: 76px; }
html[data-sidebar-collapsed="1"] .sidebar .brand-text,
html[data-sidebar-collapsed="1"] .sidebar nav a .label,
html[data-sidebar-collapsed="1"] .logout-form button .label {
  display: none;
}
html[data-sidebar-collapsed="1"] .sidebar nav a,
html[data-sidebar-collapsed="1"] .logout-form button {
  justify-content: center;
  padding: 10px;
}
html[data-sidebar-collapsed="1"] .sidebar-collapse-toggle svg { transform: rotate(180deg); }

/* Content */
.content { flex: 1; padding: 24px 32px; min-width: 0; overflow-x: auto; }
.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: background-color 0.15s ease;
}
.theme-toggle:hover { background: var(--surface-alt); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: var(--green-bg); color: var(--green-text); }
.alert-error { background: var(--red-bg); color: var(--red-text); }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-header h1 { margin: 0; font-size: 22px; font-weight: 700; }

.btn {
  display: inline-block;
  padding: 9px 18px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--gray-text); }
.btn-secondary:hover { opacity: 0.85; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--accent-color, var(--accent));
}
.stat-card .label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.stat-card .value { font-size: 27px; font-weight: 700; color: var(--text); }
.stat-card.green { --accent-color: #16a34a; }
.stat-card.orange { --accent-color: #ea580c; }
.stat-card.red { --accent-color: #dc2626; }
.stat-card.blue { --accent-color: var(--brand); }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table th, table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
table th { background: var(--surface-alt); font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
table tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: var(--surface-alt); }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-bekliyor { background: var(--orange-bg); color: var(--orange-text); }
.badge-yolda { background: var(--blue-bg); color: var(--blue-text); }
.badge-teslim_edildi { background: var(--green-bg); color: var(--green-text); }
.badge-iptal { background: var(--gray-bg); color: var(--gray-text); }
.badge-odenmedi { background: var(--red-bg); color: var(--red-text); }
.badge-kismi_odendi { background: var(--orange-bg); color: var(--orange-text); }
.badge-odendi { background: var(--green-bg); color: var(--green-text); }
.badge-musait { background: var(--green-bg); color: var(--green-text); }
.badge-bakimda { background: var(--red-bg); color: var(--red-text); }

.pagination { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.pagination .disabled { pointer-events: none; opacity: 0.4; }
.pagination-info { font-size: 13.5px; color: var(--text-muted); }

.search-box { flex: 1; max-width: 320px; }
.search-box input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
}

.filters { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filters select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
}

form.card { max-width: 640px; }
.form-row { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.form-row input, .form-row select, .form-row textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 58, 107, 0.15);
}
[data-theme="dark"] .form-row input:focus, [data-theme="dark"] .form-row select:focus, [data-theme="dark"] .form-row textarea:focus {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; }

.actions-cell { display: flex; gap: 8px; }
.actions-cell form { display: inline; }

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top left, var(--brand) 0%, var(--brand-dark) 55%, #081627 100%);
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  position: relative;
}
.login-theme-toggle { position: absolute; top: 20px; right: 20px; }
.login-box {
  background: var(--surface);
  color: var(--text);
  padding: 36px 40px 40px;
  border-radius: 16px;
  width: 340px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.login-full-logo {
  display: block;
  width: 100%;
  max-width: 240px;
  margin: 0 auto 6px;
  border-radius: 12px;
}
.login-box .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 22px; font-size: 13px; }
.login-box label { display: block; font-size: 13px; margin-bottom: 6px; font-weight: 600; color: var(--text-muted); }
.login-box input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
.login-box input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 58, 107, 0.15);
}
.remember-me {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px !important;
  cursor: pointer;
  font-weight: 500 !important;
  color: var(--text) !important;
}
.remember-me input[type="checkbox"] {
  width: auto !important;
  margin: 0 !important;
  accent-color: var(--brand);
  cursor: pointer;
}
.remember-me span { font-size: 13.5px; }

.login-box button {
  width: 100%;
  padding: 11px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background-color 0.15s ease;
}
.login-box button:hover { background: var(--brand-dark); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.detail-grid .card h3 { margin-top: 0; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px 0; }

/* Mobile topbar + off-canvas menu (hidden on desktop) */
.mobile-topbar { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 860px) {
  body { padding-top: 56px; }
  .sidebar-collapse-toggle { display: none; }
  html[data-sidebar-collapsed="1"] .sidebar { width: 260px; }
  html[data-sidebar-collapsed="1"] .sidebar .brand-text,
  html[data-sidebar-collapsed="1"] .sidebar nav a .label,
  html[data-sidebar-collapsed="1"] .logout-form button .label {
    display: block;
  }
  html[data-sidebar-collapsed="1"] .sidebar nav a,
  html[data-sidebar-collapsed="1"] .logout-form button {
    justify-content: flex-start;
    padding: 10px 14px;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--brand);
    color: #fff;
    padding: 0 14px;
    z-index: 40;
    box-shadow: 0 1px 6px rgba(0,0,0,0.2);
  }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
  .mobile-brand img { width: 30px; height: 30px; border-radius: 8px; background: #fff; object-fit: contain; padding: 3px; }

  .hamburger {
    width: 38px; height: 38px;
    border: none;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .hamburger span { width: 18px; height: 2px; background: #fff; border-radius: 2px; }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 45;
  }
  .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

  .app { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 260px;
    max-width: 80vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 50;
    padding-top: 20px;
  }
  .sidebar.open { transform: translateX(0); }

  .content { padding: 16px; overflow-x: auto; }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header .btn { align-self: stretch; text-align: center; }
  .filters { flex-direction: column; align-items: stretch; }
  .search-box { max-width: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  body.menu-open { overflow: hidden; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-box { width: 100%; max-width: 320px; padding: 28px 22px 32px; }
}
