:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f1ea;
  color: #1f2933;
  --ink: #1f2933;
  --muted: #67727e;
  --line: #d8d2c6;
  --panel: #fffdf8;
  --panel-strong: #f9f3e5;
  --green: #176f52;
  --red: #a33a2f;
  --blue: #235b8c;
  --gold: #b88926;
  --shadow: 0 18px 55px rgba(55, 45, 30, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), rgba(255,255,255,0)),
    #f4f1ea;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 14px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #bba56c;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 91, 140, 0.16);
}

.app-shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
}

.top-actions,
.inline {
  display: flex;
  gap: 10px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary {
  background: var(--ink);
  color: #fffdf8;
  border-color: var(--ink);
}

.ghost {
  background: transparent;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stat-panel {
  min-height: 94px;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-panel span {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-panel strong {
  font-size: 1.8rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  grid-template-areas:
    "controls roster"
    "events roster";
  gap: 14px;
  align-items: start;
}

.panel {
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.controls-panel {
  grid-area: controls;
}

.roster-panel {
  grid-area: roster;
  min-height: 640px;
}

.events-panel {
  grid-area: events;
}

.stack {
  display: grid;
  gap: 9px;
}

label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

.settings {
  display: grid;
  gap: 9px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.check-row input {
  width: 18px;
  height: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.panel-header p {
  color: var(--muted);
  margin-top: 3px;
  font-size: 0.9rem;
}

.panel-header input {
  max-width: 220px;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.name-cell {
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  min-height: 28px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.status-online {
  color: #fff;
  background: var(--green);
}

.status-offline {
  color: #fff;
  background: var(--red);
}

.status-unknown {
  color: var(--ink);
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.empty-state {
  display: none;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.empty-state.is-visible {
  display: grid;
}

.events-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  max-height: 300px;
  overflow: auto;
}

.events-list li {
  color: var(--muted);
  line-height: 1.35;
}

.events-list strong {
  color: var(--ink);
}

@media (max-width: 900px) {
  .topbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .inline {
    flex-direction: column;
  }

  .top-actions button,
  .inline button {
    width: 100%;
  }

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

  .workspace-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "controls"
      "roster"
      "events";
  }

  .panel-header input {
    max-width: none;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100vw - 20px, 1380px);
    padding-top: 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
