:root {
  color-scheme: light;
  --background: #f3f5f7;
  --surface: #ffffff;
  --text: #182026;
  --muted: #65717a;
  --border: #dce2e6;
  --accent: #176b5b;
  --attention: #a93636;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 28px;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.page-header,
main {
  width: min(1180px, 100%);
  margin-inline: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.system-state {
  padding: 10px 14px;
  border: 1px solid #bcd8d1;
  border-radius: 999px;
  background: #e8f5f1;
  color: var(--accent);
  font-size: 14px;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}

.user-actions a,
.back-link a {
  color: var(--accent);
}

.user-actions .action-link {
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  text-decoration: none;
}

.user-actions .action-link--secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 15px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font: inherit;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 26px 0;
}

.metrics article,
.panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgb(25 42 50 / 6%);
}

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

.guard-count {
  color: var(--muted);
  font-size: 14px;
}

.site-list {
  margin-top: 22px;
  overflow-x: auto;
}

.site-table {
  min-width: 1180px;
}

.site-table-header,
.site-row {
  display: grid;
  grid-template-columns:
    18px
    minmax(190px, 1.35fr)
    minmax(210px, 1.4fr)
    100px
    minmax(230px, 1.45fr)
    120px
    150px;
  align-items: center;
  gap: 14px;
}

.site-table-header {
  padding: 0 14px 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.site-row {
  min-height: 52px;
  margin-bottom: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #49a078;
  box-shadow: 0 0 0 5px #e8f5f1;
}

.site-row--waiting .status-dot {
  background: #c58b25;
  box-shadow: 0 0 0 5px #fff6df;
}

.site-row--attention .status-dot {
  background: var(--attention);
  box-shadow: 0 0 0 5px #fff0f0;
}

.site-name,
.guard-name,
.checkpoint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guard-name,
.shift-time,
.checkpoint,
.last-report {
  color: var(--muted);
}

.checkpoint strong {
  color: var(--text);
}

.state-badge {
  min-width: 145px;
  border-radius: 999px;
  padding: 8px 11px;
  background: #e8f5f1;
  color: var(--accent);
  text-align: center;
  font-size: 13px;
}

.site-row--waiting .state-badge {
  background: #fff6df;
  color: #8c621c;
}

.site-row--attention .state-badge {
  background: #fff0f0;
  color: var(--attention);
}

.metrics article {
  display: flex;
  min-height: 116px;
  padding: 18px;
  flex-direction: column;
  justify-content: space-between;
}

.metrics span {
  color: var(--muted);
  font-size: 14px;
}

.metrics strong {
  font-size: 34px;
  font-weight: 650;
}

.metrics .attention strong {
  color: var(--attention);
}

.panel {
  min-height: 360px;
  padding: 24px;
}

.preview-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 26px;
  border: 1px solid #cbdcd7;
  border-radius: 14px;
  padding: 15px 18px;
  background: #edf7f4;
}

.preview-note p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
}

.preview-badge {
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  text-transform: uppercase;
}

.schedule-metrics {
  margin-top: 14px;
}

.schedule-panel {
  padding-inline: 18px;
}

.schedule-heading {
  padding: 6px 6px 0;
}

.schedule-legend {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.schedule-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.legend-dot--day {
  background: #2c8a72;
}

.legend-dot--night {
  background: #5e6ba8;
}

.schedule-scroll {
  margin-top: 20px;
  overflow-x: auto;
}

.schedule-grid {
  display: grid;
  min-width: 1280px;
  grid-template-columns: 190px repeat(7, minmax(145px, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.schedule-corner,
.schedule-day,
.schedule-site,
.schedule-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.schedule-corner,
.schedule-day {
  min-height: 56px;
  padding: 11px;
  background: #f7f9fa;
}

.schedule-corner {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.schedule-day {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.schedule-day strong {
  text-transform: uppercase;
}

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

.schedule-day--today {
  background: #e8f5f1;
  color: var(--accent);
}

.schedule-site {
  display: flex;
  min-height: 96px;
  align-items: center;
  overflow: hidden;
  padding: 12px;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-cell {
  display: grid;
  min-height: 96px;
  align-content: center;
  gap: 6px;
  padding: 7px;
}

.shift-card {
  overflow: hidden;
  border-left: 3px solid;
  border-radius: 7px;
  padding: 6px 7px;
}

.shift-card--day {
  border-color: #2c8a72;
  background: #edf7f4;
}

.shift-card--night {
  border-color: #5e6ba8;
  background: #f0f1fa;
}

.shift-card span,
.shift-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shift-card span {
  color: var(--muted);
  font-size: 10px;
}

.shift-card strong {
  margin-top: 2px;
  font-size: 12px;
}

.schedule-gap {
  color: var(--attention);
  font-size: 12px;
  text-align: center;
}

.report-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 26px;
}

.report-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.report-metrics {
  margin-top: 18px;
}

.duty-report-panel {
  padding-inline: 18px;
}

.duty-report-scroll {
  margin-top: 22px;
  overflow-x: auto;
}

.duty-report-table {
  min-width: 1260px;
}

.duty-report-header,
.duty-report-row {
  display: grid;
  grid-template-columns:
    18px
    minmax(205px, 1.3fr)
    minmax(190px, 1.2fr)
    100px
    minmax(240px, 1.5fr)
    90px
    145px
    150px;
  align-items: center;
  gap: 12px;
}

.duty-report-header {
  padding: 0 14px 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.duty-report-row {
  min-height: 58px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 13px;
}

.duty-report-row--waiting .status-dot {
  background: #c58b25;
  box-shadow: 0 0 0 5px #fff6df;
}

.duty-report-row--attention .status-dot {
  background: var(--attention);
  box-shadow: 0 0 0 5px #fff0f0;
}

.duty-report-row--waiting .state-badge {
  background: #fff6df;
  color: #8c621c;
}

.duty-report-row--attention .state-badge {
  background: #fff0f0;
  color: var(--attention);
}

.report-guard,
.report-site,
.report-counts {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-guard strong,
.report-guard small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-guard small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.report-site,
.report-counts {
  color: var(--muted);
}

.report-counts b {
  margin-left: 7px;
}

.report-counts b:first-child {
  margin-left: 0;
}

.count-ok {
  color: var(--accent);
}

.count-bad {
  color: var(--attention);
}

.count-wait {
  color: #8c621c;
}

.completion {
  display: grid;
  grid-template-columns: 1fr 38px;
  align-items: center;
  gap: 8px;
}

.completion-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ecef;
}

.completion-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.completion strong {
  font-size: 12px;
  text-align: right;
}

.directory-metrics {
  margin-top: 26px;
}

.guard-directory-panel {
  padding-inline: 18px;
}

.directory-heading {
  align-items: center;
}

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

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

.directory-search input {
  width: 280px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  color: var(--text);
  font: inherit;
}

.directory-search a {
  color: var(--accent);
  font-size: 13px;
}

.guard-directory-scroll {
  margin-top: 22px;
  overflow-x: auto;
}

.guard-directory-table {
  min-width: 1120px;
}

.guard-directory-header,
.guard-directory-row {
  display: grid;
  grid-template-columns:
    18px
    minmax(240px, 1.5fr)
    145px
    145px
    minmax(220px, 1.4fr)
    105px
    125px;
  align-items: center;
  gap: 13px;
}

.guard-directory-header {
  padding: 0 14px 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guard-directory-row {
  min-height: 52px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 14px;
  color: var(--muted);
  font-size: 13px;
}

.guard-directory-row strong {
  color: var(--text);
}

.guard-directory-row--available .status-dot {
  background: #79919d;
  box-shadow: 0 0 0 5px #edf1f3;
}

.guard-directory-row--available .state-badge {
  background: #edf1f3;
  color: #50646e;
}

.guard-directory-row--inactive {
  opacity: 0.6;
}

.guard-directory-row--inactive .status-dot {
  background: #9aa2a7;
  box-shadow: 0 0 0 5px #f0f1f2;
}

.guard-directory-row--inactive .state-badge {
  background: #f0f1f2;
  color: #697278;
}

.directory-name,
.directory-assignment {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  min-height: 250px;
  place-content: center;
  text-align: center;
}

.empty-state p {
  max-width: 430px;
  margin-top: 8px;
  color: var(--muted);
}

.login-page {
  display: grid;
  place-items: center;
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 56px);
  place-items: center;
}

.login-card {
  width: min(420px, 100%);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgb(25 42 50 / 10%);
}

.login-help {
  margin-top: 10px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.login-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font: inherit;
}

.form-error {
  margin-top: 18px;
  border-radius: 10px;
  padding: 11px 13px;
  background: #fff0f0;
  color: var(--attention);
  font-size: 14px;
}

.form-success {
  margin-top: 18px;
  border-radius: 10px;
  padding: 11px 13px;
  background: #e8f5f1;
  color: var(--accent);
  font-size: 14px;
}

.back-link {
  margin-top: 20px;
  text-align: center;
}

@media (max-width: 760px) {
  body {
    padding: 18px;
  }

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

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

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-actions,
  .schedule-legend {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .directory-search {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .directory-search input {
    width: 100%;
  }
}
