:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #0b1320;
  --muted: #5a6575;
  --green: #3fa24a;
  --green-dark: #2f8a3b;
  --blue: #1351b4;
  --blue-dark: #0c326f;
  --line: #d4dbe4;
  --danger: rgb(200, 12, 15);
  --danger-dark: rgb(170, 10, 13);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Rawline", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--green);
  height: 71px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

.topbar a {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s ease, transform 0.15s ease;
}

.topbar a:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.topbar img {
  height: 40px;
  width: auto;
  display: block;
}

.container {
  width: min(1100px, 92vw);
  margin: 112px auto 40px;
}

.panel-wrap {
  width: min(760px, 94vw);
  margin: 112px auto 40px;
}

.wrap {
  max-width: 520px;
  margin: 112px auto 60px;
  padding: 20px;
}

.landing-wrap {
  max-width: 980px;
  margin: 140px auto 60px;
  padding: 20px;
}

.brand-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 0 auto 18px;
}

.brand-hero img {
  width: 84px;
  height: 84px;
  object-fit: contain;
}

.brand-title {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-hero-admin {
  margin-bottom: 14px;
}

.brand-hero-admin img {
  width: 72px;
  height: 72px;
}

.brand-hero-admin .brand-title {
  font-size: 2.4rem;
}

.landing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.landing-card {
  min-height: 220px;
  display: flex;
  flex-direction: column;
}

.landing-card h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.landing-card p {
  margin: 0 0 14px;
  color: var(--muted);
}

.landing-body {
  flex: 1;
}

.landing-action {
  min-height: 42px;
  display: flex;
  align-items: flex-end;
}

.landing-action .btn {
  width: 100%;
}

.hero {
  background: var(--card);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.row { display: grid; gap: 12px; }
.row-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

label {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 6px;
  color: var(--muted);
}

input[type="text"], input[type="password"], input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

button, .btn {
  border: none;
  border-radius: 6px;
  padding: 12px 16px;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-height: 42px;
  -webkit-appearance: none;
  appearance: none;
}

button:hover, .btn:hover { background: var(--green-dark); }
.btn-danger { background: var(--danger); }
.btn-danger:hover,
.btn-danger:focus {
  background: var(--danger-dark);
}
.btn-muted { background: #4b5563; }
.btn-full { width: 100%; }

.flash {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.flash-ok { background: #dcfce7; border: 1px solid #86efac; }
.flash-error { background: #fee2e2; border: 1px solid #fca5a5; }
.flash-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
  opacity: 0.86;
  transition: opacity 0.15s ease;
}
.flash-link:hover {
  opacity: 1;
}

.linkline { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.schedule-page .container { margin-top: 96px; }
.schedule-page .hero { margin-bottom: 14px; }
.detail-container { width: min(1600px, 98vw); }
.detail-hero h1 { font-size: 1.45rem; }
.detail-hero h1 { margin-bottom: 8px; }
.detail-card { padding: 12px; }
.detail-content {
  overflow: auto;
  max-width: 100%;
  max-height: calc(100vh - 240px);
  border-radius: 8px;
  border: 1px solid #dbe3ee;
  background: #fff;
}

.detail-content table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: #fff;
  table-layout: auto !important;
}

.detail-content caption {
  caption-side: top;
  text-align: left;
  font-weight: 700;
  padding: 10px 6px;
}

.detail-content th,
.detail-content td {
  border: 1px solid #cfd8e3;
  padding: 4px 6px;
  font-size: 0.78rem;
  line-height: 1.3;
  vertical-align: top;
  white-space: nowrap !important;
  overflow: visible;
  word-break: normal;
  min-width: 0;
  max-width: none;
  height: auto !important;
}

.detail-content tr {
  height: auto !important;
}

.detail-content thead th {
  position: sticky;
  top: 0;
  background: #eef3f9;
  z-index: 1;
}

.detail-home-link {
  color: #0b1320;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.detail-home-link:hover {
  opacity: 0.7;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.conflict-link {
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 600;
  color: var(--blue);
  background: #eaf1ff;
  border: 1px solid #c8daf8;
}
.conflict-link:hover,
.conflict-link:focus {
  background: #dce8ff !important;
  color: #0f43a0 !important;
  border-color: #b6cdf6 !important;
}

.generated-at { margin: 0; color: var(--muted); font-size: 0.9rem; }

.conflict-modal {
  width: min(900px, 92vw);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.conflict-modal::backdrop {
  background: rgba(0, 0, 0, 0.48);
}

.conflict-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.conflict-modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.conflict-close {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #1f2937;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 600;
  min-height: auto;
}

.conflict-content {
  margin: 0;
  padding: 14px 16px 18px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  line-height: 1.45;
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.schedule-card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.schedule-card h2 { margin: 0 0 10px; font-size: 1.06rem; }
.schedule-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.schedule-link {
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  padding: 9px 8px;
  text-align: center;
  color: #1b3b7a;
  border: 1px solid #d5dfef;
  background: #f8fbff;
}

.schedule-link:hover { background: #edf4ff; }

.admin-link {
  margin-left: auto;
  color: #ffffff;
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  padding: 6px 12px;
}

.admin-link:hover { background: rgba(255, 255, 255, 0.16); }

.scroll-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 42px;
  height: 42px;
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid #c6d4ea;
  background: #fff;
  color: #124488;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.2);
  display: none;
  z-index: 120;
}

.scroll-top.show {
  display: inline-flex;
}

.scroll-top:hover {
  background: #edf4ff;
}

.panel-wrap-wide {
  width: min(1100px, 96vw);
}

.legend-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-editor-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.legend-editor-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

.legend-editor-table th,
.legend-editor-table td {
  border: 1px solid #d9e1eb;
  padding: 8px;
}

.legend-editor-table thead th {
  background: #f1f5fb;
  text-align: center;
  font-size: 0.92rem;
}

.legend-head-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-header-input,
.legend-row-label-input,
.legend-cell-input {
  width: 100%;
}

.legend-remove-btn {
  border: 1px solid #d5dce8;
  background: #fff;
  color: #364152;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  border-radius: 6px;
  font-weight: 700;
  padding: 0;
}

.legend-remove-btn:hover {
  background: #f3f5f8;
}

.legend-editor-table .legend-slot {
  background: #f8fafc;
  white-space: nowrap;
  width: 180px;
}

.legend-editor-table input[type="text"] {
  min-width: 140px;
  font-size: 0.92rem;
  text-align: center;
}

.legend-card {
  margin-top: 18px;
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.legend-card h2 {
  margin: 0 0 10px;
  font-size: 1.06rem;
}

.legend-table-wrap {
  overflow-x: auto;
  border: 1px solid #d9e1eb;
  border-radius: 8px;
}

.legend-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #fff;
}

.legend-table th,
.legend-table td {
  border: 1px solid #d9e1eb;
  padding: 8px 10px;
  text-align: center;
  font-size: 0.9rem;
}

.legend-table thead th {
  background: #f1f5fb;
  font-weight: 700;
}

.legend-table .legend-row-slot {
  background: #f8fafc;
  white-space: nowrap;
}

.legend-table td {
  background: #ffffff;
}

.legend-cell-box {
  display: block;
  width: 100%;
  background: #f8fafc;
  border: 1px solid #d2dbe7;
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 38px;
}

@media (max-width: 720px) {
  .container { width: 95vw; }
  .panel-wrap { width: 95vw; margin-top: 96px; }
  .wrap { width: 95vw; margin-top: 96px; }
  .landing-wrap { width: 95vw; margin-top: 96px; }
  .landing-grid { grid-template-columns: 1fr; }
  .brand-hero { gap: 12px; }
  .brand-hero img { width: 62px; height: 62px; }
  .brand-title { font-size: 2rem; }
  .schedule-actions { grid-template-columns: 1fr; }
  .landing-card-secondary { width: 100%; }
}

.landing-secondary {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.landing-card-secondary {
  width: calc((100% - 16px) / 2);
  min-height: 104px;
  padding: 10px 12px;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.06);
}

.landing-wrap .landing-action .btn {
  min-height: 42px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 700;
}