:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dce4ec;
  --line-soft: #edf2f6;
  --text: #16212a;
  --muted: #667481;
  --green: #22a65a;
  --green-soft: #e9f8ef;
  --red: #c62846;
  --red-soft: #fdecef;
  --yellow: #946900;
  --shadow: 0 10px 30px rgba(22, 33, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 16px 32px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--text);
}

.topbar nav {
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 10px;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  padding: 9px 12px;
  border-radius: 8px;
}

.topbar nav a:hover {
  background: var(--panel-soft);
  color: var(--text);
}

main {
  padding: 24px;
}

.dashboard-shell {
  max-width: 1680px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 22px;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 100px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.sidebar-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 12px;
}

.overall {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: 10px;
  font-weight: 800;
}

.overall.active {
  background: var(--green-soft);
  color: #126b36;
}

.overall.inactive {
  background: var(--red-soft);
  color: #9d1731;
}

.department-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.department-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 11px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--text);
}

.department-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.department-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 800;
}

.department-copy small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.department-copy .department-people {
  color: #1b7f49;
  font-size: 12px;
  font-weight: 700;
  white-space: normal;
}

.department-tab.active {
  border-color: #bfe8cd;
  background: var(--green-soft);
}

.department-tab.inactive {
  border-color: #f4c8d0;
  background: var(--red-soft);
}

.dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
}

.active .dot {
  background: var(--green);
}

.inactive .dot {
  background: var(--red);
}

.content-area {
  min-width: 0;
}

section {
  margin-bottom: 22px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

details.history-panel {
  margin-bottom: 22px;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

details.history-panel summary {
  cursor: pointer;
  list-style: none;
  padding: 18px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

details.history-panel summary::-webkit-details-marker {
  display: none;
}

details.history-panel summary::after {
  content: "+";
  float: right;
  color: var(--muted);
}

details.history-panel[open] summary {
  border-bottom: 1px solid var(--line-soft);
}

details.history-panel[open] summary::after {
  content: "-";
}

details.history-panel table {
  border: 0;
  border-radius: 0;
}

h2 {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f5f8;
  color: #26333d;
  font-size: 13px;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

tr:nth-child(even) td {
  background: #fbfdfe;
}

button,
select,
input {
  font: inherit;
  padding: 8px 11px;
  border: 1px solid #ccd7df;
  background: #ffffff;
  color: var(--text);
  border-radius: 8px;
}

button {
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: #f0f5f8;
}

form {
  display: flex;
  gap: 7px;
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  font-weight: 800;
}

.state-on {
  color: #126b36;
  background: var(--green-soft);
}

.state-off {
  color: #9d1731;
  background: var(--red-soft);
}

.state-unknown {
  color: var(--yellow);
  background: #fff6dd;
}

@media (max-width: 900px) {
  .topbar {
    justify-content: flex-start;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px 18px;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .topbar nav {
    position: static;
    transform: none;
  }

  main {
    padding: 14px;
  }

  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .department-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
