:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-hover: #f0f4f8;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: var(--shadow);
}

.logo {
  padding: 0 1.25rem 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo span { color: var(--accent); }

.nav a {
  display: block;
  padding: 0.65rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.nav a:hover, .nav a.active {
  color: var(--accent);
  background: #eff6ff;
  border-left-color: var(--accent);
  text-decoration: none;
}

.main { padding: 2rem 2.5rem; max-width: 1200px; }

.page-header {
  margin-bottom: 1.75rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}

.page-header p {
  color: var(--muted);
  margin-top: 0.25rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-card .label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  background: #fafbfc;
}

.card-body { padding: 1.25rem; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  background: #fafbfc;
}

tr:hover td { background: var(--surface-hover); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: var(--success); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-muted { background: #f1f5f9; color: var(--muted); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-info { background: #dbeafe; color: var(--accent); }

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: white;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  text-decoration: none;
  color: var(--text);
}

.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }

input, select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  min-width: 180px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.pagination {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  align-items: center;
}

.pagination .muted { color: var(--muted); font-size: 0.875rem; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.detail-item label {
  display: block;
  margin-bottom: 0.25rem;
}

.detail-item .value { font-size: 1rem; color: var(--text); }

.actions { display: flex; gap: 0.5rem; margin-top: 1.5rem; flex-wrap: wrap; }

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

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: var(--success);
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
}

.parse-live-banner {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
  display: none;
  align-items: center;
  gap: 0.75rem;
  max-width: min(520px, calc(100vw - 2rem));
  padding: 0.75rem 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  color: var(--text);
  font-size: 0.875rem;
}

.company-hero {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.company-hero h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.company-hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.company-rating-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.company-hours-status {
  margin-top: 0.5rem;
  color: var(--success);
  font-weight: 500;
}

.company-hero-photo img {
  width: 220px;
  height: 160px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.company-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.company-section .detail-item + .detail-item {
  margin-top: 1rem;
}

.company-contacts {
  display: grid;
  gap: 1rem;
}

.contact-block label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.contact-list li + li {
  margin-top: 0.25rem;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.social-chip {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--accent);
  font-size: 0.8rem;
  text-decoration: none;
  text-transform: capitalize;
}

.social-chip:hover {
  background: #dbeafe;
  text-decoration: none;
}

.hours-table {
  width: 100%;
  border-collapse: collapse;
}

.hours-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.hours-table td:first-child {
  color: var(--muted);
  width: 40%;
}

.hours-text {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.photo-thumb {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 4 / 3;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.photo-thumb:hover img {
  transform: scale(1.03);
}

.value.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .company-hero {
    grid-template-columns: 1fr;
  }
  .company-hero-photo img {
    width: 100%;
    height: 200px;
  }
  .company-grid {
    grid-template-columns: 1fr;
  }
}

.log-viewer {
  margin: 0;
  padding: 1rem;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  overflow: auto;
  max-height: 70vh;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(160deg, #eff6ff 0%, var(--bg) 50%, #f0fdf4 100%);
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

.login-box h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.login-box p { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

.login-box input { width: 100%; min-width: unset; margin-bottom: 1rem; }

.login-box .btn { width: 100%; text-align: center; padding: 0.65rem; }

.rating { color: var(--warning); font-weight: 600; }

code {
  background: #f1f5f9;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
}

pre {
  background: #f8fafc !important;
  border: 1px solid var(--border);
  color: var(--text);
}

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
  .detail-grid { grid-template-columns: 1fr; }
}
