:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #16283a;
  background: #f2f5f7;
  font-synthesis: none;
  --navy: #0b1f33;
  --navy-2: #102a43;
  --teal: #0f7f86;
  --aqua: #21c3bd;
  --green: #218565;
  --amber: #d98717;
  --red: #c84845;
  --line: #dce4e9;
  --muted: #687b8c;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; background: var(--navy); }
.login-story { padding: clamp(48px, 8vw, 110px); display: flex; flex-direction: column; justify-content: center; color: white; position: relative; overflow: hidden; }
.login-story::before, .login-story::after { content: ""; position: absolute; border: 1px solid rgba(33,195,189,.2); border-radius: 50%; }
.login-story::before { width: 580px; height: 580px; right: -260px; top: -200px; }
.login-story::after { width: 350px; height: 350px; right: -140px; top: -85px; }
.brand-mark { width: 64px; height: 64px; border: 1px solid rgba(255,255,255,.26); display: grid; place-items: center; border-radius: 18px; margin-bottom: 48px; transform: rotate(45deg); background: rgba(255,255,255,.05); }
.brand-mark span { transform: rotate(-45deg); font-size: 28px; font-weight: 800; color: var(--aqua); }
.eyebrow { margin: 0 0 12px; letter-spacing: .18em; font-size: 11px; font-weight: 800; color: var(--aqua); }
.eyebrow.dark { color: var(--teal); }
.login-story h1 { font-size: clamp(44px, 5.5vw, 76px); line-height: 1.03; letter-spacing: -.055em; margin: 0; max-width: 760px; }
.login-story h1 em { color: var(--aqua); font-style: normal; }
.story-copy { max-width: 580px; line-height: 1.8; color: rgba(255,255,255,.68); font-size: 16px; margin: 28px 0 42px; }
.signal-strip { display: flex; flex-wrap: wrap; gap: 24px; font-size: 12px; color: rgba(255,255,255,.72); }
.signal-strip span { display: flex; align-items: center; gap: 8px; }
.signal-strip b { width: 7px; height: 7px; border-radius: 50%; background: var(--aqua); box-shadow: 0 0 14px var(--aqua); }
.login-panel { display: grid; place-items: center; background: #edf2f4; padding: 32px; }
.login-card { width: min(430px, 100%); background: white; border-radius: 24px; padding: 42px; box-shadow: 0 28px 80px rgba(10,31,49,.12); display: grid; gap: 18px; }
.login-card h2 { margin: 0; font-size: 32px; letter-spacing: -.03em; color: var(--navy); }
.muted, .topbar p, .section-toolbar p { color: var(--muted); }
label { display: grid; gap: 7px; color: #3c5265; font-size: 13px; font-weight: 650; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 13px 14px; color: var(--navy); background: #fbfcfd; outline: none; transition: .2s; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,127,134,.1); }
.primary-button { border: 0; border-radius: 12px; background: var(--navy); color: white; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; font-weight: 750; margin-top: 5px; }
.primary-button:hover { background: var(--teal); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.form-error { min-height: 18px; margin: 0; font-size: 12px; color: var(--red); }
.security-note { font-size: 11px; color: #8493a0; line-height: 1.55; margin: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 246px 1fr; }
.sidebar { background: var(--navy); color: white; padding: 24px 15px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 12px 28px; border-bottom: 1px solid rgba(255,255,255,.09); }
.mini-mark { width: 38px; height: 38px; display: grid; place-items: center; color: var(--aqua); font-weight: 900; border: 1px solid rgba(33,195,189,.48); border-radius: 11px; }
.sidebar-brand div { display: grid; }
.sidebar-brand strong { font-size: 16px; }
.sidebar-brand small { color: rgba(255,255,255,.45); font-size: 8px; letter-spacing: .16em; margin-top: 3px; }
.sidebar nav { display: grid; gap: 5px; margin-top: 24px; }
.sidebar nav button { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 0; border-radius: 10px; background: transparent; color: rgba(255,255,255,.62); text-align: left; font-size: 13px; }
.sidebar nav button span { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; font-size: 11px; }
.sidebar nav button:hover { color: white; background: rgba(255,255,255,.05); }
.sidebar nav button.active { color: white; background: rgba(33,195,189,.13); }
.sidebar nav button.active span { color: var(--aqua); border-color: rgba(33,195,189,.34); }
.sidebar-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid rgba(255,255,255,.09); display: flex; gap: 10px; align-items: center; }
.sidebar-foot div { display: grid; }
.sidebar-foot strong { font-size: 11px; }
.sidebar-foot small { font-size: 9px; color: rgba(255,255,255,.42); margin-top: 2px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--aqua); box-shadow: 0 0 12px var(--aqua); }
.workspace { min-width: 0; }
.topbar { min-height: 136px; background: white; border-bottom: 1px solid var(--line); padding: 28px clamp(24px, 4vw, 58px); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar h1 { margin: 0; color: var(--navy); font-size: 28px; letter-spacing: -.035em; }
.topbar p { margin: 5px 0 0; font-size: 12px; }
.account { display: flex; align-items: center; gap: 10px; }
.account-avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: white; background: var(--teal); font-weight: 800; }
.account > div:nth-child(2) { display: grid; }
.account strong { font-size: 12px; }
.account small { font-size: 10px; color: var(--muted); margin-top: 2px; }
.account button { margin-left: 8px; border: 1px solid var(--line); background: white; border-radius: 9px; padding: 8px 11px; color: var(--muted); font-size: 11px; }
.content { padding: 30px clamp(20px, 4vw, 58px) 60px; }
.loading-card, .error-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 28px; color: var(--muted); }
.error-card strong { color: var(--red); }
.error-card button { border: 0; border-radius: 8px; background: var(--navy); color: white; padding: 9px 13px; }

.metrics-grid { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 12px; }
.metric-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: grid; min-height: 130px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; height: 4px; left: 18px; right: 18px; bottom: 0; border-radius: 9px 9px 0 0; background: var(--teal); }
.metric-card.tone-1::after { background: var(--aqua); }
.metric-card.tone-2::after { background: var(--amber); }
.metric-card span { font-size: 11px; color: var(--muted); }
.metric-card strong { align-self: end; font-size: 34px; line-height: 1; color: var(--navy); }
.metric-card small { color: #90a0ad; font-size: 9px; margin-top: 6px; }
.dashboard-grid { display: grid; grid-template-columns: 1.45fr .55fr; gap: 14px; margin-top: 14px; }
.panel { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.panel h3, .section-toolbar h3 { margin: 3px 0 0; color: var(--navy); font-size: 17px; }
.kicker { font-size: 9px; letter-spacing: .15em; color: var(--teal); font-weight: 800; text-transform: uppercase; }
.flow-line { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 14px; align-items: center; margin-top: 32px; }
.flow-line > div { border: 1px solid var(--line); border-radius: 13px; padding: 15px; display: grid; gap: 4px; }
.flow-line b { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #e7f5f4; color: var(--teal); font-size: 10px; margin-bottom: 7px; }
.flow-line strong { font-size: 12px; }
.flow-line small { font-size: 9px; color: var(--muted); }
.flow-line i { color: var(--aqua); font-style: normal; }
.integrity-panel { display: flex; flex-direction: column; }
.integrity-score { display: grid; margin-top: auto; }
.integrity-score strong { color: var(--teal); font-size: 38px; }
.integrity-score span { font-size: 10px; color: var(--muted); line-height: 1.5; }
.bar { height: 6px; background: #e8eff1; border-radius: 8px; margin-top: 16px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--aqua); }

.section-toolbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.section-toolbar p { margin: 5px 0 0; font-size: 11px; }
.primary-small, .secondary { border: 0; border-radius: 9px; padding: 10px 14px; background: var(--navy); color: white; font-size: 11px; font-weight: 700; }
.secondary { color: var(--muted); background: #edf1f3; }
.danger-small { border: 0; border-radius: 9px; padding: 10px 14px; background: #fdecec; color: var(--red); font-size: 11px; font-weight: 700; margin-left: 6px; }
.danger-small:hover { background: var(--red); color: white; }
.danger-small:disabled { background: #edf1f3; color: var(--muted); }
.table-card { background: white; border: 1px solid var(--line); border-radius: 16px; overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th { background: #f8fafb; color: #718391; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); }
td { padding: 14px 16px; border-bottom: 1px solid #edf1f3; font-size: 11px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfd; }
td strong { display: block; color: var(--navy); font-size: 11px; }
td small { display: block; color: var(--muted); font-size: 9px; margin-top: 4px; }
td code { color: var(--teal); background: #edf8f7; padding: 4px 6px; border-radius: 5px; font-size: 9px; }
.truncate { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.click-row { cursor: pointer; }
.status-badge { display: inline-flex; align-items: center; white-space: nowrap; padding: 4px 8px; border-radius: 999px; background: #edf1f3; color: #617482; font-size: 9px; font-weight: 750; }
.status-badge.good { background: #e4f4ed; color: var(--green); }
.status-badge.bad { background: #fbe9e8; color: var(--red); }
.status-badge.warn { background: #fff1dc; color: var(--amber); }
.status-badge.blue { background: #e4f3f5; color: var(--teal); }
.success-text { color: var(--green); }
.danger-text { color: var(--red); }
.toggle { width: 37px; height: 21px; padding: 2px; border: 0; border-radius: 20px; background: #c9d3d9; }
.toggle i { display: block; width: 17px; height: 17px; border-radius: 50%; background: white; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle.on { background: var(--teal); }
.toggle.on i { transform: translateX(16px); }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(5,21,34,.58); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(4px); }
.modal { width: min(500px, 100%); max-height: 90vh; overflow: auto; background: white; border-radius: 18px; box-shadow: 0 30px 90px rgba(0,0,0,.24); padding: 22px; }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; color: var(--navy); }
.modal-close { border: 0; background: transparent; color: var(--muted); font-size: 25px; }
.modal form { display: grid; gap: 14px; padding-top: 18px; }
.check { display: flex; align-items: center; }
.check input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.segment-list { display: grid; gap: 10px; padding-top: 16px; }
.segment-list article { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 8px; }
.segment-list article > div { display: flex; align-items: center; justify-content: space-between; }
.segment-list small { color: var(--muted); font-size: 9px; }
.segment-list code { font-size: 9px; overflow-wrap: anywhere; color: var(--teal); }
.segment-list summary { cursor: pointer; color: var(--muted); font-size: 10px; }
.segment-list pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #f4f7f8; padding: 10px; border-radius: 8px; font-size: 9px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; padding: 12px 16px; border-radius: 10px; background: var(--navy); color: white; font-size: 12px; transform: translateY(20px); opacity: 0; transition: .2s; box-shadow: 0 12px 30px rgba(0,0,0,.2); }
.toast.bad { background: var(--red); }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1180px) {
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .login-page { grid-template-columns: 1fr; }
  .login-story { min-height: 48vh; padding: 44px 28px; }
  .brand-mark { margin-bottom: 28px; }
  .login-panel { padding: 22px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px; }
  .sidebar-brand, .sidebar-foot { display: none; }
  .sidebar nav { margin: 0; display: flex; overflow-x: auto; }
  .sidebar nav button { flex: 0 0 auto; }
  .topbar { min-height: auto; padding: 22px; align-items: flex-start; }
  .topbar > div:first-child p:last-child { display: none; }
  .account > div:nth-child(2) { display: none; }
  .content { padding: 22px 14px 50px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .flow-line { grid-template-columns: 1fr; }
  .flow-line i { transform: rotate(90deg); justify-self: center; }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 22px; }
  .login-story h1 { font-size: 42px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 112px; }
  .section-toolbar { align-items: flex-start; gap: 12px; }
}
