:root {
  --bg: #f5f2ee;
  --surface: #fff;
  --border: #e2ddd6;
  --text: #1c1917;
  --text-muted: #57534e;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: #ccfbf1;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
  --font: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg);
}

.nav-link-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.btn-toggle {
  font: inherit;
  padding: 0.4rem 0.75rem;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
}

.btn-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-toggle.active {
  background: var(--accent);
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.category-visibility-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
}

.category-visibility-inner {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.category-visibility-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.category-visibility-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.category-visibility-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.category-visibility-item input {
  margin: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.emulation-banner {
  width: 100%;
  background: #fef3c7;
  border-bottom: 2px solid #f59e0b;
  padding: 0.75rem 1.5rem;
  flex-shrink: 0;
}

.emulation-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  gap: 1rem;
}

.emulation-banner-text {
  font-size: 0.9rem;
  color: #92400e;
  font-weight: 500;
}

.emulation-banner-text strong {
  font-weight: 700;
}

.btn-exit-emulation {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  background: #fff;
  border-color: #f59e0b;
  color: #92400e;
}

.btn-exit-emulation:hover {
  background: #fef3c7;
  border-color: #d97706;
}

.day-counts-display {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.day-counts-header {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.day-count-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.day-count-item.day-count-detail {
  font-size: 0.8rem;
  padding-left: 0.5rem;
  color: var(--text-muted);
}

.day-count-label {
  color: var(--text-muted);
}

.day-count-value {
  font-weight: 600;
  color: var(--text);
}

.date-picker {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg);
}

.btn-primary {
  font: inherit;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg);
}

.main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sidebar-hint {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--bg);
}

.employee-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.employee-item {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: grab;
  margin-bottom: 2px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.employee-item:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.employee-item.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.employee-item:active {
  cursor: grabbing;
}

.employee-item.dragging {
  opacity: 0.5;
  pointer-events: none;
}

.employee-item .name {
  font-weight: 500;
  min-width: 0;
}

.employee-item .email {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.employee-item .remove-btn {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.6;
}

.employee-item .remove-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
  opacity: 1;
}

.main-centered {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

.employees-screen {
  width: 100%;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 1.5rem 0 0.75rem;
}

.section-title:first-child {
  margin-top: 0;
}

.section-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.shift-types-toolbar {
  margin-bottom: 0.75rem;
}

.employees-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.employees-filter-label {
  font-size: 0.875rem;
  color: var(--muted);
}

.employees-position-filter {
  min-width: 160px;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
}

.employees-toolbar .search {
  width: 280px;
}

.employees-table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.employees-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.employees-table th,
.employees-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.employees-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.employees-table tbody tr:last-child td {
  border-bottom: none;
}

.employees-table tbody tr:hover {
  background: var(--bg);
}

.employees-table .email-cell {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.employees-table .th-actions,
.employees-table .actions-cell {
  width: 1%;
  white-space: nowrap;
}

.btn-link {
  font: inherit;
  padding: 0.25rem 0.5rem;
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
}

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

.btn-link.btn-remove {
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.btn-link.btn-remove:hover {
  color: var(--danger);
}

.schedule-area {
  flex: 1;
  overflow: auto;
  padding: 1rem;
}

.schedule-notes {
  margin-top: 1rem;
  max-width: 600px;
}

.day-notes-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.day-notes-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.day-note-input {
  width: 100%;
  font: inherit;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  min-height: 4em;
}

.day-note-input:focus {
  outline: none;
  border-color: var(--accent);
}

.week-notes-row td {
  vertical-align: top;
  background: var(--bg);
}

.week-note-cell {
  padding: 0.25rem;
}

.week-note-cell .day-note-input {
  width: 100%;
  min-height: 3em;
  font-size: 0.75rem;
  padding: 0.35rem;
}

.week-view-wrap {
  overflow-x: auto;
}

.week-table {
  width: 100%;
  min-width: 730px;
  border-collapse: collapse;
  font-size: 0.8rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.week-table th,
.week-table td {
  border: 1px solid var(--border);
  padding: 0.3rem 0.4rem;
  vertical-align: top;
}

.week-table thead th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-align: center;
  padding: 0.4rem 0.3rem;
}

.week-table tr.week-day-summary th {
  font-weight: 500;
  font-size: 0.65rem;
  padding: 0.25rem 0.3rem;
  border-top: none;
}

.week-table .week-unassigned-cell {
  color: var(--text-muted);
}

.week-table col.week-col-label {
  width: 125px;
}
.week-table col.week-col-day {
  width: 85px;
}

.week-table th.week-col-label,
.week-table td.week-row-label {
  width: 125px;
  min-width: 125px;
  text-align: left;
  box-sizing: border-box;
}

.week-table th.week-col-day,
.week-table td.week-cell {
  width: 85px;
  min-width: 85px;
  box-sizing: border-box;
}

.week-row-label {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  box-sizing: border-box;
}

.week-cell.category-cell {
  width: 85px;
  min-width: 85px;
  min-height: 45px;
  padding: 0.25rem;
  box-sizing: border-box;
}

/* Location shading and separation in week view */
.week-table tbody tr.week-loc-first {
  border-top: 3px solid var(--text-muted);
}
.week-table tbody tr.week-loc-first:first-child {
  border-top-width: 0;
}
.week-table tbody tr.week-loc-1 { background: #f5f7f9; }
.week-table tbody tr.week-loc-2 { background: #f0f4f0; }
.week-table tbody tr.week-loc-3 { background: #f8f4f0; }
.week-table tbody tr.week-loc-4 { background: #f4f0f4; }
.week-table tbody tr.week-loc-5 { background: #f9f5f2; }
.week-table tbody tr.week-loc-6 { background: #f0f0f0; }
.week-table tbody tr.week-loc-1:hover,
.week-table tbody tr.week-loc-2:hover,
.week-table tbody tr.week-loc-3:hover,
.week-table tbody tr.week-loc-4:hover,
.week-table tbody tr.week-loc-5:hover,
.week-table tbody tr.week-loc-6:hover {
  filter: brightness(0.97);
}

.schedule-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: max-content;
}

.location-block {
  margin-bottom: 1.5rem;
}

.location-block:last-child {
  margin-bottom: 0;
}

.location-block.location-unavailable {
  padding: 0.75rem;
  background: rgba(0,0,0,0.03);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.location-block.location-unavailable .location-title {
  border-bottom-color: var(--text-muted);
}


.location-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.5rem;
  padding: 0.25rem 0;
  border-bottom: 2px solid var(--accent);
}

.categories-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-cell {
  min-width: 180px;
  width: 180px;
  min-height: 80px;
  padding: 0.5rem;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.category-cell.drag-over {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.category-cell .category-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}

.assignment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.4rem;
  margin: 0.15rem 0.15rem 0 0;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: default;
  white-space: nowrap;
  max-width: 100%;
}

.week-cell .assignment-chip {
  padding: 0.2rem 0.3rem;
  margin: 0.1rem 0.1rem 0 0;
  font-size: 0.7rem;
  gap: 0.2rem;
  white-space: nowrap;
}

.assignment-chip .chip-shift {
  font-weight: 600;
  opacity: 0.9;
}

.assignment-chip .chip-doctor {
  font-size: 0.9em;
  opacity: 0.85;
  margin-left: 0.15rem;
}

.assignment-chip .chip-testing {
  font-size: 0.9em;
  opacity: 0.85;
  margin-left: 0.15rem;
}

.assignment-chip .remove-assignment {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.8;
}

.shift-modal-hint {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.shift-type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.shift-type-btn {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}

.shift-type-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.shift-type-btn.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.shift-doctor-wrap {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.shift-doctor-label {
  font-weight: 500;
  margin: 0;
}

.shift-doctor-select {
  flex: 1;
  min-width: 120px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--surface);
  color: var(--text);
}

.shift-testing-wrap {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.shift-testing-label {
  font-weight: 500;
  margin: 0;
}

.shift-testing-select {
  flex: 1;
  min-width: 120px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--surface);
  color: var(--text);
}

.week-cell .assignment-chip .remove-assignment {
  font-size: 0.85rem;
}

.assignment-chip .remove-assignment:hover {
  opacity: 1;
  color: var(--danger);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

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

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  border-radius: 4px;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-form {
  padding: 1.25rem;
}

.modal-form label {
  display: block;
  margin-bottom: 1rem;
}

.modal-form label span {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.modal-form input[type="text"],
.modal-form input[type="email"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.employee-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.employee-tag-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.employee-tag-item input {
  margin: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
