* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 18px;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #0f172a;
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary);
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span {
  display: block;
  color: #94a3b8;
  font-size: 13px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 13px 14px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  cursor: pointer;
  font-size: 15px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-link.active {
  background: #fff;
  color: #0f172a;
  font-weight: 800;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-footer span {
  display: block;
  color: #94a3b8;
  font-size: 13px;
}

.sidebar-footer strong {
  display: block;
  margin-top: 4px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

h1,
h2,
h3 {
  margin: 0;
}

.topbar h1 {
  font-size: 30px;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

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

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 18px;
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.stat-card span {
  color: var(--muted);
  font-size: 14px;
}

.stat-card strong {
  display: block;
  font-size: 34px;
  margin-top: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field-full {
  grid-column: 1 / -1;
}

label {
  color: #374151;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
}

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

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

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

.btn-muted {
  background: #eef2ff;
  color: #3730a3;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-muted {
  background: #f3f4f6;
  color: #4b5563;
}

.empty,
.loading {
  padding: 24px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px dashed var(--border);
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: #111827;
  color: #fff;
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
  z-index: 50;
}

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

.toast.error {
  background: var(--danger);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
}

.day-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-number {
  font-weight: 900;
  font-size: 18px;
}

.day-card.closed {
  background: #f3f4f6;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

.debug-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #374151;
  line-height: 1.5;
}

.log-line strong {
  color: #111827;
}

.log-ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.log-warning {
  border-color: #fde68a;
  background: #fffbeb;
}

.log-error {
  border-color: #fecaca;
  background: #fef2f2;
}

.log-info {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.debug-json {
  margin: 0;
  padding: 18px;
  border-radius: 16px;
  background: #0f172a;
  color: #e5e7eb;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.6;
}

.info-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 16px;
}

.info-label {
  color: #6b7280;
  font-weight: 800;
}

.info-value {
  color: #111827;
}

@media (max-width: 960px) {
  .grid[style] {
    grid-template-columns: 1fr !important;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

.operator-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.operator-pill {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
}

.operator-pill strong {
  color: #111827;
}

.operator-pill span {
  color: #4b5563;
  font-size: 13px;
}

.weekdays {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.weekdays label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  border-radius: 999px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}

.weekdays input {
  width: auto;
}

.month-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
}

.month-day {
  min-height: 150px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.month-day.empty-day {
  background: transparent;
  border: 0;
}

.month-day-number {
  font-weight: 900;
  font-size: 18px;
}

.month-day.today {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.month-day.closed {
  background: #f3f4f6;
}

.slot-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 9px;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 12px;
}

.slot-chip.closed {
  background: #fee2e2;
  border-color: #fecaca;
}

.slot-chip strong {
  font-size: 12px;
}

.slot-chip span {
  color: #4b5563;
}

.calendar-week-header {
  text-align: center;
  color: #6b7280;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  padding: 8px;
}

@media (max-width: 960px) {
  .month-calendar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}