:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ef;
  --blue: #2563eb;
  --teal: #0f766e;
  --red: #dc2626;
  --green: #15803d;
  --amber: #b45309;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--blue); }
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #111827; color: #fff; padding: 20px 14px; }
.brand { display: grid; gap: 2px; padding: 8px 10px 18px; border-bottom: 1px solid rgba(255,255,255,.16); margin-bottom: 12px; }
.brand strong { font-size: 20px; }
.brand span { color: #cbd5e1; font-size: 12px; }
.nav { display: grid; gap: 4px; }
.nav a { color: #e5e7eb; padding: 10px 12px; border-radius: 7px; display: block; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.main { min-width: 0; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: #fff; border-bottom: 1px solid var(--line); }
.content { padding: 24px; display: grid; gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel-header { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-header h1, .panel-header h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.button.danger { background: var(--red); border-color: var(--red); color: #fff; }
.button.ghost { background: #f8fafc; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; width: fit-content; padding: 3px 8px; border-radius: 999px; background: #eef2ff; color: #3730a3; font-size: 12px; font-weight: 750; white-space: nowrap; }
.pill.red { background: #fee2e2; color: var(--red); }
.pill.green { background: #dcfce7; color: var(--green); }
.pill.amber { background: #fef3c7; color: var(--amber); }
.pill.gray { background: #eef2f7; color: #475467; }
.muted { color: var(--muted); }
.flash { padding: 12px 14px; border: 1px solid #bfdbfe; background: #eff6ff; border-radius: var(--radius); }
.flash.error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
.stat { display: grid; gap: 4px; }
.stat strong { font-size: 28px; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(480px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; gap: 14px; }
.task-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; background: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.03); }
.task-row { grid-template-columns: minmax(0, 1fr) 96px; align-items: start; }
.task-main { display: grid; gap: 6px; min-width: 0; }
.task-main p { margin: 0; }
.task-side { display: grid; gap: 8px; justify-items: stretch; }
.task-side .button { width: 100%; min-height: 34px; padding: 6px 8px; }
.task-create-details summary,
.task-edit-details summary { list-style: none; width: fit-content; }
.task-create-details summary::-webkit-details-marker,
.task-edit-details summary::-webkit-details-marker { display: none; }
.task-create-form,
.task-edit-form { margin-top: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); background: #f8fafc; }
.task-edit-form textarea,
.task-create-form textarea { min-height: 84px; }
.task-card.done { background: #f1f5f9; color: #64748b; }
.task-card.done strong { text-decoration: line-through; }
.task-palette { display: grid; gap: 8px; max-height: 720px; overflow: auto; }
.task-palette .task-card { cursor: grab; }
.calendar-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.calendar-task-panel { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.calendar-task-panel .panel-header { align-items: flex-start; }
.task-panel-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.calendar-task-panel h2 { margin: 0; }
.task-count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 32px; padding: 0 10px; border-radius: 999px; background: #fef3c7; color: var(--amber); font-size: 12px; font-weight: 800; white-space: nowrap; }
.quick-task-details { margin-bottom: 12px; }
.quick-task-details summary { list-style: none; width: fit-content; }
.quick-task-details summary::-webkit-details-marker { display: none; }
.quick-task-form { display: grid; gap: 10px; padding: 12px; margin-top: 8px; border: 1px dashed var(--line); border-radius: var(--radius); background: #f8fafc; }
.quick-task-form textarea { min-height: 86px; }
.check-line { display: inline-flex; grid-auto-flow: column; align-items: center; justify-content: start; gap: 8px; color: var(--ink); width: fit-content; min-height: 32px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.check-line input { flex: 0 0 auto; }
.palette-task strong { line-height: 1.25; }
.calendar-main-panel .panel-header { align-items: flex-start; }
.daily-calendar { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; max-height: min(620px, calc(100vh - 190px)); }
.daily-calendar-header,
.daily-calendar-body { display: grid; min-width: 980px; }
.daily-calendar-header { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); background: #fff; }
.time-axis-heading,
.member-heading { min-height: 60px; padding: 11px 12px; border-right: 1px solid var(--line); display: grid; align-content: center; }
.time-axis-heading { color: var(--muted); font-size: 12px; text-align: center; }
.member-heading strong { font-size: 14px; }
.member-heading span { color: var(--muted); font-size: 12px; }
.daily-calendar-body { position: relative; min-height: 896px; }
.time-axis { border-right: 1px solid var(--line); background: #f8fafc; }
.time-slot-label { height: 64px; padding: 8px 8px; text-align: right; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); }
.member-timeline-column { position: relative; min-width: 220px; min-height: 896px; border-right: 1px solid var(--line); background: #fff; }
.timeline-slot { display: block; width: 100%; height: 64px; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 0; cursor: crosshair; }
.timeline-slot:hover,
.timeline-slot.is-drop-target { background: #eff6ff; outline: 2px solid var(--blue); outline-offset: -2px; }
.timeline-event { position: absolute; left: 8px; right: 8px; z-index: 3; display: grid; grid-template-rows: 24px 18px; gap: 3px; align-content: start; padding: 5px 8px; border: 1px solid #bfdbfe; border-left: 4px solid var(--blue); border-radius: 7px; background: #eff6ff; box-shadow: 0 5px 14px rgba(15, 23, 42, .08); cursor: grab; overflow: hidden; touch-action: none; }
.event-title-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; min-width: 0; }
.event-title-row strong { min-width: 0; font-size: 13px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.timeline-event .event-pills { display: flex; flex-wrap: nowrap; gap: 4px; align-items: center; min-width: 0; overflow: hidden; }
.timeline-event .pill { min-height: 16px; font-size: 10px; line-height: 1; padding: 2px 5px; }
.event-task { border-color: #fecaca; border-left-color: var(--red); background: #fff1f2; }
.event-routine { border-color: #bbf7d0; border-left-color: var(--green); background: #f0fdf4; cursor: default; }
.timeline-event.is-completed { background: #f1f5f9; border-color: #cbd5e1; border-left-color: #94a3b8; color: #64748b; cursor: default; filter: grayscale(.2); }
.timeline-event.is-completed strong { text-decoration: line-through; }
.event-complete-form { margin: 0; align-self: start; }
.complete-button { min-height: 22px; padding: 1px 7px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: 11px; font-weight: 750; cursor: pointer; white-space: nowrap; }
.timeline-event.is-completed .complete-button { background: #e2e8f0; color: #475467; }
.resize-hit { position: absolute; left: 0; right: 0; height: 10px; opacity: 0; }
.resize-top { top: 0; cursor: ns-resize; }
.resize-bottom { bottom: 0; cursor: ns-resize; }
.timeline-event.is-dragging { opacity: .78; z-index: 50; box-shadow: 0 12px 24px rgba(15, 23, 42, .18); }
.quick-event-dialog { width: min(460px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 10px; padding: 0; box-shadow: 0 24px 80px rgba(15, 23, 42, .22); }
.quick-event-dialog::backdrop { background: rgba(15, 23, 42, .28); }
.quick-event-form { padding: 18px; display: grid; gap: 12px; }
.week-calendar-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.week-calendar { min-width: 1040px; border-collapse: separate; border-spacing: 0; }
.week-calendar th,
.week-calendar td { border-right: 1px solid #eef2f7; border-bottom: 1px solid var(--line); vertical-align: top; padding: 10px; }
.week-calendar th:first-child,
.week-calendar td:first-child { position: sticky; left: 0; z-index: 2; background: #fff; min-width: 150px; }
.week-calendar thead th { background: #f8fafc; text-align: center; }
.week-calendar thead th:first-child { z-index: 3; }
.week-calendar th small { display: block; color: var(--muted); }
.week-calendar th.weekend { background: #fff7ed; color: var(--amber); }
.week-event { display: grid; gap: 2px; margin-bottom: 6px; padding: 7px; border: 1px solid #bfdbfe; border-left: 4px solid var(--blue); border-radius: 7px; background: #eff6ff; }
.week-event.event-task { border-color: #fecaca; border-left-color: var(--red); background: #fff1f2; }
.week-event.event-routine { border-color: #bbf7d0; border-left-color: var(--green); background: #f0fdf4; }
.week-event.is-completed { opacity: .6; filter: grayscale(.3); }
.week-event strong { font-size: 13px; line-height: 1.25; }
.week-event span { color: var(--muted); font-size: 11px; }
.report-current { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.report-history { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.report-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 12px; display: grid; gap: 6px; }
.report-card p { margin: 0; color: var(--muted); }
.report-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shift-summary-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.shift-calendar-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.shift-table { min-width: 1180px; border-collapse: separate; border-spacing: 0; }
.shift-table th,
.shift-table td { border-bottom: 1px solid var(--line); border-right: 1px solid #eef2f7; padding: 6px; text-align: center; vertical-align: middle; }
.shift-table th:first-child,
.shift-table td:first-child { position: sticky; left: 0; background: #fff; z-index: 2; min-width: 120px; text-align: left; }
.shift-table thead th { position: sticky; top: 0; z-index: 3; background: #f8fafc; color: var(--ink); }
.shift-table thead th:first-child { z-index: 4; }
.shift-table th span,
.shift-table th small { display: block; line-height: 1.15; }
.shift-table th small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.shift-table th.weekend { background: #fff7ed; color: var(--amber); }
.shift-cell { min-width: 42px; background: #fff; }
.shift-cell.has-shift { background: #f8fafc; }
.shift-cell form { margin: 0; }
.shift-select { width: 34px; min-height: 32px; padding: 0; text-align: center; text-align-last: center; border-radius: 8px; font-weight: 800; color: var(--muted); background: #fff; }
.shift-select.work { border-color: #bfdbfe; background: #eff6ff; color: var(--blue); }
.shift-select.paid { border-color: #bbf7d0; background: #f0fdf4; color: var(--green); }
.attendance-status { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.attendance-status > div { border: 1px solid var(--line); border-radius: var(--radius); background: #f8fafc; padding: 12px; display: grid; gap: 4px; }
.attendance-status strong { font-size: 18px; }
.late-text { color: var(--red); }
.attendance-grid { align-items: stretch; }
.punch-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 14px; display: grid; gap: 10px; min-height: 150px; }
.punch-card strong { font-size: 30px; line-height: 1; }
.punch-card.is-locked { background: #f1f5f9; color: #64748b; }
.footer-note { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .grid.two, .grid.three, .grid.four, .form-grid, .form-grid.three, .calendar-layout { grid-template-columns: 1fr; }
  .calendar-task-panel { position: static; max-height: none; }
  .task-row { grid-template-columns: 1fr; }
  .task-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .attendance-status { grid-template-columns: 1fr; }
  .topbar { height: auto; padding: 14px; align-items: flex-start; gap: 12px; }
}
