:root {
  --yellow: #f5c518;
  --green: #2da44e;
  --orange: #fb8500;
  --blue: #1f6feb;
  --bg: #f5f6f8;
  --ink: #111;
  --muted: #555;
  --rule: #d0d4d9;
  --rule-strong: #9aa1a8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---------- upload page ---------- */
.page-upload {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.upload-card {
  background: #fff;
  max-width: 540px;
  width: 100%;
  padding: 2.25rem 2.25rem 1.75rem;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 32px rgba(0, 0, 0, 0.06);
}
.upload-card h1 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.upload-card .subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}
.error {
  background: #ffe6e6;
  color: #8a1f1f;
  border: 1px solid #f3b1b1;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}
.file-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  border: 1px dashed var(--rule-strong);
  border-radius: 8px;
  padding: 0.75rem;
  background: #fafbfc;
  margin-bottom: 1rem;
}
.file-label input[type="file"] { display: none; }
.file-label-button {
  display: inline-block;
  background: #111;
  color: #fff;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.file-label-text {
  color: var(--muted);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.submit {
  width: 100%;
  background: #1f6feb;
  color: #fff;
  border: 0;
  padding: 0.85rem;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
}
.submit:disabled { background: #6c8bbf; cursor: progress; }
.hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- toolbar ---------- */
.toolbar {
  background: #fff;
  border-bottom: 1px solid var(--rule);
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.toolbar .back {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
}
.toolbar .back:hover { text-decoration: underline; }
.toolbar .print-btn {
  background: #111;
  color: #fff;
  border: 0;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.toolbar .file-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}

/* ---------- schedule ---------- */
.schedule {
  max-width: 980px;
  margin: 1.25rem auto 3rem;
  padding: 0 1.25rem;
}
.schedule-date {
  font-size: 1.25rem;
  margin: 1rem 0 0.75rem;
}
.warnings {
  background: #fff7e0;
  border: 1px solid #f1d27a;
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.5rem;
}
.warnings h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: #6d4c00;
}
.warnings ul {
  margin: 0;
  padding-left: 1.2rem;
}
.warnings li {
  margin-bottom: 0.3rem;
  line-height: 1.4;
  font-size: 0.92rem;
}

.break-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--rule-strong);
  font-size: 0.95rem;
}
.break-table th,
.break-table td {
  border: 1px solid var(--rule);
  padding: 0.45rem 0.65rem;
  vertical-align: top;
  text-align: left;
}
.break-table th {
  background: #f2f3f5;
  font-weight: 600;
  border-bottom: 1px solid var(--rule-strong);
}
.break-table td.name { white-space: nowrap; font-weight: 500; }
.break-table td.shift { font-variant-numeric: tabular-nums; min-width: 12rem; }
.break-table td.break-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.break-table tr.director { background: #fbfafa; }
.break-table tr.director td.name { color: #553; }

.director-badge {
  display: inline-block;
  background: #6e5b2b;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.na { color: #888; }
.warn { color: #b3261e; font-weight: 600; }

.dot {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  vertical-align: -2px;
  margin-right: 0.45rem;
  border: 1px solid rgba(0,0,0,0.08);
}
.dot-yellow { background: var(--yellow); }
.dot-green  { background: var(--green); }
.dot-orange { background: var(--orange); }
.dot-blue   { background: var(--blue); }

/* ---------- legend ---------- */
.legend {
  margin-top: 1.5rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  font-size: 0.9rem;
}
.legend h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.3rem 1rem;
}
.legend-list li { display: flex; align-items: center; }
.legend-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

/* ---------- visual schedule (Gantt-style chart) ---------- */
/*
 * Layout: 2-column CSS grid.
 *   Column 1: fixed-width name column.
 *   Column 2: time-axis bar area where shifts, breaks, and blackouts
 *             are positioned by left%/width% relative to the chart range.
 *
 * Row 1 is the time-axis header (tick labels). Rows 2..N+1 are one row
 * per employee.
 */
.chart-page {
  background: #fff;
  margin: 1.5rem auto 3rem;
  max-width: 1100px;
  padding: 0 1.25rem;
}
.chart-header h2 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
}
.chart {
  display: grid;
  grid-template-columns: 9rem 1fr;
  border: 1px solid var(--rule-strong);
  background: #fff;
  font-size: 0.85rem;
  line-height: 1;
}
.chart-name-col {
  padding: 0.25rem 0.5rem;
  border-right: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  min-height: 1.6rem;
}
.chart-name-col.chart-director { background: #fbfafa; color: #553; }
.chart-name-col .director-badge { margin-left: 0.3rem; }

/* Time axis header */
.chart-axis-cell { background: #f2f3f5; min-height: 1.6rem; }
.chart-axis {
  position: relative;
  background: #f2f3f5;
  border-bottom: 1px solid var(--rule-strong);
  height: 1.6rem;
}
.chart-hour-tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 100%;
  background: var(--rule-strong);
}
.chart-hour-label {
  position: absolute;
  top: 0.15rem;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0 0.15rem;
  background: #f2f3f5;
}
.chart-quarter-tick {
  position: absolute;
  top: 60%;
  width: 1px;
  height: 40%;
  background: var(--rule);
}

/* Per-row bar area */
.chart-row {
  position: relative;
  height: 1.4rem;
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}
.chart-row-hour-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--rule);
}
.chart-blackout {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.06);
}
.chart-shift {
  position: absolute;
  top: 30%;
  height: 40%;
  background: transparent;
  border: 1px solid #777;
  border-radius: 2px;
  box-sizing: border-box;
}
.chart-break {
  position: absolute;
  top: 22%;
  height: 56%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 2px;
  box-sizing: border-box;
}
.chart-yellow { background: var(--yellow); }
.chart-green  { background: var(--green); }
.chart-orange { background: var(--orange); }
.chart-blue   { background: var(--blue); }
.chart-legend-note {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- print ---------- */
/*
 * Two-page print: page 1 is the table (portrait), page 2 is the chart
 * (landscape). Named @page rules drive the orientation per section.
 */
@page table-page {
  size: letter portrait;
  margin: 0.4in;
}
@page chart-page {
  size: letter landscape;
  margin: 0.35in;
}
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .schedule { margin: 0; padding: 0; max-width: none; }
  .schedule-date { margin-top: 0; }
  .break-table { font-size: 10pt; }
  .break-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .warnings { background: #fff7e0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; break-inside: avoid; }
  .legend { background: #fff !important; break-inside: avoid; }
  .dot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .table-page { page: table-page; }
  .chart-page {
    page: chart-page;
    page-break-before: always;
    margin: 0;
    padding: 0;
    max-width: none;
  }
  .chart {
    /* Slightly tighter when printed; keeps everything on one landscape page. */
    font-size: 8.5pt;
  }
  .chart-name-col { min-height: 1.2rem; padding: 0.1rem 0.35rem; }
  .chart-axis, .chart-axis-cell { min-height: 1.2rem; height: 1.2rem; }
  .chart-row { height: 1.05rem; }
  .chart-hour-label { font-size: 7pt; }
  .chart-blackout,
  .chart-shift,
  .chart-break,
  .chart-yellow, .chart-green, .chart-orange, .chart-blue {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
