@font-face {
  font-family: "Noto Sans SC Subset";
  src: url("/static/fonts/noto-sans-sc-subset.woff?v=axosn4") format("woff");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #172033;
  --muted: #68738a;
  --line: #dfe5ef;
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --green: #0f8a64;
  --red: #be3f47;
  --shadow: 0 18px 50px rgba(40, 52, 90, 0.1);
  font-family: "Noto Sans SC Subset", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #f8faff 0%, var(--bg) 100%);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 10px;
  padding: 0.72rem 1rem;
  background: var(--brand);
  color: white;
  font-weight: 750;
  cursor: pointer;
}
button:hover { background: var(--brand-dark); }
button.secondary {
  background: #eef1f7;
  color: var(--text);
}
button.secondary:hover { background: #e2e7f0; }
button.danger {
  background: #fee2e4;
  color: var(--red);
}
button.small {
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
}
code {
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  background: #eef1f7;
}
.hidden { display: none !important; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  background: #151d31;
  color: white;
}
.eyebrow {
  margin: 0 0 0.35rem;
  color: #aeb8e8;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
h1, h2 { margin: 0; letter-spacing: -0.03em; }
h1 { font-size: clamp(1.5rem, 3vw, 2.3rem); }
h2 { font-size: 1.25rem; }
p { color: var(--muted); line-height: 1.55; }
.session-panel { display: flex; align-items: center; gap: 0.7rem; }
.language-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.85rem;
  font-weight: 700;
}
.language-label select {
  width: auto;
  min-width: 5rem;
  border-color: rgba(255, 255, 255, 0.24);
  padding: 0.45rem 0.6rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
}
.language-label select option {
  color: #172033;
}
.status-pill {
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
}
.status-pill.connected { background: rgba(35, 197, 135, 0.18); color: #89efcf; }

main {
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}
.card, .metric-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card { margin-top: 1rem; padding: clamp(1rem, 2.5vw, 1.5rem); }
.login-card { max-width: 720px; margin: 3rem auto; }
.inline-form { display: flex; gap: 0.75rem; align-items: end; }
.grow { flex: 1; }
.hint { font-size: 0.9rem; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.metric-card { padding: 1.1rem; }
.metric-card span { color: var(--muted); font-size: 0.9rem; }
.metric-card strong { display: block; margin-top: 0.25rem; font-size: 2rem; }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.section-heading p { margin: 0.35rem 0 0; }
.rule-form, .test-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: end;
}
label {
  display: grid;
  gap: 0.4rem;
  color: #374156;
  font-size: 0.85rem;
  font-weight: 750;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #ccd4e2;
  border-radius: 10px;
  padding: 0.72rem 0.8rem;
  background: white;
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}
textarea { resize: vertical; }
.wide { grid-column: 1 / -1; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.7rem;
}
.checkbox-label input { width: auto; }
.form-actions { display: flex; gap: 0.6rem; }

.result-box {
  overflow: auto;
  margin: 1rem 0 0;
  border-radius: 12px;
  padding: 1rem;
  background: #111827;
  color: #dbeafe;
  line-height: 1.5;
  white-space: pre-wrap;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
td { font-size: 0.92rem; }
.rule-title strong { display: block; }
.rule-title span, .mono-small {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, "Noto Sans SC Subset", monospace;
  font-size: 0.78rem;
  word-break: break-all;
}
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.25rem 0.5rem;
  background: #eef1f7;
  color: #42506c;
  font-size: 0.78rem;
  font-weight: 800;
}
.badge.enabled { background: #dcf8ed; color: var(--green); }
.badge.disabled { background: #fee2e4; color: var(--red); }
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.destination { max-width: 280px; word-break: break-all; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(420px, calc(100vw - 2rem));
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: #172033;
  color: white;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 180ms ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

.tabs {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}
.tab-button {
  background: #e8ecf4;
  color: #33415c;
}
.tab-button.active {
  background: var(--brand);
  color: white;
}
.dashboard-grid.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.test-form.six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.handoff-result {
  margin-top: 1rem;
  border: 1px solid #bfe8d8;
  border-radius: 12px;
  padding: 1rem;
  background: #effbf6;
  line-height: 1.6;
}
.handoff-result a {
  color: var(--green);
  font-weight: 800;
}
.tab-panel {
  animation: fade-in 140ms ease;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1100px) {
  .dashboard-grid.five, .test-form.six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .topbar, .section-heading, .inline-form { align-items: stretch; flex-direction: column; }
  .dashboard-grid, .dashboard-grid.five, .rule-form, .test-form, .test-form.six { grid-template-columns: 1fr; }
  .session-panel { justify-content: space-between; }
  .tabs { flex-direction: column; }
}

/* Security center */
.security-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  border-left: 5px solid #ef4444;
}

.security-hero h2 { margin: 0.2rem 0; }
.eyebrow { margin: 0; color: #dc2626; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }
.dashboard-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric-card strong { font-size: 2rem; }
.danger-metric strong { color: #dc2626; }
.security-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
.resource-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; margin-top: 1rem; }
.resource-card { padding: 0.9rem; border: 1px solid #e5e7eb; border-radius: 16px; background: #f9fafb; }
.resource-card span, .resource-card small { display: block; color: #64748b; font-size: 0.78rem; }
.resource-card strong { display: block; margin: 0.25rem 0; font-size: 1.45rem; }
.service-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.security-block-form { align-items: end; margin-top: 1rem; }
.section-subheading { margin-top: 1.2rem; }
.section-subheading h3 { margin: 0; font-size: 0.95rem; }
.blocked-ip-list { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 0.7rem; }
.blocked-ip { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.45rem 0.4rem 0.7rem; border: 1px solid #fecaca; border-radius: 999px; background: #fff7f7; }
button.small { padding: 0.35rem 0.6rem; border-radius: 999px; font-size: 0.78rem; }
button.danger { border-color: #fecaca; background: #dc2626; color: white; }
.attack-chart { display: flex; align-items: end; gap: 0.35rem; min-height: 150px; padding-top: 1rem; overflow-x: auto; }
.attack-column { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; min-width: 24px; height: 140px; justify-content: end; }
.attack-stack { display: flex; flex-direction: column-reverse; justify-content: start; width: 14px; height: 110px; border-radius: 8px; overflow: hidden; background: #f1f5f9; }
.attack-ssh { display: block; width: 100%; background: #ef4444; }
.attack-web { display: block; width: 100%; background: #f59e0b; }
.attack-column small { color: #64748b; font-size: 0.65rem; writing-mode: vertical-rl; }
.policy-list { display: grid; gap: 0.65rem; margin-top: 1rem; }
.policy-row { display: flex; align-items: center; gap: 0.65rem; }
.security-center .result-box { max-height: 260px; overflow: auto; white-space: pre-wrap; }

@media (max-width: 1080px) {
  .dashboard-grid.five, .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .security-grid { grid-template-columns: 1fr; }
}

.owner-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-bottom: 12px;
}
.owner-status code {
  background: rgba(99, 102, 241, 0.08);
  border-radius: 6px;
  padding: 2px 8px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
