:root {
  --bg: #F3F5F2;
  --surface: #FFFFFF;
  --text: #24312A;
  --accent: #2F7D4F;
  --border: #DEE2DC;
  --muted: #6D7E70;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Work Sans', system_ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
h1 { 
  margin: 0; 
  font-size: 22px; 
  font-weight: 700; 
  color: var(--text);
}
.header-actions { 
  display: flex; 
  gap: 8px; 
}

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

.view-switch {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  width: fit-content;
}
.view-tab {
  padding: 8px 18px;
  font-size: 15px;
  font-weight: 600;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}
.view-tab.active {
  background: var(--accent);
  color: white;
}
.view-tab:first-child { border-right: 1px solid var(--border); }

.day-switcher {
  margin-bottom: 12px;
}
.day-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.day-btn {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  flex: 1;
  min-width: 54px;
}
.day-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.empty-state {
  padding: 24px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}
.empty-state p { margin: 0 0 12px; }

/* Today list */
#today-container {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 12px;
}
.today-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.today-card {
  background: #F8F9F7;
  border: 1px solid var(--border);
  padding: 11px 13px;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.today-card .crew {
  font-weight: 600;
  font-size: 14px;
}
.today-card .site {
  font-size: 14px;
  color: var(--text);
}
.today-card .time {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}
.today-card .addr {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Week Grid */
.grid-header {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 15px;
  padding-left: 4px;
}
.week-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}
#week-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  font-size: 14px;
}
#week-table th, #week-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}
#week-table th {
  background: #EBEDEB;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 6px;
  color: var(--muted);
  position: sticky;
  top: 0;
}
#week-table th:first-child,
#week-table td:first-child {
  border-right: 2px solid var(--border);
}
#week-table td:last-child,
#week-table th:last-child {
  border-right: 0;
}
.crew-name {
  font-weight: 600;
  padding-right: 8px;
}
.week-cell {
  width: 118px;
  min-height: 72px;
  vertical-align: top;
  padding: 6px !important;
  background: #F8F9F7;
}
.week-cell.empty {
  background: var(--surface);
  cursor: pointer;
}
.assign-content {
  background: #F8FAF7;
  border: 1px solid #D2E1D5;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 12px;
  position: relative;
  line-height: 1.35;
}
.assign-content strong { 
  display: block; 
  font-size: 13px; 
  font-weight: 600;
  color: var(--accent);
}
.assign-content .addr { 
  font-size: 11px; 
  line-height: 1.3; 
  color: var(--muted);
  margin-top: 2px;
}
.assign-content .time { 
  margin-top: 5px; 
  font-weight: 700; 
  color: var(--text); 
  font-size: 13px; 
}
.btn-delete-cell {
  position: absolute;
  top: 1px;
  right: 2px;
  border: none;
  background: transparent;
  color: #991414;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 1px 3px;
  opacity: .7;
}
.btn-delete-cell:hover { opacity: 1; }
.week-cell.empty:hover { background: #f1f7ef; }

/* Buttons */
.btn {
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  background: #E6E9E6;
  color: var(--text);
  transition: all 0.1s ease;
}
.btn:hover { filter: brightness(0.94); }
.btn.accent {
  background: var(--accent);
  color: white;
}
.btn.danger {
  background: #E5534E;
  color: white;
}
.spacer { flex: 1; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 380px;
  border-radius: 11px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 16.5px; font-weight: 600; }
.close-btn {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 6px;
}
.close-btn:hover { color: var(--text); }

#assign-form, .modal-content > .form-inline, .manage-list {
  padding: 18px;
}
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--muted);
}
.form-group select,
.form-group input {
  width: 100%;
  border: 1px solid var(--border);
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 15px;
  background: white;
  font-family: inherit;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.modal-actions {
  padding-top: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-inline {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  margin-bottom: 12px;
}
.form-inline input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.form-inline .btn { height: 36px; }

.manage-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.manage-item {
  background: #F8F9F7;
  border: 1px solid var(--border);
  padding: 8px 11px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}
.manage-item .site-name { font-weight: 600; }
.manage-item .addr {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 1px;
}
.manage-item .meta {
  flex: 1;
}
.remove-btn {
  font-size: 13px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #B83F3A;
  padding: 0 4px;
}

#view-week { min-height: 380px; }

@media (max-width: 640px) {
  h1 { font-size: 19px; }
  .header-actions { flex-wrap: wrap; }
  .week-container { max-height: none; }
  #week-table { min-width: 580px; }
  .modal { align-items: flex-end; }
  .modal-content { border-radius: 13px 13px 0 0; }
}