:root {
  --paper: #f2eee4;
  --raised: #fffdf6;
  --ink: #171914;
  --soft: #4d5048;
  --faint: #77796f;
  --line: #d6cebd;
  --red: #d84a2f;
  --jade: #2f6e58;
  --amber: #a96f18;
  --shadow: 0 18px 50px rgba(42, 35, 24, 0.12);
  --font-display: "Songti SC", "STSong", "Noto Serif SC", serif;
  --font-ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-ui);
  background-image:
    linear-gradient(rgba(23, 25, 20, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 25, 20, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--faint); }
.eyebrow {
  margin: 0 0 8px;
  color: var(--faint);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--red);
  color: #fff;
  font: 700 22px/1 var(--font-display);
  transform: rotate(-3deg);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.2);
}
.brand-mark.small { width: 35px; height: 35px; border-radius: 10px; font-size: 16px; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 1.05fr) minmax(420px, 0.95fr);
}
.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 72px clamp(42px, 7vw, 120px);
  background: #191b16;
  color: #fffdf6;
}
.login-brand::after {
  content: "GUARD";
  position: absolute;
  right: -30px;
  bottom: -70px;
  color: rgba(255,255,255,.035);
  font: 700 180px/1 var(--font-display);
}
.login-brand .eyebrow { color: #a5a99b; margin-top: 30px; }
.login-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(44px, 5.2vw, 78px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}
.login-brand > p:not(.eyebrow) {
  max-width: 620px;
  margin: 22px 0 0;
  color: #c7c8be;
  font-size: 13px;
  line-height: 1.8;
}
.brand-foot { margin-top: 50px; color: #8f9387; font-size: 10px; }
.login-panel { display: grid; place-items: center; padding: 30px; }
.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--raised);
  padding: 32px;
  box-shadow: var(--shadow);
}
.login-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 30px;
}
.login-card > .muted { margin: 0 0 26px; font-size: 11px; line-height: 1.6; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field span { color: var(--soft); font-size: 10px; font-weight: 700; }
.input, .select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefa;
  padding: 0 12px;
  outline: none;
  font-size: 12px;
}
.input:focus, .select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23,25,20,.08); }
.btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raised);
  padding: 7px 13px;
  font-size: 11px;
  font-weight: 700;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { border-color: var(--ink); background: var(--ink); color: white; }
.login-card .btn.primary { width: 100%; min-height: 44px; margin-top: 4px; }
.security-note { margin: 16px 0 0; color: var(--faint); font-size: 8px; line-height: 1.5; text-align: center; }
.alert { border-radius: 9px; padding: 10px 12px; font-size: 10px; line-height: 1.5; }
.alert.error { margin-bottom: 12px; background: #fae7df; color: #a73624; }
.alert.success { background: #e2efe8; color: var(--jade); }

.dashboard-view { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #ebe4d6;
  padding: 18px 14px 14px;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 7px 20px; }
.side-brand strong { display: block; font-family: var(--font-display); font-size: 18px; }
.side-brand span { display: block; margin-top: 3px; color: var(--faint); font-size: 8px; }
.nav { display: grid; gap: 4px; }
.nav button {
  min-height: 37px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--soft);
  padding: 0 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 650;
}
.nav button:hover { background: rgba(255,255,255,.55); }
.nav button.active { border-color: var(--line); background: var(--raised); color: var(--ink); box-shadow: 0 4px 14px rgba(50,42,28,.06); }
.side-account {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 15px 7px 1px;
}
.side-account span { display: block; color: var(--faint); font-size: 8px; }
.side-account strong { display: block; margin: 4px 0 10px; font-size: 11px; }
.text-button { display: block; border: 0; background: transparent; color: var(--soft); padding: 5px 0; font-size: 9px; }
.workspace { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(242,238,228,.92);
  backdrop-filter: blur(14px);
  padding: 12px 28px;
}
.topbar h1 { margin: 0; font-family: var(--font-display); font-size: 22px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions .muted { font-size: 9px; }
.content { max-width: 1500px; margin: 0 auto; padding: 24px 28px 46px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 11px; }
.metric-card { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--raised); padding: 17px; }
.metric-card span { color: var(--faint); font-size: 9px; font-weight: 700; letter-spacing: .05em; }
.metric-card strong { display: block; margin-top: 9px; font-family: var(--font-display); font-size: 31px; line-height: 1; }
.metric-card small { display: block; margin-top: 7px; color: var(--faint); font-size: 8px; }
.metric-card.hot { border-color: #e6b5a8; background: #fff7f2; }
.metric-card.hot strong { color: var(--red); }
.panel { border: 1px solid var(--line); border-radius: 17px; background: rgba(255,253,246,.88); padding: 17px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.panel-head h2, .panel-head h3 { margin: 0; font-family: var(--font-display); font-size: 18px; }
.panel-head p { margin: 4px 0 0; color: var(--faint); font-size: 9px; }
.grid-2 { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(320px,.8fr); gap: 14px; margin-top: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 9px; }
th { background: #243a36; color: white; padding: 10px; text-align: left; white-space: nowrap; }
td { border-top: 1px solid var(--line); padding: 10px; vertical-align: middle; }
tbody tr:nth-child(even) { background: #f5f7f5; }
td code { font-size: 8px; }
.status { display: inline-flex; border-radius: 999px; padding: 3px 7px; font-size: 8px; font-weight: 700; }
.status.active, .status.paid, .status.processed { background: #e2efe8; color: var(--jade); }
.status.pending, .status.trial { background: #faefd8; color: #865410; }
.status.disabled, .status.failed, .status.closed { background: #fae7df; color: #a73624; }
.action-row { display: flex; flex-wrap: wrap; gap: 5px; }
.action-row .btn { min-height: 27px; padding: 3px 7px; font-size: 8px; }
.empty { padding: 26px 12px; color: var(--faint); font-size: 10px; text-align: center; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.pagination span { color: var(--faint); font-size: 9px; }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.plan-card { border: 1px solid var(--line); border-radius: 14px; background: var(--raised); padding: 15px; }
.plan-card h3 { margin: 0 0 12px; font-family: var(--font-display); font-size: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 1000; display: grid; gap: 8px; }
.toast { max-width: 330px; border-left: 3px solid var(--red); border-radius: 9px; background: var(--ink); color: white; padding: 10px 13px; box-shadow: var(--shadow); font-size: 10px; line-height: 1.5; }
.modal-layer { position: fixed; inset: 0; z-index: 999; display: grid; place-items: center; background: rgba(23,25,20,.42); padding: 18px; }
.modal { width: min(430px,100%); border: 1px solid var(--line); border-radius: 18px; background: var(--raised); box-shadow: var(--shadow); padding: 20px; }
.modal h2 { margin: 0 0 16px; font-family: var(--font-display); font-size: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 14px; }

@media (max-width: 980px) {
  .login-view { grid-template-columns: 1fr; }
  .login-brand { min-height: 330px; padding: 44px 30px; }
  .login-brand h1 { font-size: 46px; }
  .dashboard-view { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(4, 1fr); }
  .nav button { text-align: center; padding: 5px; }
  .side-account { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
  .side-account strong { margin: 0; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .content { padding: 14px; }
  .topbar { padding: 11px 14px; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .metric-grid, .plan-grid, .form-grid { grid-template-columns: 1fr; }
  .login-panel { padding: 18px; }
  .login-brand { padding: 34px 24px; }
}
