:root {
  color-scheme: light;
  font-family: "Hiragino Sans", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  --ink: #272922;
  --muted: #575a51;
  --line: #d8d9d0;
  --base: #f5f5f1;
  --panel: #fff;
  --yellow: #ffea00;
  --amber-light: #fff3c0;
  --amber-strong: #ffdf69;
  --red-light: #fae7e3;
  --red: #882a23;
  --undated-light: #fff2ef;
  --undated-ink: #93463e;
  --green-light: #e2f1e5;
  --green: #275540;
  --sunday-bg: #fff3f2;
  --sunday-ink: #993a36;
  --saturday-bg: #eff6ff;
  --saturday-ink: #315983;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--base); line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid #645200; outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.55rem, 2.6vw, 2.12rem); letter-spacing: -.035em; }
h2 { font-size: 1.15rem; }
.top { background: #fff; border-top: 4px solid var(--yellow); border-bottom: 1px solid var(--line); }
.top-inner, .shell { width: min(100% - 48px, 1530px); margin-inline: auto; }
.top-inner { min-height: 68px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand, .session, .toolbar, .actions, .dialog-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { flex-wrap: nowrap; font-weight: 800; white-space: nowrap; }
.brand img { width: 110px; height: auto; }
.brand span { padding-left: 12px; border-left: 1px solid var(--line); }
.session { justify-content: flex-end; font-size: .875rem; }
.connection { color: var(--green); font-weight: 700; }
.connection.problem, .message.error { color: var(--red); }
.shell { padding-block: 22px 34px; }
.page-heading, .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-heading { margin-bottom: 8px; }
.muted { color: var(--muted); font-size: .875rem; }
.card { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); min-width: 0; }
.card-head { padding: 15px 16px 13px; }
.split { display: grid; align-items: start; grid-template-columns: minmax(0, 1fr) minmax(420px, .72fr); gap: 16px; }
.button, .filter {
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
  padding: 7px 12px; font-size: .875rem; font-weight: 700; white-space: nowrap;
}
.button:hover:not(:disabled), .filter:hover { background: #f2f2ed; }
.button.primary { border-color: #e0cc00; background: var(--yellow); }
.button.primary:hover:not(:disabled) { background: #f2dc00; }
.button.small { padding: 5px 9px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 13px; }
.filter { padding: 5px 8px; }
.filter[aria-pressed="true"] { background: var(--amber-light); border-color: #a98a23; }
.filter.overdue { color: var(--red); }
.filter.overdue[aria-pressed="true"] { background: var(--red-light); border-color: var(--red); }
#filter-undated { color: var(--undated-ink); }
#filter-undated[aria-pressed="true"] { background: var(--undated-light); border-color: #cf938b; }
.list-scroll { max-height: 650px; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.task-table th, .calendar th { color: #474940; background: #eeeee8; font-size: .875rem; font-weight: 700; }
.task-table th { position: sticky; top: 0; z-index: 1; padding: 8px; text-align: left; }
.task-table th:first-child { padding-left: 16px; }
.task-table th:nth-child(2) { width: 133px; }
.task-table th:nth-child(3) { width: 101px; }
.task-table td { padding: 7px 8px; border-top: 1px solid var(--line); font-size: .875rem; }
.task-table td:first-child { padding-left: 16px; min-width: 0; }
.task-table tr.selected td { background: #fff9d9; }
.task-table .task-group td { padding: 0; background: #f5f5ef; }
.task-group-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px 9px 16px;
  border: 0; text-align: left; background: transparent; font-weight: 700;
}
.task-group-toggle::before { content: '▸'; color: var(--muted); }
.task-group-toggle[aria-expanded="true"]::before { content: '▾'; }
.task-group-title { min-width: 0; overflow-wrap: anywhere; }
.task-group-count { margin-left: auto; color: var(--muted); white-space: nowrap; font-size: .8125rem; }
.task-table .task-group-item td:first-child { padding-left: 28px; }
.task-name { color: inherit; background: transparent; border: none; padding: 2px 0; text-align: left; font-weight: 700; overflow-wrap: anywhere; }
.task-name:hover { text-decoration: underline; }
.task-table td.list-empty { padding: 16px; color: var(--muted); }
.date-cell input { max-width: 100%; min-width: 0; padding: 4px 3px; font-size: .875rem; }
.date-cell .readonly { font-variant-numeric: tabular-nums; color: var(--muted); }
.date-adjusted { display: block; color: var(--muted); font-size: .75rem; margin-top: 3px; }
.badge { display: inline-flex; gap: 3px; align-items: center; border-radius: 5px; padding: 2px 6px; font-weight: 700; font-size: .875rem; white-space: nowrap; }
.planned { background: #eeeeea; color: #4c4d45; }
.undated { background: var(--undated-light); color: var(--undated-ink); }
.soon { background: var(--amber-light); color: #5f4300; }
.today { background: var(--amber-strong); color: #473300; }
.late { background: var(--red-light); color: var(--red); }
.done { background: var(--green-light); color: var(--green); }
.calendar-scroll { overflow: auto; }
.month-undated { padding: 7px 13px; border-top: 1px solid var(--line); }
.month-undated > span { color: var(--undated-ink); font-size: .8125rem; font-weight: 700; }
.month-undated ul { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0; margin: 3px 0 0; list-style: none; }
.month-undated button { font-size: .875rem; }
.calendar { min-width: 630px; }
.calendar td, .calendar th { border-top: 1px solid var(--line); border-right: 1px solid var(--line); }
.calendar td:last-child, .calendar th:last-child { border-right: none; }
.calendar th { padding: 6px; }
.calendar td { min-width: 0; height: 83px; padding: 5px; vertical-align: top; }
.calendar td.outside { background: #f6f6f2; }
.calendar .saturday { background: var(--saturday-bg); }
.calendar .sunday, .calendar .holiday { background: var(--sunday-bg); }
.calendar .company-paid-day { background: var(--amber-light); }
.calendar th.saturday, .calendar .saturday:not(.holiday) .day { color: var(--saturday-ink); }
.calendar th.sunday, .calendar .sunday .day, .calendar .holiday .day { color: var(--sunday-ink); }
.holiday-name { display: block; color: var(--sunday-ink); font-size: .8125rem; font-weight: 700; overflow-wrap: anywhere; }
.calendar td.selected-day { background: #fffbed; }
.calendar td.drop-target { background: #fff4c9; outline: 2px solid #987c21; outline-offset: -2px; }
.day { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px; font-size: .875rem; font-variant-numeric: tabular-nums; }
.outside .day { color: #66695d; }
.day.current { background: var(--yellow); border-radius: 7px; font-weight: 800; }
.event { display: block; text-align: left; border: 1px solid transparent; border-radius: 5px; width: 100%; margin-top: 4px; padding: 3px 4px; overflow-wrap: anywhere; font-size: .875rem; line-height: 1.3; }
.event:hover { border-color: currentColor; }
.event[draggable="true"] { cursor: grab; }
.event[draggable="true"]:active { cursor: grabbing; }
.event[aria-pressed="true"] { border-color: #7a6507; }
.event span { display: block; margin-top: 2px; font-size: .8125rem; font-weight: 700; }
.calendar-foot { display: flex; flex-wrap: wrap; justify-content: space-between; padding: 9px 13px; gap: 8px; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--muted); }
.message { color: var(--green); font-size: .875rem; margin-block: 5px; }
.message:empty { display: none; }
label { display: grid; gap: 4px; font-size: .875rem; font-weight: 700; }
label.check { display: flex; align-items: center; gap: 6px; }
input:not([type="checkbox"]), select, textarea { border: 1px solid #aeb1a4; border-radius: 6px; padding: 7px 9px; background: #fff; min-width: 0; }
input[type="checkbox"] { accent-color: #827000; }
input[readonly], input:disabled, textarea:disabled { color: var(--muted); background: #f7f7f4; }
textarea { resize: vertical; min-height: 68px; }
.add-form { display: grid; grid-template-columns: minmax(145px, 1fr) minmax(0, 1fr); gap: 8px; padding: 11px 16px; background: #fff9d9; border-top: 1px solid var(--line); }
.detail-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.wide { grid-column: 1 / -1; }
.actions { justify-content: flex-end; }
.login { margin: 8vh auto 0; padding: 23px; width: min(100%, 385px); }
.login form, dialog form { display: grid; gap: 11px; margin-top: 12px; }
dialog { width: min(510px, 100% - 28px); border: 1px solid var(--line); border-radius: 10px; padding: 18px; color: var(--ink); }
dialog::backdrop { background: #24251e66; }
.dialog-head { justify-content: space-between; }
.admin-fields { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 8px; }
.admin-list { margin-top: 12px; max-height: 30vh; overflow: auto; }
.admin-list th, .admin-list td { padding: 7px 8px; text-align: left; overflow-wrap: anywhere; }
.admin-list th { position: sticky; top: 0; background: #eeeee8; }
.admin-list td { border-bottom: 1px solid var(--line); }
.admin-list th:last-child { width: 38%; }
#company-dialog { width: min(760px, 100% - 28px); max-height: 90vh; }
.company-dates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.company-dates textarea { width: 100%; font-family: ui-monospace, monospace; }
#company-review fieldset { margin: 0; border: 1px solid var(--line); border-radius: 6px; }
#company-image canvas { display: block; width: min(100%, 560px); height: auto; margin: 8px auto; }
#company-changes { max-height: 150px; overflow: auto; margin: 0; padding-left: 24px; }
.company-work-name { color: var(--green); }
@media (max-width: 550px) { .company-dates { grid-template-columns: 1fr; } }
.source { color: var(--muted); padding: 7px 9px; background: var(--base); font-size: .875rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#print-sheet { display: none; }
@media (max-width: 1140px) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(380px, 420px); }
}
@media (max-width: 920px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .list-scroll { max-height: 410px; }
}
@media (max-width: 550px) {
  .top-inner, .shell { width: calc(100% - 20px); }
  .top-inner { padding-block: 7px; align-items: flex-start; }
  .brand { align-self: center; }
  .brand img { width: 80px; }
  .brand span { padding-left: 6px; }
  .session { gap: 5px; }
  .task-table th:nth-child(2) { width: 104px; }
  .task-table th:nth-child(3) { width: 78px; }
  .task-table td, .task-table th { padding-inline: 4px; }
  .task-table td:first-child, .task-table th:first-child { padding-left: 8px; }
  .badge { padding-inline: 3px; font-size: .8125rem; }
}

@page iso-year { size: A4 landscape; margin: 10mm; }
@page iso-calendar { size: A4 landscape; margin: 0; }

@media print {
  body.printing-year { background: #fff; min-width: 0; }
  body.printing-year > :not(#print-sheet) { display: none !important; }
  .printing-year #print-sheet {
    display: block;
    color: #252721;
    font-size: 9pt;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .print-overview {
    page: iso-calendar;
    padding: 10mm 10mm 0;
    line-height: 1.2;
    page-break-inside: avoid;
    break-inside: avoid-page;
  }
  .print-heading {
    border-bottom: 1.2mm solid #ffea00;
    padding-bottom: 1.5mm;
    margin-bottom: 2.5mm;
  }
  .print-heading-line { display: flex; justify-content: space-between; align-items: end; }
  .print-heading h1, .print-agenda h1 { font-size: 19pt; line-height: 1.25; }
  .print-heading p { font-size: 10pt; }
  .print-months { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2.5mm; }
  .print-month { border: .25mm solid #d8d9d0; padding: 1.5mm 2.5mm; break-inside: avoid; }
  .print-month h2 { display: flex; align-items: baseline; gap: 3mm; font-size: 12pt; margin-bottom: 1mm; }
  .print-month h2 small { color: #575a51; font-size: 7pt; font-weight: 400; }
  .print-calendar th, .print-calendar td { height: 4.8mm; padding: 0; text-align: center; }
  .print-calendar th { border-bottom: .25mm solid #d8d9d0; font-size: 8pt; }
  .print-calendar td { position: relative; border-bottom: .18mm solid #eee; font-variant-numeric: tabular-nums; }
  .print-calendar .saturday { background: var(--saturday-bg); color: var(--saturday-ink); }
  .print-calendar .sunday, .print-calendar .holiday { background: var(--sunday-bg); color: var(--sunday-ink); }
  .print-calendar .company-paid-day, .print-paid-key { background: var(--amber-light); color: #5f4300; }
  .print-scheduled {
    display: inline-block;
    min-width: 5.5mm;
    padding: 0 1mm;
    border: .3mm solid #836209;
    border-radius: 1mm;
    background: #ffe27a;
    color: #3c2c00;
    font-weight: 800;
    line-height: 1.2;
  }
  .print-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 1mm 3mm; margin-top: 2mm; color: #575a51; font-size: 8pt; }
  .print-holiday-key, .print-saturday-key { padding: .3mm 1mm; font-weight: 700; }
  .print-holiday-key { background: var(--sunday-bg); color: var(--sunday-ink); }
  .print-saturday-key { background: var(--saturday-bg); color: var(--saturday-ink); }
  .print-agenda { page: iso-year; }
  .print-agenda h1 { margin-bottom: 3mm; }
  .print-agenda thead { display: table-header-group; }
  .print-agenda tr { break-inside: avoid; }
  .print-agenda th, .print-agenda td { padding: 1mm 2mm; border-bottom: .22mm solid #d8d9d0; text-align: left; overflow-wrap: anywhere; }
  .print-agenda th { background: #f2f2ed; }
  .print-agenda th:first-child { width: 63mm; }
  .print-agenda th:last-child { width: 47mm; }
}
