:root {
  --bg: #f2f5f9;
  --panel: #ffffff;
  --panel-soft: #f4f8ff;
  --line: #e5eaf1;
  --line-strong: #d8dee8;
  --text: #1f2937;
  --muted: #7a8494;
  --blue: #0f66e8;
  --blue-dark: #0756d4;
  --blue-soft: #eaf2ff;
  --green: #18a957;
  --red: #dc3c3c;
  --warning: #f5a623;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  font-family:
    "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--blue);
  text-decoration: none;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
  line-height: 1;
}

.brand strong {
  font-size: 15px;
}

.brand span {
  margin-top: 3px;
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
}

.nav {
  padding: 22px 0;
}

.nav-item {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  color: #687384;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: #f7f9fc;
  color: var(--text);
}

.nav-item.active {
  color: #fff;
  background: var(--blue-dark);
  border-left-color: var(--blue-dark);
  font-weight: 700;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.nav-icon svg {
  width: 17px;
  height: 17px;
  display: block;
}

.nav-item.active .nav-icon svg {
  stroke-width: 2;
}

.icon-button svg {
  width: 15px;
  height: 15px;
  display: block;
  margin: auto;
}

.sidebar-footer {
  margin-top: auto;
  height: 58px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #4b5563;
  cursor: pointer;
}

.workspace {
  min-width: 0;
}

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 700;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
}

h3 {
  font-size: 16px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #4b5563;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warning);
}

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

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

.account {
  margin-left: 12px;
  padding: 6px 10px;
  background: #f4f6f9;
  color: #334155;
}

.view {
  display: none;
  padding: 26px;
}

.view.active {
  display: block;
}

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

.quick-guide {
  padding: 26px;
  margin-bottom: 18px;
}

.section-heading,
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.inline-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.inline-check input {
  width: 14px;
  height: 14px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.guide-card {
  min-height: 190px;
  padding: 28px;
  background: var(--panel-soft);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.guide-number {
  color: #0875ff;
  font-size: 34px;
  line-height: 1;
  margin-bottom: 24px;
}

.guide-card h3 {
  margin-bottom: 10px;
}

.guide-card p {
  color: #293241;
  line-height: 1.75;
  margin-bottom: 22px;
}

.link-button,
.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  cursor: pointer;
}

.link-button {
  margin-top: auto;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 18px;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.content-grid.single-primary {
  grid-template-columns: minmax(360px, 620px) minmax(0, 1fr);
}

.span-2 {
  grid-column: span 1;
}

.panel {
  padding: 24px 26px;
}

.company-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.company-logo {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  background: var(--blue-dark);
  color: #fff;
  font-size: 24px;
}

.company-summary h2 {
  margin-bottom: 8px;
}

.company-summary p {
  margin-bottom: 0;
  color: var(--muted);
}

.summary-tags {
  display: flex;
  gap: 8px;
}

.tag {
  padding: 6px 10px;
  background: #f1f3f7;
  color: #6b7280;
  white-space: nowrap;
}

.tag.strong {
  background: #ef4444;
  color: #fff;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 22px;
}

.metric {
  min-height: 70px;
  padding: 0 22px;
  border-right: 1px solid var(--line);
}

.metric:first-child {
  padding-left: 0;
}

.metric:last-child {
  border-right: 0;
}

.metric span,
.overview-metrics span,
.status-list span {
  color: #9aa3af;
}

.metric strong,
.overview-metrics strong {
  display: block;
  margin-top: 12px;
  font-size: 27px;
  font-weight: 500;
}

.status-list {
  margin-top: 24px;
  display: grid;
  gap: 15px;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.status-list strong {
  font-weight: 600;
}

.overview-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
  margin-top: 28px;
}

.doc-links {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.form-stack,
.settings-form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

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

label {
  display: grid;
  gap: 8px;
  color: #5c6675;
  font-size: 13px;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 0 11px;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(15, 102, 232, 0.12);
}

textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 9px 11px;
  color: var(--text);
  outline: none;
  font: inherit;
  resize: vertical;
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(15, 102, 232, 0.12);
}

.config-company-select {
  max-width: 360px;
  margin-top: 16px;
}

.grant-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .grant-form {
    grid-template-columns: 1fr;
  }
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-content: center;
}

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

.primary-button {
  height: 38px;
  border: 0;
  background: var(--blue-dark);
  color: #fff;
  padding: 0 18px;
  cursor: pointer;
  justify-self: start;
}

.primary-button:hover {
  background: #004ac2;
}

.table-panel {
  padding-bottom: 10px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

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

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

th {
  color: #7d8796;
  font-size: 12px;
  font-weight: 600;
}

td {
  color: #2d3748;
}

.cell-title {
  font-weight: 700;
}

.cell-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 12px;
}

.pill.warn {
  background: #fff4dc;
  color: #9a5b00;
}

.pill.error {
  background: #ffe8e8;
  color: #b42318;
}

.pill.ok {
  background: #e7f8ee;
  color: #14783f;
}

.pill.deleted {
  background: #f1f3f7;
  color: #7a8494;
}

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

.small-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #374151;
  height: 30px;
  padding: 0 10px;
  cursor: pointer;
}

.small-button.danger {
  color: #b42318;
}

.result-box {
  min-height: 184px;
  max-height: 280px;
  overflow: auto;
  margin: 20px 0 0;
  padding: 14px;
  background: #0f172a;
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.6;
}

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 240px;
  max-width: 420px;
  padding: 12px 14px;
  background: #111827;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #b42318;
}

.drawer {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.24);
  z-index: 20;
}

.drawer.open {
  display: flex;
}

.drawer-panel {
  width: min(460px, 100vw);
  min-height: 100vh;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 28px rgba(15, 23, 42, 0.12);
  padding: 22px;
  overflow-y: auto;
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-form {
  display: none;
}

.drawer-form.active {
  display: grid;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .brand div:last-child,
  .nav-item span:last-child,
  .sidebar-footer span {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .guide-grid,
  .dashboard-grid,
  .content-grid,
  .content-grid.single-primary,
  .settings-form {
    grid-template-columns: 1fr;
  }

  .metric-strip,
  .overview-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  .metric {
    padding: 0;
    border-right: 0;
  }
}

@media (max-width: 720px) {
  .shell {
    display: block;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    padding: 0;
  }

  .nav-item {
    min-width: 72px;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    flex-direction: column;
  }

  .view {
    padding: 16px;
  }

  .quick-guide,
  .panel {
    padding: 18px;
  }

  .company-summary {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .summary-tags {
    grid-column: 1 / -1;
  }
}
