:root {
  color-scheme: light;
  --bg: #edf4f2;
  --bg-deep: #dbe9e4;
  --ink: #182124;
  --muted: #697578;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --line: rgba(28, 42, 45, 0.12);
  --jade: #1f9d80;
  --jade-dark: #11735f;
  --coral: #e85d4f;
  --gold: #d4942b;
  --charcoal: #20292d;
  --shadow: 0 18px 52px rgba(30, 55, 55, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(31, 157, 128, 0.22), transparent 32rem),
    radial-gradient(circle at 86% 18%, rgba(232, 93, 79, 0.16), transparent 30rem),
    linear-gradient(135deg, #f7fbf9 0%, var(--bg) 42%, #f3eddc 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(247, 251, 249, 0.72);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: #fff;
  background:
    linear-gradient(135deg, var(--jade), #2d6f88 58%, var(--coral));
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(31, 157, 128, 0.28);
}

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

.brand small,
.eyebrow,
td small,
.metric small {
  color: var(--muted);
}

.brand small {
  margin-top: 3px;
  font-size: 12px;
}

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

nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  color: #425053;
  font-weight: 650;
}

nav a:hover,
nav a.is-active {
  background: rgba(31, 157, 128, 0.12);
  color: var(--jade-dark);
}

.workspace {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 48px) 48px;
}

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

.topbar h1,
.panel h2,
.modal h2 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.top-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-action,
.ghost-button,
.icon-button,
.chip-button {
  border: 0;
  cursor: pointer;
  min-height: 40px;
  border-radius: 8px;
  font-weight: 760;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: #fff;
  background: var(--charcoal);
  box-shadow: 0 12px 24px rgba(32, 41, 45, 0.18);
}

.ghost-button {
  padding: 0 14px;
  color: var(--jade-dark);
  background: rgba(31, 157, 128, 0.12);
}

.icon-button {
  width: 42px;
  font-size: 19px;
  color: var(--ink);
  background: var(--panel-solid);
  border: 1px solid var(--line);
}

.chip-button {
  min-height: 32px;
  padding: 0 10px;
  color: #2e3b3e;
  background: #eef5f2;
}

.chip-button.danger {
  color: #9f3025;
  background: rgba(232, 93, 79, 0.14);
}

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

.metric-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric,
.panel,
.stat-card,
.domain-card,
.account-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.metric {
  min-height: 138px;
  padding: 22px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto -28px -42px auto;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(31, 157, 128, 0.16);
}

.metric.accent-coral::after {
  background: rgba(232, 93, 79, 0.18);
}

.metric.accent-gold::after {
  background: rgba(212, 148, 43, 0.2);
}

.metric.accent-ink::after {
  background: rgba(32, 41, 45, 0.13);
}

.metric span {
  color: var(--muted);
  font-weight: 720;
}

.metric strong {
  display: block;
  margin: 14px 0 6px;
  font-size: 38px;
  line-height: 1;
}

.metric em {
  font-style: normal;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel {
  border-radius: 8px;
  padding: 20px;
}

.panel.wide {
  grid-row: span 2;
}

.panel-heading,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  font-size: 21px;
}

.server-cards,
.domain-grid,
.account-grid {
  display: grid;
  gap: 14px;
}

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

.stat-card,
.domain-card,
.account-card {
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.7);
}

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

.stat-head h3,
.card-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.online,
.status.active,
.status.valid,
.status.connected,
.status.healthy {
  color: #0f735e;
  background: rgba(31, 157, 128, 0.16);
}

.status.warning,
.status.limited,
.status.watch {
  color: #92610d;
  background: rgba(212, 148, 43, 0.19);
}

.status.offline,
.status.paused,
.status.expired,
.status.manual,
.status.low {
  color: #a0352b;
  background: rgba(232, 93, 79, 0.16);
}

.meter-group {
  display: grid;
  gap: 9px;
}

.meter {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #dfe9e6;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--jade), var(--gold));
}

.renew-list,
.event-list {
  display: grid;
  gap: 10px;
}

.renew-item,
.event-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
}

.renew-item strong,
.event-item strong {
  font-size: 15px;
}

.toolbar {
  flex-wrap: wrap;
}

.search-box {
  flex: 1 1 280px;
}

.search-box,
.editor label {
  display: grid;
  gap: 7px;
  color: #49575a;
  font-size: 14px;
  font-weight: 720;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(31, 157, 128, 0.55);
  box-shadow: 0 0 0 3px rgba(31, 157, 128, 0.12);
}

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

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

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

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

td strong,
td small {
  display: block;
}

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

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

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

.kv {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 6px 12px;
  color: var(--muted);
  font-size: 14px;
}

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

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 33, 36, 0.36);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.modal[hidden] {
  display: none;
}

.editor {
  width: min(820px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 22px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f9fcfa;
  box-shadow: 0 24px 70px rgba(12, 22, 24, 0.26);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.modal-head button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  font-size: 24px;
  cursor: pointer;
  background: #eef5f2;
}

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

.form-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.empty {
  padding: 26px;
  border: 1px dashed rgba(24, 33, 36, 0.18);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  nav {
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    overflow-x: auto;
  }

  .metric-grid,
  .metric-grid.compact,
  .dashboard-grid,
  .server-cards,
  .domain-grid,
  .account-grid {
    grid-template-columns: 1fr 1fr;
  }

  .panel.wide {
    grid-row: auto;
  }
}

@media (max-width: 720px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 14px 14px 10px;
    box-shadow: 0 8px 22px rgba(30, 55, 55, 0.08);
  }

  .brand {
    min-height: 44px;
    margin-bottom: 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

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

  .brand small {
    font-size: 11px;
  }

  nav {
    display: flex;
    gap: 6px;
    margin: 0 -2px;
    padding: 0 2px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  nav::-webkit-scrollbar {
    display: none;
  }

  nav a {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 12px;
    white-space: nowrap;
    font-size: 14px;
  }

  .workspace {
    padding: 18px 12px 32px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
  }

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

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .top-actions .primary-action {
    flex: 1;
  }

  .primary-action,
  .ghost-button,
  .icon-button {
    min-height: 44px;
  }

  .metric {
    min-height: 124px;
    padding: 18px;
  }

  .metric strong {
    margin-top: 12px;
    font-size: 34px;
  }

  .panel-heading,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .panel-heading .ghost-button,
  .toolbar select {
    width: 100%;
  }

  .search-box {
    flex-basis: auto;
  }

  .stat-card,
  .domain-card,
  .account-card {
    padding: 14px;
  }

  .stat-head,
  .card-head {
    gap: 10px;
  }

  .stat-head h3,
  .card-head h3 {
    font-size: 17px;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    display: block;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
  }

  tbody td {
    display: grid;
    gap: 4px;
    padding: 0;
    border: 0;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  tbody td::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  tbody td[colspan]::before {
    content: none;
  }

  tbody td:nth-child(1) {
    grid-column: 1 / -1;
  }

  tbody td:nth-child(1)::before {
    content: "节点 / 云厂商";
  }

  tbody td:nth-child(2)::before {
    content: "地址 / 余额";
  }

  tbody td:nth-child(3)::before {
    content: "资源 / 月消耗";
  }

  tbody td:nth-child(4)::before {
    content: "状态 / 阈值";
  }

  tbody td:nth-child(5)::before {
    content: "续费 / 最近充值";
  }

  tbody td:nth-child(6) {
    grid-column: 1 / -1;
  }

  tbody td:nth-child(6)::before {
    content: "操作";
  }

  .servers-table tbody td:nth-child(1)::before {
    content: "节点";
  }

  .servers-table tbody td:nth-child(2)::before {
    content: "IP / 端口";
  }

  .servers-table tbody td:nth-child(3)::before {
    content: "资源";
  }

  .servers-table tbody td:nth-child(4)::before {
    content: "状态";
  }

  .servers-table tbody td:nth-child(5)::before {
    content: "续费";
  }

  .clouds-table tbody td:nth-child(1)::before {
    content: "云厂商";
  }

  .clouds-table tbody td:nth-child(2)::before {
    content: "余额";
  }

  .clouds-table tbody td:nth-child(3)::before {
    content: "月消耗";
  }

  .clouds-table tbody td:nth-child(4)::before {
    content: "阈值 / 状态";
  }

  .clouds-table tbody td:nth-child(5)::before {
    content: "最近充值";
  }

  tbody .meter {
    grid-template-columns: 48px minmax(0, 1fr) 38px;
    width: 100%;
  }

  tbody .row-actions {
    width: 100%;
  }

  tbody .row-actions .chip-button {
    flex: 1 1 auto;
    min-height: 38px;
  }

  .editor {
    padding: 18px;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .form-actions > * {
    width: 100%;
  }

  .metric-grid,
  .metric-grid.compact,
  .dashboard-grid,
  .server-cards,
  .domain-grid,
  .account-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

}
