:root {
  --bg: #fff3d7;
  --ink: #17131d;
  --muted: #6e604a;
  --line: #f0b053;
  --panel: #fffaf0;
  --panel-2: #ffdf8b;
  --accent: #f36c21;
  --accent-2: #1859d7;
  --gold: #ffd54f;
  --green: #dff3df;
  --green-line: #57a05a;
  --yellow: #fff1b9;
  --yellow-line: #c9941b;
  --shadow: 0 18px 46px rgba(59, 30, 6, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 213, 79, 0.95), transparent 18%),
    radial-gradient(circle at 88% 2%, rgba(24, 89, 215, 0.22), transparent 26%),
    linear-gradient(135deg, rgba(243, 108, 33, 0.2), transparent 30%),
    linear-gradient(315deg, rgba(24, 89, 215, 0.14), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1680px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar,
.brand-lockup,
.panel-head,
.layout,
.top-actions,
.legend,
menu {
  display: flex;
}

.brand-lockup {
  align-items: center;
  gap: 16px;
}

.warrior-mark {
  position: relative;
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border: 3px solid #17131d;
  border-radius: 18px;
  background: linear-gradient(160deg, #ffd54f, #f36c21 62%, #1859d7 63%);
  box-shadow: 6px 7px 0 #17131d;
  overflow: hidden;
}

.warrior-mark .aura,
.warrior-mark .hair,
.warrior-mark .face,
.warrior-mark .gi {
  position: absolute;
  display: block;
}

.warrior-mark .aura {
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  transform: rotate(-18deg);
}

.warrior-mark .hair {
  left: 22px;
  top: 8px;
  width: 30px;
  height: 24px;
  background: #121212;
  clip-path: polygon(0 100%, 12% 16%, 31% 64%, 45% 0, 58% 61%, 84% 11%, 100% 100%);
}

.warrior-mark .face {
  left: 25px;
  top: 28px;
  width: 24px;
  height: 22px;
  border-radius: 46% 46% 50% 50%;
  background: #ffd2a2;
  border: 2px solid #17131d;
}

.warrior-mark .gi {
  left: 18px;
  bottom: 4px;
  width: 38px;
  height: 24px;
  background: #f36c21;
  border: 2px solid #17131d;
  clip-path: polygon(8% 100%, 22% 20%, 50% 54%, 78% 20%, 92% 100%);
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
  font-weight: 900;
}

h2 {
  font-size: 18px;
}

.top-actions {
  position: relative;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#datePicker {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.icon-btn,
.primary-btn,
.secondary-btn,
.date-pill,
.toggle,
.small-btn {
  border: 2px solid #17131d;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  min-height: 40px;
}

.icon-btn {
  width: 42px;
  font-size: 24px;
  line-height: 1;
}

.date-pill {
  padding: 0 18px;
  font-weight: 800;
  min-width: 220px;
}

.view-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 2px solid #17131d;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 3px 4px 0 #17131d;
}

.view-toggle button {
  min-height: 40px;
  border: 0;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 900;
}

.view-toggle button.active {
  background: var(--accent);
  color: #17131d;
}

body.mobile-preview {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 213, 79, 0.9), transparent 20%),
    linear-gradient(180deg, #1859d7, #fff3d7 34%);
}

body.mobile-preview .app-shell {
  width: min(430px, calc(100vw - 18px));
  min-height: calc(100vh - 24px);
  margin: 12px auto;
  padding: 12px;
  border: 6px solid #17131d;
  border-radius: 34px;
  background: var(--bg);
  box-shadow: 0 22px 70px rgba(23, 19, 29, 0.35);
}

body.mobile-preview .topbar,
body.mobile-preview .layout,
body.mobile-preview .panel-head {
  display: grid;
  grid-template-columns: 1fr;
}

body.mobile-preview .brand-lockup {
  gap: 10px;
}

body.mobile-preview .warrior-mark {
  width: 56px;
  height: 56px;
  flex-basis: 56px;
}

body.mobile-preview h1 {
  font-size: 28px;
}

body.mobile-preview .top-actions,
body.mobile-preview .panel-actions {
  justify-content: start;
}

body.mobile-preview .date-pill {
  min-width: 180px;
}

body.mobile-preview .calendar-popover {
  right: auto;
  left: -82px;
  width: min(390px, calc(100vw - 34px));
}

body.mobile-preview .calendar-day {
  min-height: 66px;
  padding: 5px;
}

body.mobile-preview .calendar-day span {
  font-size: 10px;
}

body.mobile-preview table {
  min-width: 0;
}

body.mobile-preview .side-panel {
  width: 100%;
  grid-template-columns: 1fr;
  flex-basis: auto;
}

body.mobile-preview .line-box {
  grid-column: auto;
}

body.mobile-preview .salary-summary {
  grid-template-columns: 1fr;
}

body.mobile-preview .salary-calendar-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.calendar-host {
  position: relative;
}

.calendar-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 8;
  width: min(560px, calc(100vw - 28px));
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(28, 22, 14, 0.24);
}

.sync-status {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f0eadf;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 900;
}

.calendar-head,
.calendar-week,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.calendar-week {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.calendar-day {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px;
  text-align: left;
  display: grid;
  align-content: start;
  gap: 3px;
}

.calendar-day strong {
  font-size: 16px;
}

.calendar-day span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.calendar-day.selected {
  border-color: var(--accent);
  background: #fff2f3;
  outline: 2px solid rgba(164, 23, 34, 0.16);
}

.calendar-day.blank {
  visibility: hidden;
}

.primary-btn {
  background: var(--accent-2);
  color: white;
  border-color: #17131d;
  padding: 0 16px;
  font-weight: 800;
  box-shadow: 3px 4px 0 #17131d;
}

.secondary-btn,
.danger-btn,
.small-btn,
.toggle {
  padding: 0 12px;
  font-weight: 800;
}

.danger-btn {
  min-height: 40px;
  border: 2px solid #17131d;
  border-radius: 8px;
  background: #fff2f2;
  color: #9b1c1c;
  padding: 0 12px;
  font-weight: 900;
  box-shadow: 2px 3px 0 #17131d;
}

.layout {
  align-items: flex-start;
  gap: 18px;
}

.schedule-panel,
.side-panel section {
  background: rgba(255, 253, 248, 0.92);
  border: 2px solid #17131d;
  box-shadow: var(--shadow);
}

.schedule-panel {
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 12px;
  overflow: hidden;
}

.panel-head {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #fffaf0, #ffd88a);
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: end;
}

.schedule-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.japan-clock {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border: 2px solid #17131d;
  border-radius: 8px;
  background: #fff;
  box-shadow: 2px 3px 0 #17131d;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.sort-control {
  min-width: 230px;
  color: var(--ink);
}

.sort-control select {
  min-height: 40px;
  border: 2px solid #17131d;
  box-shadow: 2px 3px 0 #17131d;
}

#dataSummary,
.line-box p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.legend {
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mark,
.rec {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 2px solid #17131d;
  transform: rotate(45deg);
  box-shadow: 2px 2px 0 rgba(23, 19, 29, 0.3);
}

.mark-high {
  background: linear-gradient(135deg, #ffd54f, #f36c21);
}

.mark-mid {
  background: linear-gradient(135deg, #fff7bd, #ffb238);
}

.mark-low {
  background: linear-gradient(135deg, #7fb2ff, #1859d7);
}

.rec-best {
  background: var(--green);
  border: 1px solid var(--green-line);
}

.rec-warn {
  background: var(--yellow);
  border: 1px solid var(--yellow-line);
}

.table-wrap {
  overflow: visible;
}

table {
  display: block;
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}

body.tomorrow-mode table {
  min-width: 0;
}

thead {
  display: none;
}

tbody {
  display: grid;
  gap: 12px;
}

.tomorrow-col {
  display: none;
}

body.tomorrow-mode .tomorrow-col {
  display: none;
}

th,
td {
  border: 1px solid rgba(23, 19, 29, 0.12);
  border-radius: 9px;
  padding: 8px;
  text-align: left;
  vertical-align: top;
  min-width: 0;
  background: rgba(255, 255, 255, 0.58);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #17131d;
  color: #fffaf0;
  font-size: 12px;
  white-space: nowrap;
}

tbody tr {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  background: rgba(255, 253, 248, 0.88);
  border: 2px solid #17131d;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 4px 4px 0 rgba(23, 19, 29, 0.16);
}

td::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 6px;
  color: #7a4400;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
}

td.wave {
  display: none;
}

.driver-cell,
.start-cell,
.today-pay {
  grid-column: span 2;
}

.final-pay {
  grid-column: span 2;
}

.tomorrow-col {
  display: none;
}

body.tomorrow-mode .tomorrow-col {
  display: none;
}

body.tomorrow-mode .tomorrow-start-cell {
  grid-column: auto;
}

tbody tr.best-driver {
  background: var(--green);
  outline: 2px solid var(--green-line);
  outline-offset: -2px;
}

tbody tr.warn-driver {
  background: var(--yellow);
  outline: 2px solid var(--yellow-line);
  outline-offset: -2px;
}

tbody tr.holiday-driver {
  background: #e7e7ea;
  color: #777b84;
  outline: 2px solid #b8bbc3;
  outline-offset: -2px;
}

tbody tr.settled-driver {
  background: #e7e7ea;
  color: #777b84;
  outline: 2px solid #b8bbc3;
  outline-offset: -2px;
}

tbody tr.holiday-driver .driver-box,
tbody tr.holiday-driver .end-live,
tbody tr.holiday-driver .money,
tbody tr.settled-driver .driver-box,
tbody tr.settled-driver .end-live,
tbody tr.settled-driver .money {
  opacity: 0.62;
}

tbody tr.holiday-driver button:disabled,
tbody tr.holiday-driver input:disabled,
tbody tr.holiday-driver select:disabled,
tbody tr.holiday-driver textarea:disabled,
tbody tr.settled-driver button:disabled,
tbody tr.settled-driver input:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.48;
}

.driver-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 0;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.driver-box {
  display: grid;
  gap: 4px;
}

.driver-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.salary-btn {
  min-height: 30px;
  border: 2px solid #17131d;
  border-radius: 7px;
  background: #ffd54f;
  color: #17131d;
  font-size: 12px;
  font-weight: 900;
  padding: 0 8px;
  box-shadow: 2px 2px 0 #17131d;
}

.driver-address,
.subtext,
.place-address {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  max-width: 260px;
}

.line-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.line-status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 2px solid #17131d;
  border-radius: 7px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 2px 2px 0 #17131d;
}

.line-status.linked {
  background: #d9f7c7;
  color: #195820;
}

.line-status.unlinked {
  background: #fff2c4;
  color: #7a4400;
}

.line-action {
  min-height: 28px;
  border: 2px solid #17131d;
  border-radius: 7px;
  padding: 0 9px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 2px 2px 0 #17131d;
}

.line-action.send {
  background: #21a545;
}

.line-action.copy {
  background: #1859d7;
}

.start-editor {
  display: grid;
  gap: 8px;
}

.start-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.time-input {
  width: 96px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
}

.holiday-toggle {
  min-height: 36px;
  border: 2px solid #17131d;
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: #17131d;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 2px 2px 0 #17131d;
}

.holiday-toggle.active {
  background: #717782;
  color: #fff;
}

.holiday-note {
  display: inline-flex;
  width: fit-content;
  border: 1px solid #b8bbc3;
  border-radius: 999px;
  padding: 5px 10px;
  background: #f5f5f6;
  color: #616672;
  font-size: 12px;
  font-weight: 900;
}

.pay-breakdown,
.advance-box,
.settlement-box,
.final-settlement {
  display: grid;
  gap: 6px;
  min-width: 176px;
}

.transport-box {
  display: grid;
  gap: 5px;
  border: 1px solid #f0b053;
  border-radius: 8px;
  padding: 7px;
  background: #fffaf0;
  text-align: left;
}

.transport-title {
  color: #7a4400;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.expense-line {
  display: grid;
  grid-template-columns: 14px max-content 48px 18px;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.expense-line span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-line input[type="checkbox"] {
  width: 13px;
  height: 13px;
  accent-color: var(--accent-2);
}

.expense-input,
.money-mini-input {
  width: 100%;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}

.expense-input:disabled {
  background: #ececf0;
  color: #90939b;
}

.expense-unit {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.advance-box .toggle {
  width: fit-content;
}

.money-mini-input {
  max-width: 120px;
}

.extra-pay-list {
  display: grid;
  gap: 4px;
}

.extra-pay-line {
  display: grid;
  grid-template-columns: 10px 14px minmax(42px, 0.8fr) minmax(78px, 1.4fr);
  align-items: center;
  gap: 4px;
  color: var(--ink);
  font-size: 10px;
}

.extra-pay-line input[type="checkbox"],
.advance-settle-line input[type="checkbox"] {
  width: 13px;
  height: 13px;
  min-height: 13px;
  accent-color: var(--accent-2);
}

.extra-pay-memo,
.shift-note {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  background: #fff;
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
}

.shift-note {
  min-height: 54px;
  resize: vertical;
}

.add-extra-pay {
  min-height: 24px;
  width: fit-content;
  padding: 0 8px;
  font-size: 11px;
}

.advance-settle-line {
  display: grid;
  grid-template-columns: minmax(56px, 1fr) 14px;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 900;
}

.advance-settle-line.crossed .money-mini-input {
  text-decoration: line-through;
  color: #777b84;
  background: #f1f1f2;
}

.settlement-error {
  color: #b01818;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.25;
  white-space: normal;
}

.final-settlement strong {
  color: #1859d7;
  font-size: 15px;
  white-space: nowrap;
}

.final-settlement span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
  text-align: left;
}

.start-place {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  width: 174px;
}

.pay-rounding {
  width: 100%;
  max-width: 156px;
}

.segmented button {
  border: 0;
  background: #fff;
  min-height: 34px;
  font-size: 12px;
}

.segmented button.active {
  background: var(--ink);
  color: white;
}

.cast-select {
  width: 220px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
}

.cast-pickup {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.cast-search-wrap {
  display: grid;
  min-width: 0;
}

.address-edit {
  border-color: var(--accent);
}

.tomorrow-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
}

.tomorrow-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

.tomorrow-editor {
  display: grid;
  gap: 8px;
}

.tomorrow-editor.disabled {
  opacity: 0.45;
}

.tomorrow-plan {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(23, 19, 29, 0.22);
}

.tomorrow-plan-head {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.tomorrow-plan-head input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-2);
}

.start-live,
.end-live {
  font-weight: 900;
  font-size: 18px;
  margin-bottom: 8px;
}

.money {
  font-weight: 900;
  white-space: nowrap;
}

.toggle.on {
  background: var(--accent-2);
  color: white;
  border-color: var(--accent-2);
}

.toggle.off {
  background: #fff;
}

.side-panel {
  width: 360px;
  display: grid;
  gap: 14px;
  flex: 0 0 360px;
}

.side-panel section {
  border-radius: 12px;
  padding: 16px;
}

.notice-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.notice {
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.notice p {
  font-size: 13px;
  line-height: 1.5;
}

.notice-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

textarea {
  width: 100%;
  height: 190px;
  margin-top: 12px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

#castQuickSearch {
  width: 100%;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.cast-list {
  max-height: 320px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.cast-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px;
}

.cast-item strong {
  display: block;
}

.export-box {
  display: grid;
  gap: 10px;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.export-grid label {
  min-width: 0;
}

.export-grid input,
.export-grid select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  background: #fff;
  color: var(--ink);
}

.export-box .primary-btn {
  width: 100%;
}

dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(720px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}

#salaryDialog {
  width: min(960px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(17, 15, 12, 0.48);
}

.dialog-card {
  padding: 18px;
  background: var(--panel);
}

.salary-dialog-card {
  width: 100%;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

label input,
label select {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.expense-line input[type="checkbox"] {
  min-height: 13px;
  padding: 0;
  border-radius: 2px;
  flex: 0 0 13px;
}

.expense-line .expense-input {
  min-height: 28px;
  padding: 4px 6px;
}

/* Compact no-scroll table: keep every driver on one row and shrink controls instead of wrapping. */
.table-wrap {
  overflow: hidden;
}

table {
  display: table;
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

thead {
  display: table-header-group;
}

tbody {
  display: table-row-group;
}

tbody tr {
  display: table-row;
  box-shadow: none;
}

th,
td {
  display: table-cell;
  border-radius: 0;
  padding: 5px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(8px, 0.55vw, 10px);
  line-height: 1.25;
  white-space: nowrap;
}

td::before {
  content: none;
  display: none;
}

th:nth-child(1),
td:nth-child(1) {
  width: 13%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 14%;
}

th:nth-child(5),
td:nth-child(5) {
  display: none;
}

th:nth-child(6),
td:nth-child(6) {
  width: 9%;
}

th:nth-child(7),
td:nth-child(7) {
  width: 16%;
}

th:nth-child(8),
td:nth-child(8) {
  width: 7%;
}

th:nth-child(9),
td:nth-child(9) {
  width: 6%;
}

th:nth-child(10),
td:nth-child(10) {
  width: 8%;
}

th:nth-child(11),
td:nth-child(11) {
  width: 9%;
}

th:nth-child(12),
td:nth-child(12) {
  width: 9%;
}

th:nth-child(13),
td:nth-child(13) {
  width: 7%;
}

body.tomorrow-mode th:nth-child(1),
body.tomorrow-mode td:nth-child(1) {
  width: 10%;
}

body.tomorrow-mode th:nth-child(2),
body.tomorrow-mode td:nth-child(2) {
  width: 6%;
}

body.tomorrow-mode th:nth-child(3),
body.tomorrow-mode td:nth-child(3) {
  width: 10%;
}

body.tomorrow-mode th:nth-child(4),
body.tomorrow-mode td:nth-child(4) {
  width: 12%;
}

body.tomorrow-mode th:nth-child(6),
body.tomorrow-mode td:nth-child(6) {
  width: 8%;
}

body.tomorrow-mode th:nth-child(7),
body.tomorrow-mode td:nth-child(7) {
  width: 13%;
}

body.tomorrow-mode th:nth-child(8),
body.tomorrow-mode td:nth-child(8) {
  width: 7%;
}

body.tomorrow-mode th:nth-child(9),
body.tomorrow-mode td:nth-child(9) {
  width: 5%;
}

body.tomorrow-mode th:nth-child(10),
body.tomorrow-mode td:nth-child(10) {
  width: 6%;
}

body.tomorrow-mode th:nth-child(11),
body.tomorrow-mode td:nth-child(11) {
  width: 8%;
}

body.tomorrow-mode th:nth-child(12),
body.tomorrow-mode td:nth-child(12) {
  width: 8%;
}

body.tomorrow-mode th:nth-child(13),
body.tomorrow-mode td:nth-child(13) {
  width: 7%;
}

.driver-cell,
.start-cell,
.today-pay,
.final-pay,
body.tomorrow-mode .tomorrow-start-cell {
  grid-column: auto;
}

.driver-box,
.start-editor,
.pay-breakdown,
.advance-box,
.settlement-box,
.final-settlement {
  min-width: 0;
  max-width: 100%;
  gap: 3px;
}

.driver-name-row,
.line-row,
.start-time-row {
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
}

.driver-name,
.salary-btn,
.line-status,
.line-action,
.toggle,
.holiday-toggle,
.primary-btn,
.secondary-btn,
.danger-btn {
  min-height: 22px;
  padding: 0 5px;
  border-width: 1px;
  border-radius: 5px;
  box-shadow: none;
  font-size: clamp(7px, 0.5vw, 9px);
  line-height: 1;
  white-space: nowrap;
}

.driver-name span,
.driver-address,
.subtext,
.place-address,
.final-settlement span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver-address,
.subtext,
.place-address {
  margin-top: 2px;
  font-size: clamp(7px, 0.5vw, 9px);
}

.time-input {
  width: 52px;
  min-height: 23px;
  padding: 2px 3px;
  font-size: clamp(8px, 0.55vw, 10px);
}

.holiday-toggle {
  min-height: 23px;
  padding: 0 4px;
}

.holiday-note {
  padding: 3px 6px;
  font-size: 9px;
  white-space: nowrap;
}

.start-place {
  margin-top: 3px;
  gap: 3px;
}

.segmented {
  width: 86px;
  border-radius: 5px;
}

.segmented button {
  min-height: 22px;
  font-size: 8px;
  white-space: nowrap;
}

.cast-select {
  width: 100%;
  max-width: 112px;
  min-height: 24px;
  padding: 3px 4px;
  font-size: 8px;
}

.start-live,
.end-live {
  font-size: clamp(9px, 0.65vw, 11px);
  white-space: nowrap;
}

.transport-box {
  gap: 2px;
  padding: 3px;
  border-radius: 5px;
}

.transport-title {
  font-size: 8px;
}

.expense-line {
  grid-template-columns: 11px minmax(0, 1fr) 34px 12px;
  gap: 2px;
  font-size: 7px;
}

.expense-line input[type="checkbox"] {
  width: 10px;
  height: 10px;
  min-height: 10px;
}

.expense-input,
.money-mini-input {
  min-height: 20px;
  padding: 2px 3px;
  font-size: 8px;
}

.extra-pay-line {
  grid-template-columns: 8px 10px minmax(28px, 0.8fr) minmax(54px, 1.4fr);
  gap: 2px;
  font-size: 7px;
}

.extra-pay-memo,
.shift-note {
  min-height: 20px;
  padding: 2px 3px;
  font-size: 8px;
}

.shift-note {
  min-height: 38px;
}

.advance-settle-line {
  grid-template-columns: minmax(36px, 1fr) 10px;
  gap: 2px;
  font-size: 7px;
}

.settlement-error {
  font-size: 7px;
}

.expense-unit {
  font-size: 7px;
}

.money-mini-input {
  max-width: 76px;
}

.final-settlement strong {
  font-size: clamp(10px, 0.75vw, 13px);
}

.final-settlement span {
  font-size: 7px;
  white-space: nowrap;
}

.wide {
  grid-column: 1 / -1;
}

menu {
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 0 0;
  margin: 0;
}

.salary-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.salary-summary div {
  position: relative;
  min-height: 86px;
  border: 2px solid #17131d;
  border-radius: 10px;
  padding: 12px;
  background: linear-gradient(150deg, #fff, #ffd54f);
  box-shadow: 3px 4px 0 #17131d;
}

.salary-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.salary-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1;
}

.edit-chip {
  width: 34px;
  height: 34px;
  border: 2px solid #17131d;
  border-radius: 8px;
  background: #1859d7;
  position: absolute;
  right: 8px;
  top: 8px;
  box-shadow: 2px 2px 0 #17131d;
}

.edit-chip span {
  display: block;
  width: 15px;
  height: 15px;
  margin: 6px auto;
  background: #fff;
  clip-path: polygon(0 72%, 62% 10%, 89% 36%, 28% 100%, 0 100%);
}

.edit-chip.mini {
  position: static;
  width: 28px;
  height: 28px;
  justify-self: end;
  margin-top: 2px;
}

.day-ocr-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 7px;
  border: 1px solid #17131d;
  border-radius: 7px;
  background: #fff;
  color: #17131d;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.day-ocr-upload input {
  display: none;
}

.salary-tools,
.salary-calendar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  flex-wrap: wrap;
}

.salary-calendar-head {
  justify-content: space-between;
}

.ocr-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 12px;
  border: 2px solid #17131d;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 2px 3px 0 #17131d;
}

.ocr-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.ocr-result {
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 900;
}

.salary-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.salary-day {
  min-height: 86px;
  border: 2px solid #17131d;
  border-radius: 9px;
  background: #fff;
  padding: 8px;
  display: grid;
  gap: 5px;
  align-content: start;
}

.salary-day strong {
  font-size: 17px;
}

.salary-day span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.salary-day.selected {
  background: #fff2c4;
  outline: 3px solid #f36c21;
}

.salary-day.blank {
  visibility: hidden;
}

@media (max-width: 1100px) {
  .topbar,
  .layout {
    display: grid;
  }

  .side-panel {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex-basis: auto;
  }

  .line-box {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 18px, 1680px);
    padding: 14px 0;
  }

  .top-actions {
    justify-content: start;
  }

  .date-pill {
    min-width: 190px;
  }

  .panel-head,
  .side-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

  .line-box {
    grid-column: auto;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .salary-summary,
  .salary-calendar-grid {
    grid-template-columns: 1fr;
  }
}
.secondary-btn {
  background: #fff;
  box-shadow: 2px 3px 0 #17131d;
}

/* Preference-driven compact density. Later rules intentionally win over the base UI. */
body {
  --cell-font: 8px;
  --head-font: 9px;
  --control-font: 8px;
  --micro-font: 7px;
  --row-y: 3px;
  --row-x: 3px;
  --control-h: 20px;
  --check-size: 10px;
}

body.font-small {
  --cell-font: 7px;
  --head-font: 8px;
  --control-font: 7px;
  --micro-font: 6px;
  --row-y: 2px;
  --row-x: 2px;
  --control-h: 18px;
  --check-size: 9px;
}

body.font-large {
  --cell-font: 9px;
  --head-font: 10px;
  --control-font: 9px;
  --micro-font: 8px;
  --row-y: 4px;
  --row-x: 3px;
  --control-h: 22px;
  --check-size: 11px;
}

.app-shell {
  width: min(1760px, calc(100vw - 10px));
  padding: 8px 0;
}

.topbar {
  gap: 8px;
  margin-bottom: 8px;
}

.brand-lockup {
  gap: 8px;
}

.warrior-mark {
  width: 50px;
  height: 50px;
  flex-basis: 50px;
  border-radius: 12px;
  box-shadow: 3px 4px 0 #17131d;
}

.warrior-mark .aura {
  inset: 5px;
}

.warrior-mark .hair {
  left: 15px;
  top: 5px;
  width: 22px;
  height: 18px;
}

.warrior-mark .face {
  left: 17px;
  top: 20px;
  width: 17px;
  height: 16px;
}

.warrior-mark .gi {
  left: 12px;
  width: 28px;
  height: 17px;
}

.eyebrow {
  font-size: 10px;
  margin-bottom: 1px;
}

h1 {
  font-size: clamp(24px, 2.8vw, 34px);
}

h2 {
  font-size: 15px;
}

.top-actions,
.layout,
.panel-head,
.panel-actions,
.legend,
.side-panel,
.notice-list,
.line-row,
.driver-name-row,
.start-time-row {
  gap: 6px;
}

.panel-head {
  padding: 8px 10px;
}

.schedule-panel,
.side-panel section {
  box-shadow: 3px 3px 0 rgba(23, 19, 29, 0.28);
}

.side-panel {
  width: 310px;
  flex-basis: 310px;
  gap: 8px;
}

.side-panel section {
  padding: 9px;
}

.legend span,
#dataSummary,
.japan-clock,
.sync-status,
.notice,
.cast-item,
.salary-day span {
  font-size: var(--control-font);
}

.view-toggle,
.text-size-toggle {
  display: inline-grid;
  align-items: center;
  border: 1px solid #17131d;
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
  box-shadow: none;
}

.view-toggle {
  grid-template-columns: 1fr 1fr;
}

.text-size-toggle {
  grid-template-columns: auto 86px 44px auto;
  gap: 4px;
  padding: 0 6px;
}

.text-size-toggle span {
  padding: 0;
  color: var(--muted);
  font-size: var(--control-font);
  font-weight: 900;
  white-space: nowrap;
}

.text-size-toggle b {
  color: var(--muted);
  font-size: var(--control-font);
  line-height: 1;
}

.view-toggle button {
  min-height: 28px;
  border: 0;
  border-left: 1px solid rgba(23, 19, 29, 0.2);
  background: #fff;
  color: var(--ink);
  padding: 0 7px;
  font-size: var(--control-font);
  font-weight: 900;
  white-space: nowrap;
}

.text-size-toggle input[type="range"] {
  width: 86px;
  accent-color: var(--accent);
}

.text-size-toggle input[type="number"] {
  width: 44px;
  min-height: 22px;
  border: 1px solid rgba(23, 19, 29, 0.25);
  border-radius: 4px;
  padding: 0 3px;
  background: #fffaf0;
  color: var(--ink);
  font-size: var(--control-font);
  font-weight: 900;
  text-align: right;
}

.view-toggle button.active {
  background: var(--accent);
  color: #17131d;
}

.icon-btn,
.primary-btn,
.secondary-btn,
.date-pill,
.toggle,
.small-btn {
  min-height: 28px;
  padding: 0 8px;
  border-width: 1px;
  border-radius: 6px;
  box-shadow: none;
  font-size: var(--control-font);
}

.date-pill {
  min-width: 150px;
}

.sort-control {
  min-width: 188px;
  font-size: var(--control-font);
}

.sort-control select {
  min-height: 28px;
  padding: 3px 26px 3px 7px;
  font-size: var(--control-font);
}

th,
td {
  padding: var(--row-y) var(--row-x);
  font-size: var(--cell-font);
  line-height: 1.15;
}

th {
  font-size: var(--head-font);
}

.driver-name,
.salary-btn,
.line-status,
.line-action,
.toggle,
.holiday-toggle,
.primary-btn,
.secondary-btn {
  min-height: var(--control-h);
  padding: 0 4px;
  font-size: var(--control-font);
}

.driver-box,
.start-editor,
.pay-breakdown,
.advance-box,
.final-settlement,
.transport-box,
.start-place,
.cast-pickup {
  gap: 2px;
}

.driver-address,
.subtext,
.place-address,
.final-settlement span,
.transport-title,
.expense-line,
.expense-unit {
  font-size: var(--micro-font);
}

.time-input,
.cast-select,
.expense-input,
.money-mini-input {
  min-height: var(--control-h);
  padding: 1px 3px;
  font-size: var(--control-font);
}

.time-input {
  width: clamp(62px, calc(var(--control-h) * 2.8), 72px);
  font-variant-numeric: tabular-nums;
}

.holiday-toggle {
  min-height: var(--control-h);
}

.transport-box {
  padding: 2px;
}

.expense-line {
  grid-template-columns: var(--check-size) minmax(0, 1fr) minmax(56px, 1.2fr) 14px;
  gap: 2px;
}

.expense-line input[type="checkbox"] {
  width: var(--check-size);
  height: var(--check-size);
  min-height: var(--check-size);
}

.expense-input {
  min-width: 0;
  width: 100%;
}

.final-settlement strong {
  font-size: calc(var(--cell-font) + 3px);
}

.line-box textarea {
  min-height: 170px;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 8px, 1680px);
    padding: 8px 0;
  }

  .side-panel {
    gap: 8px;
  }

  .date-pill {
    min-width: 150px;
  }
}

/* Mobile-first readability override: keep every field visible without horizontal clipping. */
body.mobile-preview .app-shell {
  width: min(100vw - 10px, 430px);
  padding: 8px;
}

body.mobile-preview .top-actions {
  gap: 4px;
}

body.mobile-preview .text-size-toggle {
  grid-template-columns: auto minmax(0, 72px) 38px auto;
  padding: 0 4px;
}

body.mobile-preview .text-size-toggle input[type="range"] {
  width: 100%;
  min-width: 0;
}

body.mobile-preview .text-size-toggle input[type="number"] {
  width: 38px;
  padding: 0 2px;
}

body.mobile-preview .table-wrap {
  overflow: visible;
}

body.mobile-preview table {
  display: block;
  table-layout: auto;
  width: 100%;
  min-width: 0;
}

body.mobile-preview thead {
  display: none;
}

body.mobile-preview tbody {
  display: grid;
  gap: 7px;
}

body.mobile-preview tbody tr {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 6px;
  border: 1px solid #17131d;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: none;
}

body.mobile-preview th,
body.mobile-preview td {
  display: grid;
  align-content: start;
  border: 1px solid rgba(23, 19, 29, 0.16);
  border-radius: 6px;
  padding: 3px;
  min-width: 0;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  background: #fff;
  width: auto !important;
  max-width: none;
  justify-self: stretch;
}

body.mobile-preview td::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 2px;
  color: #7a4400;
  font-size: var(--micro-font);
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

body.mobile-preview td.wave {
  display: none;
}

body.mobile-preview .tomorrow-col {
  display: none;
}

body.mobile-preview.tomorrow-mode .tomorrow-col {
  display: none;
}

body.mobile-preview .driver-cell,
body.mobile-preview .today-pay,
body.mobile-preview .final-pay,
body.mobile-preview .note-cell {
  grid-column: 1 / -1;
}

body.mobile-preview .start-cell,
body.mobile-preview .tomorrow-start-cell,
body.mobile-preview .end-cell,
body.mobile-preview .month-pay,
body.mobile-preview .settlement-cell,
body.mobile-preview .change-cell,
body.mobile-preview .advance-cell {
  grid-column: auto;
}

body.mobile-preview .driver-box,
body.mobile-preview .start-editor,
body.mobile-preview .pay-breakdown,
body.mobile-preview .advance-box,
body.mobile-preview .settlement-box,
body.mobile-preview .final-settlement,
body.mobile-preview .transport-box,
body.mobile-preview .start-place {
  width: 100%;
  min-width: 0;
  max-width: none;
}

body.mobile-preview .driver-name-row,
body.mobile-preview .line-row,
body.mobile-preview .start-time-row {
  flex-wrap: wrap;
}

body.mobile-preview .driver-address,
body.mobile-preview .subtext,
body.mobile-preview .place-address,
body.mobile-preview .final-settlement span {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

body.mobile-preview .segmented {
  width: 100%;
  max-width: none;
}

body.mobile-preview .pay-rounding {
  max-width: none;
}

body.mobile-preview .cast-select,
body.mobile-preview .time-input,
body.mobile-preview .expense-input,
body.mobile-preview .money-mini-input,
body.mobile-preview .extra-pay-memo,
body.mobile-preview .shift-note {
  width: 100%;
  max-width: none;
}

body.mobile-preview .expense-line {
  grid-template-columns: var(--check-size) minmax(0, 1fr) minmax(64px, 1.3fr) 14px;
}

body.mobile-preview .extra-pay-line {
  grid-template-columns: 10px var(--check-size) minmax(76px, 0.8fr) minmax(0, 1.4fr);
}

body.mobile-preview .advance-settle-line {
  grid-template-columns: minmax(84px, 1fr) var(--check-size);
}

body.mobile-preview tbody tr.settled-driver {
  background: #e7e7ea;
}
