:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #637083;
  --line: #d9e0e7;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --warn: #9a6700;
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 40px;
  padding: 9px 14px;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  background: #e8eef3;
  color: var(--text);
}

.auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-panel {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
}

.login-panel h1,
.topbar h1,
.workspace h2,
.door-list h2 {
  margin: 0;
}

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 20px;
}

.topbar p,
.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  min-height: calc(100vh - 73px);
}

.door-list,
.workspace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  min-width: 0;
}

.door-list {
  display: grid;
  align-content: start;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.door-button {
  display: grid;
  justify-items: start;
  gap: 3px;
  width: 100%;
  background: #eef5f4;
  color: var(--text);
  text-align: left;
}

.door-button.active {
  outline: 2px solid var(--accent);
}

.door-button small {
  color: var(--muted);
}

.workspace-head,
.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.workspace-head {
  align-items: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-head.compact {
  align-items: center;
  margin-bottom: 10px;
}

.panel-head.compact h2 {
  font-size: 18px;
}

.panel-summary {
  color: var(--muted);
  font-size: 13px;
  margin: 3px 0 0;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.status-item,
.control {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.status-item b {
  display: block;
  font-size: 13px;
}

.status-item span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-height: min(58vh, 620px);
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin: 4px -16px 16px;
  padding: 0 16px;
}

.tab-button {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: transparent;
  color: var(--muted);
  min-height: 38px;
  padding: 8px 12px;
}

.tab-button:hover,
.tab-button.active {
  background: #eef5f4;
  color: var(--text);
}

.tab-button.active {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.search-input {
  max-width: 320px;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.inline-edit {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  min-width: 290px;
}

.inline-edit input {
  min-height: 40px;
}

.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 12px;
}

.table-wrap .empty-state {
  border: 0;
  border-radius: 0;
}

.error-state {
  border-color: #f0b4ad;
  color: var(--danger);
}

.table-note {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.control {
  display: grid;
  gap: 10px;
}

.control h3 {
  margin: 0;
  font-size: 16px;
}

.control p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.control-actions {
  display: flex;
  gap: 8px;
}

.danger-command {
  border-color: #f0b4ad;
}

.danger-command h3 {
  color: var(--danger);
}

.message,
.error {
  border-radius: 6px;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.message {
  border: 1px solid #b7ddc8;
  background: #effaf3;
  color: #155724;
}

.message.error,
.error {
  border: 1px solid #f0b4ad;
  background: #fff3f1;
  color: var(--danger);
}

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

  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .tabs {
    overflow-x: auto;
  }

  .tab-button {
    white-space: nowrap;
  }
}
