:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --border: #d0d0dd;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --text: #111827;
  --text-soft: #4b5563;
  --danger: #b91c1c;
  --radius: 10px;
  --slot-height: 18px;
  --event-min-height: 72px;
  --day-column-min-width: 220px;
}

* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 1.5rem 2rem;
  background: #0f172a;
  color: #e5e7eb;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

header h1 {
  margin: 0;
  font-size: 1.4rem;
}

header p {
  margin: 0;
  font-size: 0.9rem;
  color: #9ca3af;
}

main {
  padding: 1.5rem 2rem 2.5rem;
  display: grid;
  grid-template-columns: 2fr 1.5fr;
  gap: 1.5rem;
}

@media (max-width: 1100px) {
  main {
    grid-template-columns: 1fr;
  }
}

.fullwidth-wrapper {
  padding: 0 2rem 2.5rem;
}

section {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1rem 1.25rem 1.25rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

section h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

section p.section-subtitle {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn.btn-secondary {
  border-color: var(--border);
  background: #f9fafb;
  color: #111827;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.action-row {
  margin-top: 0.35rem;
}

.save-indicator {
  font-size: 0.85rem;
  color: #16a34a;
  font-weight: 700;
}

label {
  font-size: 0.8rem;
  color: var(--text-soft);
  display: block;
  margin-bottom: 0.1rem;
}

input[type="number"],
input[type="time"],
input[type="date"],
input[type="text"],
select {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  background: #f9fafb;
}

input[type="file"] {
  font-size: 0.85rem;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.field-row.single {
  grid-template-columns: minmax(0, 1fr);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #1e40af;
  font-size: 0.75rem;
}

.status {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: 0.25rem;
}

.status.ok {
  color: #15803d;
}

.status.error {
  color: var(--danger);
}

.table-wrapper {
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: #fff;
  max-height: 420px;
  overflow-y: auto;
  margin-top: 0.75rem;
}

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

thead {
  background: #f3f4f6;
  position: sticky;
  top: 0;
  z-index: 1;
}

th,
td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: #f9fafb;
}

.color-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 180px;
}

.color-select {
  min-width: 120px;
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-block;
}

.color-hex {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.75rem;
  color: var(--text-soft);
}

.small-btn {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9fafb;
  cursor: pointer;
}

.small-btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.pill {
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #f3f4f6;
  color: #374151;
  display: inline-block;
}

.hidden {
  display: none !important;
}

#windowEditor {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f9fafb;
}

.window-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr auto;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

#scheduleTable {
  margin-top: 0.75rem;
}

.day-load-bar {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.day-load-chip {
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #eef2ff;
  font-size: 0.75rem;
}

.weekday-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.weekday-boxes label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0;
}

.schedule-visual {
  margin-top: 1rem;
  --schedule-header-gap: 6px;
}

.schedule-visual h3 {
  margin: 0 0 0.15rem;
  font-size: 0.95rem;
}

.schedule-board {
  margin-top: 0.35rem;
  border: 1px solid #d9dde7;
  border-radius: 16px;
  padding: 0.9rem;
  background: #f9fafb;
  box-shadow: inset 0 1px 0 #fff, 0 14px 28px rgba(15, 23, 42, 0.06);
  overflow-x: auto;
}

.schedule-board.hidden {
  display: none;
}

.schedule-board .schedule-empty {
  color: var(--text-soft);
  font-size: 0.9rem;
  padding: 0.45rem 0.25rem;
}

.schedule-scroll {
  display: flex;
  gap: 0.65rem;
  min-width: 100%;
  align-items: stretch;
}

.schedule-time-column {
  position: relative;
  width: 80px;
  flex-shrink: 0;
  height: var(--board-height, 420px);
  font-size: 0.8rem;
  color: #6b7280;
}

.schedule-time-mark {
  position: absolute;
  left: 0;
  width: 100%;
  line-height: 1.2;
}

.schedule-time-mark .line {
  display: block;
  margin-top: 4px;
  height: 1px;
  background: #e5e7eb;
  opacity: 0.9;
}

.schedule-days {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(var(--day-column-min-width), 1fr);
  gap: 0.75rem;
  flex: 1;
}

.schedule-day {
  display: flex;
  flex-direction: column;
  gap: var(--schedule-header-gap);
  min-width: var(--day-column-min-width);
}

.schedule-day-title {
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: #f1f5f9;
  color: #111827;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  box-shadow: inset 0 1px 0 #fff;
  margin: 0;
}

.schedule-day-count {
  font-size: 0.75rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  border: 1px solid #d4d8dd;
}

.schedule-day-body {
  position: relative;
  border: 1px solid #d9dde7;
  border-radius: 12px;
  background: repeating-linear-gradient(
    to bottom,
    #f9fafb 0,
    #f9fafb calc(var(--slot-height, 18px) - 1px),
    #edf2fb calc(var(--slot-height, 18px) - 1px),
    #edf2fb var(--slot-height, 18px)
  );
  height: var(--board-height, 420px);
  padding: 6px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 #fff;
}

.schedule-day:not(:first-child) .schedule-day-body {
  box-shadow:
    inset 0 1px 0 #fff,
    inset 1px 0 0 #e5e7eb;
}

.schedule-event {
  position: absolute;
  left: 10px;
  right: 10px;
  border-radius: 12px;
  border: 2px solid #bfdbfe;
  background: #e0f2fe;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  line-height: 1.25;
  box-shadow: 0 12px 22px rgba(17, 24, 39, 0.08);
  min-height: var(--event-min-height);
  cursor: default;
}

.schedule-event .name {
  font-weight: 700;
  font-size: 0.95rem;
}

.schedule-event .meta {
  color: #4b5563;
  font-size: 0.82rem;
}

.schedule-event .meta.time {
  font-weight: 600;
  color: #1f2937;
}

.schedule-event.multiple {
  cursor: pointer;
}
