:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --primary: #0b7285;
  --primary-strong: #085d6c;
  --danger: #c92a2a;
  --success: #2b8a3e;
  --warning: #f08c00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8faf9 0%, #eef2f0 100%);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

header {
  background: #0f172a;
  color: #ffffff;
  padding: 14px 20px;
}

header .bar {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

header nav {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

header nav a,
header nav button {
  color: #ffffff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
}

main {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.stats {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.stat {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
}

.stat strong {
  display: block;
  font-size: 28px;
  margin-top: 4px;
}

.stat-link {
  color: var(--text);
  text-decoration: none;
}

.stat-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

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

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
}

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

button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  background: var(--primary);
  color: #ffffff;
}

button.secondary {
  background: #334155;
}

button.danger {
  background: var(--danger);
}

button.warn {
  background: var(--warning);
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  padding: 10px 8px;
  vertical-align: top;
}

th {
  background: #f8fafc;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  border: 1px solid;
}

.badge.planned {
  color: #1d4ed8;
  border-color: #93c5fd;
  background: #eff6ff;
}

.badge.in_progress {
  color: #b45309;
  border-color: #fcd34d;
  background: #fffbeb;
}

.badge.completed {
  color: #166534;
  border-color: #86efac;
  background: #f0fdf4;
}

.flash {
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid;
}

.flash.info {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.flash.success {
  background: #f0fdf4;
  border-color: #86efac;
}

.flash.error {
  background: #fef2f2;
  border-color: #fca5a5;
}

.photo {
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-link {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--primary);
  color: #ffffff;
  text-decoration: none;
  white-space: nowrap;
}

.btn-link:hover {
  text-decoration: none;
  background: var(--primary-strong);
}

.btn-link.secondary {
  background: #334155;
}

.btn-link.secondary:hover {
  background: #1f2937;
}

.filter-grid {
  display: grid;
  gap: 10px;
}

.filter-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.filter-actions {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
}

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

.pagination {
  margin-top: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.page-link {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: #ffffff;
  color: var(--text);
  text-decoration: none;
}

.page-link:hover {
  text-decoration: none;
  border-color: #94a3b8;
}

.page-link.active {
  background: #0f766e;
  color: #ffffff;
  border-color: #0f766e;
}

.page-gap {
  color: var(--muted);
  padding: 0 2px;
}

.token-box {
  display: flex;
  gap: 8px;
}

.token-box input {
  flex: 1;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.service-row {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
}

.site-row strong {
  display: block;
}

.row-focus td {
  background: #ecfeff;
}

.calendar-title {
  font-weight: 700;
  color: #0f172a;
}

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

.calendar-grid.weekdays {
  margin-bottom: 6px;
}

.calendar-weekday {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 8px;
  text-align: center;
  font-size: 12px;
  color: #475569;
}

.calendar-cell {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  background: #ffffff;
  color: var(--text);
  text-decoration: none;
}

.calendar-cell:hover {
  text-decoration: none;
  border-color: #0891b2;
}

.calendar-cell.outside {
  background: #f8fafc;
  color: #94a3b8;
}

.calendar-cell.today {
  border-color: #0ea5e9;
  box-shadow: inset 0 0 0 1px #0ea5e9;
}

.calendar-cell.selected {
  border-color: #0f766e;
  box-shadow: inset 0 0 0 1px #0f766e;
  background: #f0fdfa;
}

.calendar-day {
  font-weight: 700;
  font-size: 14px;
}

.calendar-count {
  display: inline-block;
  font-size: 12px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  padding: 2px 8px;
  align-self: flex-start;
}

.schedule-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.mobile-section {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.selected-site-panel {
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  padding: 12px 14px;
  background: #eff6ff;
}

.selected-site-panel.empty {
  border-style: dashed;
  background: #f8fafc;
}

.selected-site-title {
  font-weight: 700;
  font-size: 16px;
}

.selected-site-meta {
  margin-top: 4px;
  color: #334155;
  font-size: 13px;
}

.selected-site-address {
  margin-top: 4px;
  color: #475569;
  font-size: 12px;
}

.selected-site-placeholder {
  color: #64748b;
}

.site-search-results {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.site-option-card {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: #ffffff;
  padding: 12px 14px;
  display: grid;
  gap: 4px;
  text-align: left;
  color: var(--text);
}

.site-option-card:hover {
  border-color: #60a5fa;
}

.site-option-card.selected {
  border-color: #0284c7;
  box-shadow: inset 0 0 0 1px #0284c7;
  background: #f0f9ff;
}

.site-option-name {
  font-weight: 700;
}

.site-option-path {
  color: #334155;
  font-size: 13px;
}

.site-option-address {
  color: #64748b;
  font-size: 12px;
}

.mobile-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.mobile-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #0f766e;
  color: #ffffff;
  padding: 4px 10px;
  font-size: 12px;
}

.mobile-chip.subtle {
  background: #e2e8f0;
  color: #334155;
}

.stage-create-links {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-create-links .btn-link {
  font-size: 13px;
  padding: 7px 10px;
}

.service-mobile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.service-mobile-card {
  position: relative;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: #ffffff;
  padding: 12px 14px;
  display: grid;
  gap: 6px;
  cursor: pointer;
}

.service-mobile-card.selected {
  border-color: #0ea5e9;
  background: #ecfeff;
  box-shadow: inset 0 0 0 1px #0ea5e9;
}

.service-mobile-checkbox {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
}

.service-mobile-name {
  font-weight: 700;
  padding-right: 24px;
}

.service-mobile-detail {
  color: #334155;
  font-size: 12px;
}

.service-mobile-qty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.service-mobile-qty span {
  color: #475569;
  font-size: 12px;
}

.service-mobile-qty input {
  width: 88px;
  padding: 6px 8px;
}

.estimate-service-breakdown {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.estimate-service-row {
  border: 1px solid #dbe2ea;
  border-radius: 10px;
  padding: 8px 10px;
  background: #f8fafc;
}

.estimate-service-name {
  font-weight: 700;
  font-size: 13px;
}

.estimate-service-meta {
  margin-top: 2px;
  color: #475569;
  font-size: 12px;
}

details {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: #f8fafc;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

@media (max-width: 768px) {
  .split {
    grid-template-columns: 1fr;
  }

  header .bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .token-box {
    flex-direction: column;
  }

  .schedule-row {
    grid-template-columns: 1fr;
  }

  .service-mobile-grid {
    grid-template-columns: 1fr;
  }

  .site-option-card,
  .service-mobile-card {
    border-radius: 12px;
    padding: 10px 12px;
  }

  .page-head {
    flex-direction: column;
  }

  .head-actions {
    width: 100%;
  }

  .filter-grid.three,
  .filter-grid.two {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    flex-direction: column;
    align-items: stretch;
  }

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

  .calendar-cell {
    min-height: 64px;
    padding: 6px;
  }
}
