﻿:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ec;
  --primary: #1677ff;
  --primary-dark: #0f5fd3;
  --success: #0f9f6e;
  --warning: #b76e00;
  --danger: #c2410c;
  --soft: #fbfcff;
  --shadow: 0 10px 24px rgba(21, 31, 53, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

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

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 12px;
  white-space: nowrap;
}

button:hover {
  border-color: var(--primary);
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

button.primary:hover {
  background: var(--primary-dark);
}

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

button.danger {
  color: var(--danger);
}

button.small {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #98a2b3;
  font-weight: 400;
  opacity: 1;
}

textarea {
  min-height: 130px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

label,
.field-title {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(140deg, rgba(22, 119, 255, 0.12), transparent 45%),
    linear-gradient(320deg, rgba(15, 159, 110, 0.12), transparent 40%),
    var(--bg);
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card h1,
.topbar h1,
.panel h2,
.section-head h2 {
  margin: 0;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted,
.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--success);
  font-size: 13px;
}

.message.error,
.toast.error {
  color: var(--danger);
}

.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.app {
  min-height: 100vh;
  width: min(1560px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 16px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 14px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

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

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

.metrics article {
  min-height: 82px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics span {
  display: block;
  font-size: 26px;
  font-weight: 800;
}

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

.workspace {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-height: 0;
}

.app-shell {
  margin-top: 0;
}

.side-panel,
.main-panel {
  display: grid;
  gap: 12px;
}

.side-nav {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  min-height: min(640px, calc(100vh - 24px));
  overflow: auto;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.nav-title {
  display: grid;
  gap: 5px;
  padding: 8px 6px 16px;
  border-bottom: 1px solid var(--line);
}

.nav-title strong {
  font-size: 17px;
  line-height: 1.25;
}

.nav-title small {
  color: var(--muted);
  font-size: 13px;
}

.nav-menu {
  display: grid;
  gap: 10px;
  padding-top: 16px;
}

.panel,
.main-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.main-panel {
  overflow: hidden;
}

.panel h3,
.section-subhead h3 {
  margin: 0;
}

.form-panel {
  margin-bottom: 14px;
}

.compact-form {
  max-width: 920px;
}

.license-form {
  max-width: 1040px;
}

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

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

.checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 500;
}

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

.check-item.disabled {
  color: var(--muted);
  background: #f8fafc;
  opacity: 0.72;
}

.tab {
  width: 100%;
  min-height: 46px;
  justify-content: flex-start;
  background: #f8fafc;
  text-align: left;
  padding: 10px 14px;
  border-color: #d5deeb;
  font-size: 15px;
}

.tab:hover {
  background: #eef4ff;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(22, 119, 255, 0.18);
}

.tab-panel {
  display: none;
  min-width: 0;
  padding: 22px;
}

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

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  font-size: 24px;
  line-height: 1.25;
}

.section-subhead {
  margin: 20px 0 10px;
  padding-top: 2px;
}

.section-subhead p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.global-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px)) minmax(180px, 1fr);
  gap: 12px;
  align-items: end;
  padding: 14px 18px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.quick-grid button,
.info-card {
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.info-card {
  display: grid;
  gap: 8px;
}

.info-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-warning span {
  color: var(--danger);
}

.inline-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-tools {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-height: min(440px, calc(100vh - 310px));
}

.tall-table {
  max-height: min(520px, calc(100vh - 280px));
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fc;
  color: #344054;
  font-weight: 800;
  white-space: nowrap;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 92px;
  padding: 24px;
  background: #fbfcff;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

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

.row-focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: #edf4ff;
}

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

.license-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(64px, 1fr));
  width: min(300px, 100%);
  gap: 6px;
}

.license-actions .small {
  min-width: 0;
  min-height: 26px;
  justify-content: center;
  padding: 3px 6px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.badge.active,
.badge.activated {
  background: #e8f7f0;
  color: var(--success);
}

.badge.inactive {
  background: #eef2f7;
  color: #475467;
}

.badge.disabled,
.badge.revoked,
.badge.recycled,
.badge.expired {
  background: #fff2e8;
  color: var(--danger);
}

.badge.bundle {
  background: #edf4ff;
  color: var(--primary);
}

.tag {
  display: inline-flex;
  align-items: center;
  max-width: 210px;
  min-height: 24px;
  margin: 2px 4px 2px 0;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, 104px));
  gap: 4px;
  width: max-content;
  max-width: 220px;
}

.project-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
}

.project-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-state {
  margin-left: 3px;
  color: var(--danger);
  font-size: 9px;
  font-weight: 800;
}

.more-tag {
  background: #f8fafc;
  color: var(--muted);
  grid-template-columns: 1fr;
  justify-content: center;
  text-align: center;
}

.tag.danger-tag,
.project-pill.danger-tag {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--danger);
}

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

.mono {
  font-family: Consolas, "Courier New", monospace;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.38);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: min(760px, calc(100vw - 40px));
  max-height: min(780px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.modal-head h3 {
  margin: 0;
}

#modalBody {
  padding: 18px;
}

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

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}

.detail-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid strong {
  color: var(--text);
  font-size: 14px;
}

.modal-field {
  display: block;
}

.modal-field textarea {
  min-height: 220px;
  margin-top: 8px;
  font-family: Consolas, "Courier New", monospace;
}

.modal-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 4px 0 12px;
}

.notice-panel {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  line-height: 1.5;
}

.copy-panel {
  display: grid;
  gap: 12px;
}

.copy-panel p {
  margin: 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(520px, calc(100vw - 36px));
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--success);
  font-size: 13px;
}

.toast:empty {
  display: none;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
    max-height: none;
  }

  .nav-menu {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

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

  .global-tools,
  .quick-grid,
  .inline-tools,
  .compact-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app {
    width: calc(100vw - 20px);
    padding: 10px 0;
  }

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

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1 1 110px;
  }

  .tab-panel {
    padding: 16px;
  }

  .panel {
    padding: 14px;
  }

  .table-wrap,
  .tall-table {
    max-height: none;
  }

  .metrics,
  .grid.two,
  .inline-tools,
  .checks,
  .global-tools,
  .quick-grid,
  .nav-menu {
    grid-template-columns: 1fr;
  }
}
