:root {
  --brand: #2f7d52;
  --brand-dark: #1c4d31;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --warn: #d97706;
}

html, body {
  overflow-x: hidden;
  width: 100%;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px;
  overflow-x: auto;
  max-width: 100%;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--brand);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin: 0 auto 12px;
}

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
p.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 24px; text-align: center; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 14px;
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  font-family: inherit;
}

.btn-primary { background: var(--brand); color: white; width: 100%; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-link { background: none; color: var(--brand); text-decoration: underline; padding: 0; }

.error-text { color: var(--danger); font-size: 13px; }
.success-text { color: var(--brand-dark); font-size: 13px; }

/* App shell layout */
.app-shell { display: flex; min-height: 100vh; flex-direction: column; width: 100%; max-width: 100vw; }
@media (min-width: 768px) {
  .app-shell { flex-direction: row; }
}

.sidebar {
  background: #0f172a;
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
@media (min-width: 768px) {
  .sidebar { flex-direction: column; align-items: stretch; width: 220px; padding: 20px 16px; }
}

.sidebar .brand-title { font-weight: 700; font-size: 16px; }
.sidebar .brand-sub { font-size: 12px; color: #94a3b8; display: none; }
@media (min-width: 768px) { .sidebar .brand-sub { display: block; } }

/* Asıl içerik #sidebar-nav'ın içine yazılıyor (renderShell ile), .sidebar'ın kendisi değil -
   bu yüzden flex düzeni doğrudan #sidebar-nav'a uygulanmalı, yoksa mobilde öğeler
   yan yana değil alt alta dizilip kaymaya neden oluyor. */
#sidebar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
}
@media (min-width: 768px) {
  #sidebar-nav { flex-direction: column; align-items: stretch; gap: 0; }
}

.nav-links { display: flex; gap: 4px; overflow-x: auto; flex: 1; min-width: 0; }
@media (min-width: 768px) { .nav-links { flex-direction: column; margin-top: 24px; } }

.nav-links a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
}
.nav-links a.active, .nav-links a:hover { background: var(--brand); color: white; }

.logout-link { margin-left: auto; color: #94a3b8; font-size: 13px; text-decoration: underline; background: none; border: none; cursor: pointer; }
@media (min-width: 768px) { .logout-link { margin-left: 0; margin-top: auto; } }

.main-content { flex: 1; padding: 16px; padding-bottom: 80px; min-width: 0; max-width: 100%; overflow-x: hidden; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 24px; }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(5, 1fr); } }

.stat-card { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.stat-card .label { font-size: 12px; color: var(--muted); }
.stat-card .value { font-size: 24px; font-weight: 700; margin-top: 4px; }

.branch-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 768px) { .branch-grid { grid-template-columns: repeat(3, 1fr); } }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; background: #f8fafc; }

.row-actions button, .row-actions a { font-size: 13px; margin-right: 8px; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; gap: 0 12px; } }

.section { margin-bottom: 24px; }

.qr-screen {
  min-height: 100vh;
  background: #0f172a;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}
.qr-box { background: white; padding: 24px; border-radius: 20px; }

.tabs { display: flex; gap: 4px; background: white; border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs button { flex: 1; background: none; color: var(--muted); padding: 10px; border-radius: 8px; }
.tabs button.active { background: var(--brand); color: white; }

#qr-reader { width: 100%; max-width: 300px; margin: 0 auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: #d7ecdc; color: var(--brand-dark); }
.badge-warn { background: #fef3c7; color: var(--warn); }
.badge-danger { background: #fee2e2; color: var(--danger); }