:root {
  --primary: #1e5a8a;
  --primary-dark: #164568;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --border: #d8e2ec;
  --text: #1a2b3c;
  --muted: #5a7085;
  --danger: #c0392b;
  --warning: #d68910;
  --info: #2471a3;
  --success: #1e8449;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
}

.sidebar {
  width: 240px;
  min-width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.25s ease, min-width 0.25s ease, padding 0.25s ease;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 32px;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  margin-bottom: 16px;
  width: 100%;
  font-size: 0.85rem;
}

.sidebar-toggle:hover {
  background: rgba(255,255,255,0.25);
}

.sidebar-toggle .toggle-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.layout.sidebar-collapsed .sidebar {
  width: 56px;
  min-width: 56px;
  padding: 16px 8px;
}

.layout.sidebar-collapsed .sidebar-body {
  display: none;
}

.layout.sidebar-collapsed .sidebar-toggle {
  margin-bottom: 0;
  padding: 8px;
}

.layout.sidebar-collapsed .sidebar-toggle .toggle-label {
  display: none;
}

.sidebar h1 {
  font-size: 1rem;
  margin: 0 0 24px;
  line-height: 1.4;
}

.sidebar nav a {
  display: block;
  color: rgba(255,255,255,0.92);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255,255,255,0.15);
  text-decoration: none;
}

.sidebar .user-info {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.2);
  font-size: 0.875rem;
}

.sidebar .user-label {
  font-size: 0.7rem;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.sidebar .user-role {
  font-weight: 600;
  margin-bottom: 8px;
}

.corp-select-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #ffffff 0%, #f0f6fb 100%);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(30, 90, 138, 0.08);
}

.corp-select-card label {
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.corp-select-card select {
  flex: 1;
  max-width: 420px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 0.95rem;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}

.checkbox-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  max-height: 240px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  cursor: pointer;
}

.checkbox-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.facility-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.facility-checkbox-item span {
  line-height: 1.4;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--primary);
}

.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.dashboard-summary td {
  font-weight: 600;
  background: #f4f8fb;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .label {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 4px;
}

.stat-card.danger .value { color: var(--danger); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.info .value { color: var(--info); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  background: #eef4f9;
  font-weight: 600;
}

tr.highlight-expired { background: #fdecea; }
tr.highlight-council_pending { background: #fef9e7; }
tr.highlight-resigned { background: #eceff1; }
tr.highlight-support_plan { background: #ebf5fb; }

tr.hiring-locked td {
  background-color: #d0d0d0;
  background-image:
    repeating-linear-gradient(
      -45deg,
      rgba(0, 0, 0, 0.35),
      rgba(0, 0, 0, 0.35) 1px,
      transparent 1px,
      transparent 7px
    );
  color: #333;
  opacity: 0.92;
}

tr.hiring-locked td.col-actions {
  background-image: none;
  background-color: #d8d8d8;
}

.hiring-locked-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #222;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #666;
  border-radius: 4px;
  padding: 4px 8px;
}

.hiring-filter-bar {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  margin-bottom: 16px;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #c5d0db;
  border-radius: 26px;
  transition: background 0.2s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .switch-slider {
  background: var(--primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-expired { background: #fadbd8; color: var(--danger); }
.badge-council_pending { background: #fdebd0; color: var(--warning); }
.badge-support_plan { background: #d6eaf8; color: var(--info); }
.badge-resigned { background: #eceff1; color: #546e7a; }

.collapsible summary { cursor: pointer; font-size: 1.05rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }

th.col-actions,
td.col-actions {
  text-align: right;
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
  padding-left: 16px;
}

.action-buttons {
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.action-buttons form {
  margin: 0;
  display: contents;
}
.locked-section { opacity: 0.55; pointer-events: none; }
.modal { border: none; border-radius: 12px; padding: 32px; width: 75%; max-width: none; }
.modal::backdrop { background: rgba(0,0,0,0.4); }
.modal-actions { display: flex; gap: 16px; justify-content: flex-end; margin-top: 24px; }
.modal-actions [data-modal-close] {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  background: #6c7a89;
  color: #fff;
}
.modal-actions [data-modal-close]:hover { background: #5a6672; }
.table-scroll { overflow-x: auto; }
.filter-bar { display: flex; gap: 12px; align-items: center; }
.filter-checkboxes { display: flex; gap: 16px; flex-wrap: wrap; }

.worker-dimension-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px 20px;
  align-items: start;
}

.worker-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-weight: 600;
  color: var(--primary);
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 4px 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.filter-toggle-icon {
  display: inline-block;
  font-size: 0.75rem;
  line-height: 1;
  transition: transform 0.15s ease;
}

.worker-filter-col.is-collapsed .filter-toggle-icon {
  transform: rotate(-90deg);
}

.worker-filter-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.worker-filter-col.is-collapsed .worker-filter-body {
  display: none;
}

.worker-filter-header .facility-select-toolbar {
  margin: 0;
}

.worker-filter-list {
  max-height: 220px;
  margin-top: 0;
}
.inline-form { display: flex; gap: 8px; align-items: center; }
.hidden-row { opacity: 0.6; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a93226; }
legend-color.resigned { background: #eceff1; border: 1px solid #78909c; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  background: var(--primary);
  color: #fff;
}

.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #6c7a89; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.form-group.full { grid-column: 1 / -1; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #2e86c1 100%);
}

.login-card {
  background: #fff;
  padding: 40px;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  text-align: center;
}

.login-card p.subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 0.875rem;
}

.error {
  background: #fadbd8;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.report-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.report-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.report-export-card .section-title {
  margin-top: 0;
}

.facility-select-toolbar {
  display: flex;
  gap: 8px;
  margin: 16px 0 12px;
}

.report-facility-list {
  margin-bottom: 20px;
}

.report-export-actions {
  display: flex;
  justify-content: flex-end;
}

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.alert-error {
  background: #fdecea;
  border: 1px solid #f5c2c0;
  color: #842029;
}

.legend {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.legend-color.expired { background: #fdecea; border: 1px solid #e74c3c; }
.legend-color.council { background: #fef9e7; border: 1px solid #f39c12; }
.legend-color.support { background: #ebf5fb; border: 1px solid #3498db; }

@media (max-width: 900px) {
  .layout:not(.sidebar-collapsed) {
    flex-direction: column;
  }
  .layout:not(.sidebar-collapsed) .sidebar {
    width: 100%;
    min-width: 0;
  }
  .layout.sidebar-collapsed {
    flex-direction: row;
  }
  .layout.sidebar-collapsed .sidebar {
    width: 56px;
    min-width: 56px;
  }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

.workers-page .page-header {
  margin-bottom: 8px;
}

.workers-page .corp-select-card,
.workers-page .legend.card,
.workers-page .worker-dimension-filters.card {
  margin-bottom: 8px;
  padding: 8px 16px;
}

.workers-page .corp-select-card select {
  padding: 6px 10px;
}

.workers-page .filter-checkboxes {
  align-items: center;
  gap: 8px 16px;
}

.workers-page .filter-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  line-height: 1.2;
}

.workers-page .filter-toggle {
  padding: 0;
}

.workers-page .table-scroll.card {
  padding: 8px 12px;
}

.workers-page #workers-table th,
.workers-page #workers-table td {
  padding: 4px 8px;
  line-height: 1.25;
}

.workers-page .btn-sm {
  padding: 2px 8px;
  font-size: 0.8rem;
}
