:root {
  --primary: #0d6e6e;
  --primary-dark: #095555;
  --primary-light: #e8f5f5;
  --accent: #c9a227;
  --bg: #f4f7f7;
  --card: #ffffff;
  --text: #1a2e2e;
  --muted: #5c7373;
  --danger: #c0392b;
  --success: #1e8449;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(13, 110, 110, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  direction: rtl;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.site-header h1 { font-size: 1.25rem; font-weight: 700; }
.site-header p { font-size: 0.85rem; opacity: 0.9; margin-top: 0.25rem; }

.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 1rem;
}

.container-wide { max-width: 960px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-top: 1.25rem;
}

.card h2 {
  font-size: 1.1rem;
  color: var(--primary-dark);
  margin-bottom: 1rem;
  text-align: center;
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, transform 0.1s;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

.btn-sm { width: auto; padding: 0.5rem 1rem; font-size: 0.875rem; }

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

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid #d0dede;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.2s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.15);
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6cb; }
.alert-success { background: #eafaf1; color: var(--success); border: 1px solid #a9dfbf; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); }

.result-box {
  text-align: center;
  padding: 1rem 0;
}

.result-box .shelter-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0.5rem 0;
}

.result-box .address-link {
  display: inline-block;
  margin: 1rem 0;
  padding: 0.75rem 1.25rem;
  background: var(--primary-light);
  border-radius: 8px;
  font-weight: 600;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.nav-links a {
  padding: 0.5rem 0.85rem;
  background: var(--primary-light);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--primary-dark);
  text-decoration: none;
}

.home-actions { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.5rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--primary-light);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.stat-card .num { font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); }
.stat-card .lbl { font-size: 0.75rem; color: var(--muted); }

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

th, td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid #e8eeee;
  text-align: right;
}

th { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

.progress-bar {
  height: 6px;
  background: #e0eaea;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}

.progress-bar .fill.warn { background: var(--accent); }
.progress-bar .fill.full { background: var(--danger); }

.companion-fields { margin-top: 0.5rem; }

.footer, .site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.8;
}

.admin-shell {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  align-items: flex-start;
}

.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 0;
  position: sticky;
  top: 1rem;
}

.admin-sidebar-title {
  font-weight: 700;
  color: var(--primary-dark);
  padding: 0 1rem 0.75rem;
  border-bottom: 1px solid #e8eeee;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.admin-sidebar nav { display: flex; flex-direction: column; }

.admin-sidebar nav a {
  display: block;
  padding: 0.65rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  border-right: 3px solid transparent;
  transition: background 0.15s;
}

.admin-sidebar nav a:hover { background: var(--primary-light); text-decoration: none; }

.admin-sidebar nav a.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
  border-right-color: var(--primary);
}

.admin-sidebar nav a.logout { color: var(--danger); margin-top: 0.5rem; }

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

.admin-content .card { margin-top: 0; }

.search-bar {
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-bar input, .search-bar select {
  flex: 1;
  min-width: 140px;
  padding: 0.6rem 0.75rem;
  border: 1px solid #d0dede;
  border-radius: 8px;
  font-family: inherit;
}

.table-scroll { overflow-x: auto; max-height: 70vh; overflow-y: auto; }

.table-scroll table { font-size: 0.82rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-cancelled { background: #fdecea; color: var(--danger); }
.badge-assigned { background: #fff8e1; color: #b8860b; }
.badge-in { background: #eafaf1; color: var(--success); }
.badge-out { background: #e8f4fd; color: #2980b9; }

.stat-cancelled { background: #fdecea !important; }
.stat-cancelled .num { color: var(--danger) !important; }

.pagination { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary-dark);
  text-decoration: none;
  font-size: 0.85rem;
}
.pagination span { background: var(--primary); color: #fff; }

@media (max-width: 768px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; position: static; }
  .admin-sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .admin-sidebar nav a { border-right: none; border-bottom: 2px solid transparent; }
  .admin-sidebar nav a.active { border-bottom-color: var(--primary); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end; }
.inline-form .form-group { flex: 1; min-width: 140px; margin-bottom: 0; }

@media (min-width: 640px) {
  .site-header h1 { font-size: 1.5rem; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .stats-grid { grid-template-columns: repeat(5, 1fr); }
}
