:root {
  --ink: #17201b;
  --muted: #68756d;
  --line: #d9dfd8;
  --panel: #fbfcf8;
  --paper: #f2f5ec;
  --accent: #1f6f5b;
  --accent-2: #c07233;
  --danger: #b43f3f;
  --ok: #246e3c;
  --shadow: 0 20px 60px rgba(36, 50, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 32, 27, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 32, 27, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body.auth-loading .app-frame,
body:not(.is-authenticated) .app-frame {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  background: rgba(251, 252, 248, 0.96);
  box-shadow: var(--shadow);
}

.login-card .brand-mark {
  width: 54px;
  height: 54px;
  border-color: var(--line);
}

.login-card h1 {
  font-size: 26px;
}

.login-card p {
  color: var(--muted);
  line-height: 1.6;
}

button,
input,
textarea {
  font: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  color: #edf4ec;
  background: #16231d;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: #dfe7d8;
  color: #16231d;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: #aebdaf;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  color: #d8e3d7;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.server-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

.server-card + .server-card {
  margin-top: 0;
}

.server-card span,
.server-card strong {
  display: block;
}

.server-card span {
  color: #aebdaf;
  font-size: 13px;
}

.logout-button {
  width: 100%;
  margin-top: 12px;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #edf4ec;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.shell {
  margin-left: 248px;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.topbar p {
  margin-top: 7px;
  color: var(--muted);
}

.quick-scan {
  min-width: 320px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(251, 252, 248, 0.78);
}

.quick-scan label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.quick-scan input,
.search {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

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

.metrics article,
.panel {
  border: 1px solid var(--line);
  background: rgba(251, 252, 248, 0.92);
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 18px;
}

.metrics span {
  color: var(--muted);
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.form-grid {
  grid-template-columns: minmax(340px, 0.9fr) minmax(320px, 1.1fr);
}

.panel {
  padding: 18px;
}

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

.ghost,
.primary,
.danger-button,
.complete-button {
  min-height: 38px;
  border: 1px solid var(--accent);
  cursor: pointer;
}

.ghost {
  padding: 8px 12px;
  color: var(--accent);
  background: transparent;
}

.primary {
  padding: 10px 15px;
  color: white;
  background: var(--accent);
}

.danger-button {
  padding: 8px 12px;
  border-color: rgba(180, 63, 63, 0.45);
  color: var(--danger);
  background: #fff;
}

.danger-button:disabled {
  border-color: var(--line);
  color: #aab2ac;
  cursor: not-allowed;
  background: #f2f4ef;
}

.complete-button {
  padding: 8px 12px;
  border-color: rgba(192, 114, 51, 0.5);
  color: var(--accent-2);
  background: #fff;
}

.small {
  min-height: 34px;
  padding: 7px 12px;
}

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

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
}

.tag.ok {
  border-color: rgba(36, 110, 60, 0.3);
  color: var(--ok);
}

.tag.warn {
  border-color: rgba(192, 114, 51, 0.4);
  color: var(--accent-2);
}

.tag.danger {
  border-color: rgba(180, 63, 63, 0.35);
  color: var(--danger);
}

.progress-list,
.compact-list,
.job-board {
  display: grid;
  gap: 12px;
}

.progress-item {
  display: grid;
  gap: 7px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.bar {
  height: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #edf1e8;
}

.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #6b8f4f);
}

.compact-item,
.job-card,
.lookup-card {
  padding: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.compact-item strong,
.compact-item span {
  display: block;
}

.compact-item span {
  margin-top: 4px;
  color: var(--muted);
}

.form {
  display: grid;
  gap: 12px;
}

.inline-form {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.inline-form textarea,
.inline-form button {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  outline-color: var(--accent);
}

textarea {
  resize: vertical;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  overflow: hidden;
}

.segmented label {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  color: var(--ink);
  background: #fff;
}

.segmented input {
  width: auto;
}

.scan-guide {
  display: grid;
  gap: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin: 12px 0 18px;
}

.job-card {
  display: grid;
  gap: 10px;
}

.job-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.job-card .details {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  color: var(--muted);
}

.job-card .details strong {
  display: block;
  color: var(--ink);
}

.toast {
  position: fixed;
  z-index: 20;
  right: 26px;
  bottom: 26px;
  max-width: 420px;
  padding: 13px 16px;
  color: #fff;
  background: #17201b;
  box-shadow: var(--shadow);
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .shell {
    margin-left: 0;
    padding: 18px;
  }

  nav,
  .metrics,
  .grid.two,
  .form-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .quick-scan {
    min-width: 0;
  }

  .inline-form textarea,
  .inline-form button {
    grid-column: auto;
  }
}
