:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-strong: #eef4ef;
  --ink: #1c211d;
  --muted: #657065;
  --line: #dfe5dc;
  --green: #216e4e;
  --green-dark: #164c37;
  --amber: #b7791f;
  --red: #b42318;
  --blue: #1f5f99;
  --shadow: 0 16px 40px rgba(28, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(520px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card .brand {
  color: var(--ink);
}

.login-card .brand small {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-demo {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-strong);
}

.demo-account-list {
  display: grid;
  gap: 8px;
}

.demo-account {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.demo-account > div {
  min-width: 0;
}

.demo-account .muted {
  overflow-wrap: anywhere;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px;
  color: #fff;
  background: #18251f;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #f5c15b;
  color: #172119;
  font-weight: 800;
}

.brand small,
.storage-panel small {
  display: block;
  color: rgba(255, 255, 255, 0.66);
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  color: rgba(255, 255, 255, 0.74);
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.storage-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.main {
  padding: 28px;
  min-width: 0;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.top-actions,
.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.settings-savebar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.settings-savebar h2 {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.edit-actionbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 0 12px;
  background: var(--panel);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--ink);
}

.inline-check input {
  width: auto;
}

.accept-count-box {
  max-width: 680px;
}

.accept-count-box > label {
  max-width: 240px;
}

.table-scroll {
  overflow-x: auto;
}

.compact-table th,
.compact-table td {
  padding: 8px 10px;
}

.fee-confirmation {
  padding: 14px;
  border: 1px solid #efd89f;
  border-radius: 8px;
  background: #fff8e5;
  color: #765018;
}

.fee-confirmation label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-weight: 700;
}

.fee-confirmation input {
  width: 18px;
  height: 18px;
}

.fee-confirmation input[type="number"] {
  width: 100%;
  height: auto;
}

.subsection-block {
  margin-top: 18px;
}

.subsection-block h2 {
  margin-bottom: 12px;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.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));
}

.panel,
.card,
.empty,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.card {
  padding: 16px;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric strong {
  font-size: 28px;
}

.metric span,
.muted,
label small {
  color: var(--muted);
}

.dashboard-history summary {
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  list-style: none;
}

.dashboard-history summary::-webkit-details-marker {
  display: none;
}

.dashboard-history summary::after {
  content: "+";
  float: right;
  color: var(--muted);
}

.dashboard-history details[open] summary::after {
  content: "-";
}

.history-content {
  margin-top: 14px;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

fieldset {
  border: 1px solid #cfd8cc;
  border-radius: 8px;
  padding: 12px;
}

legend {
  padding: 0 6px;
  font-weight: 700;
}

.check-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 260px;
  overflow: auto;
}

.check-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.check-group input {
  width: auto;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd8cc;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 13px;
  font-weight: 700;
}

.primary-button {
  color: #fff;
  background: var(--green);
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  color: var(--green-dark);
  background: var(--panel-strong);
  border-color: #c8d8ce;
}

.ghost-button {
  color: inherit;
  background: transparent;
  border-color: currentColor;
}

.danger-button {
  color: #fff;
  background: var(--red);
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.icon-button:hover {
  background: #f4f8f2;
}

.danger-icon {
  color: var(--red);
  border-color: #f1b8b2;
}

.danger-icon:hover {
  background: #fde2df;
}

.pill,
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  background: #e8efe8;
  color: var(--green-dark);
}

.status.invited,
.status.pending {
  background: #fff3d7;
  color: #8a5200;
}

.status.accepted,
.status.completed,
.status.paid {
  background: #dff3e6;
  color: #155d3d;
}

.status.declined,
.status.timeout,
.status.cancelled {
  background: #fde2df;
  color: #9b1c13;
}

.status.draft {
  background: #e7edf5;
  color: #234f7e;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  background: #fbfcfa;
}

.tier-cell {
  width: 72px;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

.clickable-row {
  cursor: zoom-in;
}

.clickable-row:hover td {
  background: #f4f8f2;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 24, 20, 0.5);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(1040px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(16, 24, 20, 0.25);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.modal-header h2 {
  margin: 0;
}

#jobDetailBody {
  padding: 18px;
}

.dispatch-rank {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px dashed #cbd7ca;
  border-radius: 8px;
  background: #fbfcfa;
}

.candidate-list {
  display: grid;
  gap: 10px;
}

.candidate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

button.candidate {
  width: 100%;
  color: inherit;
  text-align: left;
}

button.candidate:hover {
  border-color: var(--green);
  background: #f4f8f2;
}

.accept-screen {
  max-width: 720px;
  margin: 0 auto;
}

.notice {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff8e5;
  color: #765018;
  border: 1px solid #efd89f;
}

.accept-complete-notice {
  background: #dff3e6;
  color: #155d3d;
  border-color: #a9d7ba;
}

.dashboard-notice {
  margin: 16px 0;
}

.message-preview {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}

.map-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.map-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.map-link:hover {
  text-decoration: underline;
}

.map-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #edf2ed;
  aspect-ratio: 16 / 9;
}

.map-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2,
.section-heading p {
  margin-bottom: 0;
}

.compact-field {
  min-width: 240px;
}

.compact-field select {
  margin-top: 6px;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
}

.request-calendar {
  display: grid;
  gap: 18px;
  max-height: 760px;
  overflow-y: auto;
  padding-right: 6px;
}

.calendar-month {
  display: grid;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.calendar-month:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.calendar-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.calendar-weekdays span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.calendar-day {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.calendar-day:hover {
  border-color: var(--green);
  background: #f4f8f2;
}

.calendar-day.has-requests {
  border-color: #8bb89e;
  background: #f0f7f2;
}

.calendar-date-number {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.calendar-day strong {
  display: block;
  margin-top: 8px;
  font-size: 19px;
}

.calendar-day small {
  color: var(--green-dark);
  font-weight: 700;
}

.calendar-statuses {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.calendar-status {
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.2;
}

.calendar-jobs {
  display: grid;
  gap: 2px;
  margin-top: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.calendar-jobs span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-companies {
  display: grid;
  gap: 2px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.calendar-companies span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-empty-mark {
  display: block;
  margin-top: 12px;
  color: #a5ada4;
  text-align: center;
}

.calendar-day.outside-month {
  opacity: 0.48;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .section-heading,
  .grid.two,
  .grid.three,
  .form-grid,
  .check-group {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-day {
    min-height: 68px;
    padding: 7px;
  }

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

  .calendar-companies {
    font-size: 11px;
  }

  .login-screen {
    align-items: start;
    padding: 12px;
  }

  .login-card {
    gap: 14px;
    padding: 16px;
  }

  .demo-account {
    align-items: stretch;
    flex-direction: column;
  }

  .demo-account .secondary-button {
    width: 100%;
  }
}
