/* ==========================================================================
   Телефонний довідник КНУВС
   ========================================================================== */

:root {
  --bg-page: #f5f7fb;
  --bg-surface: #ffffff;
  --bg-subtle: #eef2f8;
  --navy-950: #0a192f;
  --navy-900: #0f294a;
  --navy-800: #173d6e;
  --blue-600: #1d4ed8;
  --blue-500: #2563eb;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;
  --gold-500: #d97706;
  --gold-400: #f59e0b;
  --emerald-600: #059669;
  --emerald-50: #ecfdf5;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px -4px rgba(15, 41, 74, 0.08);
  --shadow-lg: 0 20px 40px -12px rgba(10, 25, 47, 0.18);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  scroll-behavior: smooth;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-page);
  line-height: 1.5;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  background: #f0e6c2;
  color: #013220;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-emblem {
#  background: linear-gradient(135deg, var(--blue-500), #f0e6c2);
  background: #f0e6c2;
  color: #013220;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
#  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-uni {
  font-size: 0.92rem;
  font-weight: 600;
  color: #013220;
}

.brand-sub {
  font-size: 0.76rem;
  color: #94a3b8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #012320;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.btn-outline-sm {
  text-decoration: none;
  color: #013220;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
#  border: 1px solid rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(0, 0, 0, 0.22);
  transition: var(--transition);
}

.btn-outline-sm:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
}

/* Hero Section */
.hero {
  background: radial-gradient(circle at 85% 15%, rgba(37, 99, 235, 0.28) 0%, transparent 45%),
              linear-gradient(135deg, var(--navy-950) 0%, var(--navy-900) 55%, var(--navy-800) 100%);
  color: #ffffff;
  padding: 48px 0 44px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-kicker {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #93c5fd;
  margin-bottom: 10px;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 14px;
}

.accent-text {
  background: linear-gradient(90deg, #60a5fa, #fcd34d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  max-width: 680px;
  font-size: 1.05rem;
  color: #cbd5e1;
}

/* Main Section */
.main-section {
  flex: 1;
  padding: 36px 0 60px;
}

.section-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy-950);
  letter-spacing: -0.015em;
}

.section-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.btn-ghost {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-ghost:hover {
  border-color: var(--blue-500);
  color: var(--blue-600);
  background: var(--blue-50);
}

/* Filter Card */
.filter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1.2fr 1fr auto;
  gap: 14px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  font-size: 0.9rem;
  pointer-events: none;
  opacity: 0.65;
}

.filter-group input,
.filter-group select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0 12px;
  transition: var(--transition);
}

.filter-group input {
  padding-left: 36px;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.btn-reset {
  height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-reset:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #b91c1c;
}

/* Status Box */
.status-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--blue-100);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Table Card */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.directory-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.directory-table thead {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
}

.directory-table th {
  padding: 14px 16px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  white-space: nowrap;
}

.directory-table td {
  padding: 15px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.directory-table tbody tr {
  transition: background-color 0.15s ease;
}

.directory-table tbody tr:hover {
  background-color: #f8fbff;
}

.directory-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table Cell Elements */
.unit-cell {
  min-width: 200px;
  max-width: 260px;
}

.badge-type {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--blue-50);
  color: var(--blue-600);
  border: 1px solid var(--blue-100);
  margin-bottom: 5px;
}

.subdivision-name {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--navy-900);
  line-height: 1.35;
}

.position-cell {
  min-width: 160px;
  max-width: 230px;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.person-cell {
  min-width: 180px;
  font-weight: 600;
  color: var(--text-main);
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 165px;
}

.contact-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--navy-800);
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  padding: 4px 9px;
  border-radius: 6px;
  width: fit-content;
  transition: var(--transition);
}

.contact-chip:hover {
  background: var(--blue-50);
  border-color: var(--blue-500);
  color: var(--blue-600);
}

.email-chip {
  color: var(--blue-600);
  word-break: break-all;
}

.location-cell {
  min-width: 160px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.btn-detail {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--navy-900);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.btn-detail:hover {
  background: var(--navy-900);
  color: #ffffff;
  border-color: var(--navy-900);
}

/* Empty State */
.empty-state {
  padding: 56px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 2.4rem;
  margin-bottom: 10px;
}

.empty-state h3 {
  font-size: 1.15rem;
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 18px;
}

.btn-primary {
  background: var(--blue-600);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

/* Pagination */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
}

.page-info {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
  border-color: var(--blue-500);
  color: var(--blue-600);
}

.page-btn.active {
  background: var(--navy-900);
  color: #ffffff;
  border-color: var(--navy-900);
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 47, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 540px;
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-close {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy-950);
  margin-bottom: 4px;
}

.modal-position {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.modal-details-grid {
  display: grid;
  gap: 14px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy-950);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: var(--transition);
  z-index: 80;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Footer */
.site-footer {
  background: var(--navy-950);
  color: #94a3b8;
  padding: 28px 0;
  font-size: 0.85rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-inner strong {
  color: #f8fafc;
  display: block;
  margin-bottom: 3px;
}

.footer-links {
  display: flex;
  gap: 18px;
}

.footer-links a {
  color: #93c5fd;
  text-decoration: none;
  font-weight: 500;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 1024px) {
  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }
  .search-group {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .filter-grid {
    grid-template-columns: 1fr;
  }
  .section-top {
    flex-direction: column;
    align-items: flex-start;
  }
}
