:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #152033;
  --muted: #718096;
  --line: #e5eaf2;
  --navy: #18345f;
  --blue: #2f6df6;
  --blue-soft: #eaf1ff;
  --green: #159b72;
  --green-soft: #e7f8f2;
  --amber: #d98715;
  --amber-soft: #fff5df;
  --violet: #7757d9;
  --violet-soft: #f0ebff;
  --rose: #d94b67;
  --rose-soft: #fff0f3;
  --shadow: 0 12px 34px rgba(25, 46, 79, .07);
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; }

.topbar {
  height: 72px;
  padding: 0 36px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand > div:last-child { display: grid; gap: 2px; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand span { color: #8a96a9; font-size: 9px; letter-spacing: .14em; font-weight: 700; }
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(145deg, #244e87, #16345e);
  box-shadow: 0 12px 24px rgba(28,61,105,.22);
  color: white;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 17px; }
.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f4f6f9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.sync-status i { width: 7px; height: 7px; border-radius: 50%; background: #9aa5b4; }
.sync-status.online { background: var(--green-soft); color: #087a58; }
.sync-status.online i { background: var(--green); box-shadow: 0 0 0 4px rgba(21,155,114,.1); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.sync-now-button {
  height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #d8e1ed;
  border-radius: 10px;
  background: #fff;
  color: var(--navy);
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(24,52,95,.05);
  transition: .18s ease;
}
.sync-now-button:hover { color: var(--blue); border-color: #aebfe0; transform: translateY(-1px); }
.sync-now-button:disabled { cursor: wait; opacity: .72; transform: none; }
.sync-icon { font-size: 18px; line-height: 1; }
.sync-now-button.loading .sync-icon { animation: sync-spin .8s linear infinite; }
@keyframes sync-spin { to { transform: rotate(360deg); } }
.page-toast {
  position: fixed;
  left: 50%;
  top: 86px;
  z-index: 100;
  max-width: min(520px, calc(100vw - 30px));
  padding: 12px 18px;
  border-radius: 11px;
  background: #173b68;
  color: #fff;
  box-shadow: 0 14px 38px rgba(15,35,62,.24);
  font-weight: 650;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: .22s ease;
}
.page-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.page-toast.error { background: #ad2f48; }

.page-shell { max-width: 1560px; margin: 0 auto; padding: 34px 30px 60px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.eyebrow.green { color: var(--green); }
.hero-row h1 { margin: 0; font-size: clamp(28px, 3vw, 42px); letter-spacing: -.045em; line-height: 1.1; }
.hero-row p:last-child { margin: 10px 0 0; color: var(--muted); }
.hero-actions { display: flex; gap: 8px; }
.ghost-button, .clear-button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 9px 13px;
  text-decoration: none;
  color: #4b5a70;
  font-weight: 600;
  font-size: 13px;
  transition: .18s ease;
}
.ghost-button:hover, .clear-button:hover { border-color: #bcc9dc; color: var(--blue); transform: translateY(-1px); }

.alert { padding: 13px 16px; border-radius: 12px; margin: 0 0 18px; line-height: 1.55; border: 1px solid; }
.alert strong { margin-right: 6px; }
.alert.error { background: #fff1f2; border-color: #fecdd3; color: #a51c36; }
.alert.warning { background: var(--amber-soft); border-color: #f5d89a; color: #87530a; }
.alert.info { background: var(--blue-soft); border-color: #cddcff; color: #244d9b; }
.alert code { background: rgba(255,255,255,.72); padding: 2px 5px; border-radius: 4px; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric-card {
  min-height: 132px;
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 5px 18px rgba(24,52,95,.035);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.metric-card::after { content: ""; position: absolute; right: -32px; top: -44px; width: 112px; height: 112px; border-radius: 50%; background: #f2f5fa; }
.metric-card.primary { background: linear-gradient(145deg, #204a81, #17355f); color: white; border-color: transparent; box-shadow: 0 16px 32px rgba(24,52,95,.18); }
.metric-card.primary::after { background: rgba(255,255,255,.07); }
.metric-card.danger { border-color: #f5d2d9; }
.metric-card.danger::after { background: var(--rose-soft); }
.metric-card span { color: var(--muted); font-weight: 650; position: relative; z-index: 1; }
.metric-card.primary span, .metric-card.primary small { color: rgba(255,255,255,.76); }
.metric-card strong { font-size: 34px; line-height: 1; letter-spacing: -.04em; position: relative; z-index: 1; }
.metric-card strong.compact { font-size: 25px; }
.metric-card.danger strong { color: var(--rose); }
.metric-card small { color: #98a3b3; position: relative; z-index: 1; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 20px; align-items: start; }
.main-panel, .side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.main-panel { min-width: 0; overflow: hidden; }
.filter-bar { padding: 16px; background: var(--surface-soft); border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.filter-field { display: grid; gap: 5px; min-width: 138px; }
.filter-field.date-filter { min-width: 150px; }
.filter-field.search-field { flex: 1; min-width: 170px; }
.filter-field label { color: #7a8799; font-size: 11px; font-weight: 700; }
.filter-field input, .filter-field select, .install-form input, .install-form select {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  color: var(--ink);
  background: white;
  border: 1px solid #dce3ec;
  border-radius: 9px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.filter-field input:focus, .filter-field select:focus, .install-form input:focus, .install-form select:focus { border-color: #8dadf8; box-shadow: 0 0 0 3px rgba(47,109,246,.1); }
.risk-toggle { height: 40px; display: flex; align-items: center; gap: 7px; white-space: nowrap; color: #59687d; font-weight: 600; cursor: pointer; }
.risk-toggle input { width: 16px; height: 16px; accent-color: var(--rose); }
.filter-button, .primary-button {
  border: 0;
  border-radius: 9px;
  min-height: 40px;
  padding: 9px 18px;
  background: var(--navy);
  color: white;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 7px 14px rgba(24,52,95,.15);
  transition: .18s ease;
}
.filter-button:hover, .primary-button:hover { background: #254f86; transform: translateY(-1px); }
.primary-button:disabled { opacity: .7; cursor: wait; transform: none; }
.clear-button { height: 40px; display: inline-flex; align-items: center; }
.primary-button.full { width: 100%; display: flex; justify-content: center; align-items: center; text-decoration: none; min-height: 46px; }

.table-heading { display: flex; align-items: center; justify-content: space-between; padding: 22px 22px 12px; }
.table-heading h2 { margin: 0; font-size: 19px; }
.table-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.system { background: var(--blue); }
.dot.manual { background: var(--rose); }

.flow-list { padding: 0 12px 14px; }
.flow-row { border: 1px solid transparent; border-top-color: #edf0f5; transition: .18s ease; }
.flow-row:first-child { border-top-color: transparent; }
.flow-row[open], .flow-row:hover { border-color: #dce4ef; border-radius: 12px; background: #fbfcfe; margin: 4px 0; }
.flow-row.high { border-left: 3px solid var(--rose); }
.flow-row.medium { border-left: 3px solid var(--amber); }
.flow-row summary { list-style: none; display: grid; grid-template-columns: 70px minmax(210px, 1.55fr) minmax(130px, .9fr) minmax(86px,.65fr) 22px minmax(86px,.65fr) 94px 18px; gap: 12px; align-items: center; min-height: 78px; padding: 10px 12px; cursor: pointer; }
.flow-row summary::-webkit-details-marker { display: none; }
.time-cell, .company-cell, .person-cell { display: grid; gap: 4px; }
.time-cell strong { font-size: 16px; }
.time-cell span, .company-cell span, .person-cell span { color: #96a0af; font-size: 11px; }
.company-cell { min-width: 0; }
.company-cell strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reason-cell { display: grid; gap: 5px; justify-items: start; }
.reason-cell small { color: #9aa4b2; font-size: 10px; }
.reason-badge { display: inline-flex; padding: 5px 8px; border-radius: 7px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.reason-badge.blue { color: #2457bd; background: var(--blue-soft); }
.reason-badge.amber { color: #9a5e09; background: var(--amber-soft); }
.reason-badge.violet { color: #6444c5; background: var(--violet-soft); }
.reason-badge.rose { color: #b72f4a; background: var(--rose-soft); }
.reason-badge.gray { color: #657388; background: #eef1f5; }
.person-cell strong { font-size: 13px; }
.person-cell.claim strong { color: var(--green); }
.flow-arrow { color: #c0c8d3; font-size: 17px; }
.duration-cell { justify-self: end; display: grid; justify-items: end; gap: 5px; color: #546278; font-size: 12px; font-weight: 700; }
.duration-cell b { padding: 3px 6px; border-radius: 5px; background: var(--rose-soft); color: var(--rose); font-size: 9px; }
.duration-cell b.medium { background: var(--amber-soft); color: var(--amber); }
.chevron { color: #9aa5b3; transition: transform .18s; }
.flow-row[open] .chevron { transform: rotate(180deg); }
.flow-details { margin: 0 12px 12px; padding: 14px 16px; border-radius: 10px; background: #f4f7fb; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.flow-details > div { display: grid; gap: 5px; }
.flow-details span { color: #8b96a7; font-size: 10px; font-weight: 650; }
.flow-details strong { font-size: 12px; }
.flow-details .flags { grid-column: 1 / -1; }
.flags p { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.flags em { font-style: normal; background: var(--rose-soft); color: #af314a; border: 1px solid #f5d2da; border-radius: 6px; padding: 4px 7px; font-size: 11px; font-weight: 650; }

.side-panel { display: grid; gap: 16px; }
.side-card { padding: 20px; }
.side-title { display: flex; justify-content: space-between; align-items: start; margin-bottom: 18px; }
.side-title h3 { margin: 0; font-size: 16px; }
.side-title > span { color: var(--muted); background: #f1f4f8; padding: 5px 8px; border-radius: 7px; font-size: 11px; font-weight: 700; }
.chart-item { margin-bottom: 16px; }
.chart-item:last-child { margin-bottom: 0; }
.chart-item > div:first-child { display: flex; justify-content: space-between; margin-bottom: 7px; color: #5b687a; font-size: 12px; }
.chart-item strong { color: var(--ink); }
.bar { height: 7px; background: #eef1f5; border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: #a7b3c4; }
.bar i.blue { background: var(--blue); }
.bar i.amber { background: #e7a23c; }
.bar i.violet { background: var(--violet); }
.bar i.rose { background: var(--rose); }
.rule-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; }
.rule-list li { display: flex; gap: 11px; align-items: center; }
.rule-list div { display: grid; gap: 3px; }
.rule-list strong { font-size: 12px; }
.rule-list span { color: var(--muted); font-size: 11px; }
.rule-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.rule-dot.blue { background: var(--blue); }
.rule-dot.amber { background: #e7a23c; }
.rule-dot.violet { background: var(--violet); }
.rule-dot.rose { background: var(--rose); }
.sync-card dl { margin: 0; display: grid; gap: 11px; }
.sync-card dl div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding-bottom: 10px; }
.sync-card dl div:last-child { border: 0; padding: 0; }
.sync-card dt { color: var(--muted); }
.sync-card dd { margin: 0; font-weight: 700; }
.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state > div { width: 48px; height: 48px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 14px; background: #eef3fa; color: #7890b1; font-size: 24px; }
.empty-state h3 { margin: 0 0 6px; color: #526176; font-size: 15px; }
.empty-state p, .muted { color: var(--muted); }

/* Installer */
.install-body { min-height: 100vh; background: radial-gradient(circle at 15% 15%, #254f87 0, #18365f 28%, #102949 62%, #0c213d 100%); }
.install-shell { min-height: 100vh; width: min(1120px, calc(100% - 40px)); margin: 0 auto; display: grid; grid-template-columns: .85fr 1.15fr; gap: 80px; align-items: center; padding: 50px 0; }
.install-brand { color: white; }
.install-brand .eyebrow { color: #8db4ff; margin-top: 26px; }
.install-brand h1 { font-size: 46px; margin: 0; letter-spacing: -.05em; }
.install-lead { color: rgba(255,255,255,.7); font-size: 16px; line-height: 1.85; margin: 20px 0 28px; }
.install-points { display: grid; gap: 13px; }
.install-points span { color: rgba(255,255,255,.8); display: flex; align-items: center; gap: 10px; }
.install-points span::before { content: "✓"; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: rgba(87,208,164,.14); color: #62d4aa; font-weight: 800; }
.install-card { background: white; border-radius: 22px; padding: 34px; box-shadow: 0 28px 70px rgba(0,0,0,.24); }
.install-card h2 { font-size: 26px; margin: 4px 0 8px; letter-spacing: -.03em; }
.step-label { margin: 0; color: var(--blue); font-weight: 750; font-size: 12px; }
.install-form { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.install-form .field { display: grid; gap: 6px; }
.install-form .small-field { min-width: 100px; }
.install-form .full-field, .section-divider { grid-column: 1 / -1; }
.install-form label { color: #56647a; font-size: 12px; font-weight: 700; }
.install-form small { color: #95a0af; line-height: 1.5; }
.section-divider { position: relative; margin: 7px 0 0; color: #8995a6; font-size: 11px; font-weight: 750; letter-spacing: .08em; }
.section-divider::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line); }
.section-divider span { position: relative; z-index: 1; background: white; padding-right: 10px; }
.check-row { display: flex; gap: 8px; align-items: start; cursor: pointer; }
.check-row input { width: 16px; height: 16px; min-height: 0; margin-top: 1px; accent-color: var(--blue); }
.success-icon { width: 60px; height: 60px; border-radius: 18px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-size: 28px; font-weight: 800; margin-bottom: 22px; }

@media (max-width: 1250px) {
  .content-grid { grid-template-columns: 1fr; }
  .side-panel { grid-template-columns: repeat(3, 1fr); }
  .flow-row summary { grid-template-columns: 64px minmax(190px,1.5fr) minmax(125px,.9fr) 80px 18px 80px 82px 14px; gap: 9px; }
}
@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .flow-row summary { grid-template-columns: 58px minmax(180px,1fr) 125px 82px 18px; }
  .flow-row .person-cell:first-of-type, .flow-arrow, .duration-cell { display: none; }
  .side-panel { grid-template-columns: 1fr; }
  .install-shell { grid-template-columns: 1fr; gap: 34px; padding: 40px 0; }
  .install-brand { max-width: 620px; }
}
@media (max-width: 720px) {
  .topbar { height: 62px; padding: 0 16px; }
  .brand span { display: none; }
  .sync-status { display: none; }
  .sync-now-button { height: 36px; padding: 0 11px; }
  .page-shell { padding: 24px 12px 40px; }
  .hero-row { align-items: start; flex-direction: column; gap: 18px; }
  .hero-actions { width: 100%; }
  .ghost-button { flex: 1; text-align: center; padding: 8px 5px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric-card { min-height: 115px; padding: 16px; }
  .metric-card strong { font-size: 28px; }
  .metric-card strong.compact { font-size: 20px; }
  .filter-bar { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-field, .filter-field.date-filter, .filter-field.search-field { min-width: 0; }
  .search-field { grid-column: 1 / -1; }
  .filter-button, .clear-button { justify-content: center; text-align: center; }
  .table-heading { padding: 18px 16px 9px; }
  .legend { display: none; }
  .flow-list { padding: 0 7px 10px; }
  .flow-row summary { grid-template-columns: 50px minmax(0,1fr) 98px 12px; gap: 8px; padding: 10px 8px; }
  .flow-row .reason-cell { display: none; }
  .flow-row .person-cell.claim { justify-items: end; }
  .flow-details { grid-template-columns: 1fr 1fr; }
  .install-shell { width: min(100% - 24px, 620px); padding: 26px 0; }
  .install-brand h1 { font-size: 34px; }
  .install-card { padding: 23px 18px; border-radius: 17px; }
  .install-form { grid-template-columns: 1fr; }
  .install-form .full-field, .section-divider { grid-column: auto; }
}
@media (max-width: 430px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 108px; }
  .filter-bar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .flow-row summary { grid-template-columns: 46px minmax(0,1fr) 76px 10px; }
  .company-cell span { display: none; }
  .flow-details { grid-template-columns: 1fr; }
}

/* SaaS multi-page shell */
.app-body { background: #f4f6fb; min-height: 100vh; }
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 50; width: 248px;
  background: linear-gradient(180deg, #151620 0%, #11121a 100%); color: #dce3f0;
  display: flex; flex-direction: column; border-right: 1px solid rgba(255,255,255,.05);
  box-shadow: 14px 0 40px rgba(18,20,31,.08);
}
.sidebar-brand { height: 88px; padding: 0 22px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-logo { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 19px; font-weight: 850; background: linear-gradient(145deg,#367df9,#1e55d2); box-shadow: 0 12px 26px rgba(39,105,238,.3); }
.sidebar-brand > div:last-child { display: grid; gap: 4px; min-width: 0; }
.sidebar-brand strong { color: #fff; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand span { color: #7e8ba3; font-size: 9px; letter-spacing: .15em; font-weight: 700; }
.sidebar-nav { padding: 22px 14px; display: grid; gap: 8px; }
.sidebar-nav a { min-height: 52px; padding: 0 15px; border-radius: 11px; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px; color: #9eabc0; text-decoration: none; font-weight: 650; transition: .18s ease; }
.sidebar-nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-nav a.active { color: #fff; background: linear-gradient(115deg,#2f74f4,#235ddc); box-shadow: 0 14px 30px rgba(36,101,232,.26); }
.sidebar-nav i { width: 23px; height: 23px; display: grid; place-items: center; font-style: normal; font-size: 18px; }
.sidebar-nav b { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; background: #e14862; color: #fff; font-size: 10px; }
.sidebar-foot { margin: auto 16px 20px; padding: 15px 12px; border-top: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; gap: 10px; }
.sidebar-foot > div { display: grid; gap: 3px; }
.sidebar-foot strong { color: #c6d0de; font-size: 11px; }
.sidebar-foot small { color: #677389; font-size: 10px; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: #778195; box-shadow: 0 0 0 5px rgba(119,129,149,.08); }
.health-dot.online { background: #18c48e; box-shadow: 0 0 0 5px rgba(24,196,142,.09); }
.app-main { min-height: 100vh; margin-left: 248px; }
.app-header { height: 88px; padding: 0 34px; position: sticky; top: 0; z-index: 35; background: rgba(255,255,255,.94); backdrop-filter: blur(14px); border-bottom: 1px solid #e5e9f1; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.page-heading { display: grid; gap: 4px; }
.page-heading h1 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.page-heading p { margin: 0; color: #8490a3; font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.mobile-menu { display: none; border: 0; background: none; font-size: 23px; color: var(--navy); }
.app-content { padding: 28px 32px 60px; max-width: 1700px; margin: 0 auto; }
.mobile-backdrop { display: none; }

.dashboard-hero { min-height: 142px; margin-bottom: 20px; padding: 26px 28px; border-radius: 17px; display: flex; justify-content: space-between; align-items: center; gap: 24px; color: #fff; background: radial-gradient(circle at 78% 0,#3f83f8 0,transparent 32%), linear-gradient(120deg,#183d70,#245aa0); box-shadow: 0 16px 38px rgba(29,74,130,.17); overflow: hidden; }
.dashboard-hero h2 { margin: 0; font-size: 26px; letter-spacing: -.035em; }
.dashboard-hero p:last-child { color: rgba(255,255,255,.7); margin: 9px 0 0; }
.dashboard-hero .eyebrow { color: #9ec5ff; }
.dashboard-hero.compact-hero { min-height: 128px; }
.hero-links { display: flex; gap: 9px; flex-wrap: wrap; }
.hero-links a, .primary-action { min-height: 42px; padding: 0 16px; border: 1px solid rgba(255,255,255,.28); border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: rgba(255,255,255,.1); color: #fff; text-decoration: none; font-weight: 700; cursor: pointer; }
.hero-links a.primary { background: #fff; color: #20518d; border-color: #fff; }
.primary-action { background: #2870ef; border-color: #2870ef; box-shadow: 0 8px 18px rgba(40,112,239,.18); }
.primary-action.violet { background: #7356db; border-color: #7356db; }
.primary-action:disabled { opacity: .7; cursor: wait; }
.dashboard-metrics, .expiry-metrics { grid-template-columns: repeat(4,minmax(0,1fr)); }
.dashboard-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }

/* Unified system settings */
.settings-login-card { max-width: 520px; margin: 72px auto; }
.settings-login-card .sales-logo { margin-bottom: 22px; }
.settings-login-card input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid #dbe2ec; border-radius: 10px; }
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.settings-card { min-height: 100%; }
.settings-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.settings-fields label { display: grid; gap: 7px; color: #66758a; font-size: 12px; font-weight: 700; }
.settings-fields input { width: 100%; min-height: 42px; padding: 0 12px; color: var(--ink); border: 1px solid #dfe5ee; border-radius: 9px; background: #fff; }
.settings-help { grid-column: 1 / -1; margin: 0; padding: 12px 14px; color: #64748b; font-size: 12px; line-height: 1.7; border-radius: 10px; background: #f6f8fc; }
.settings-label-picker { grid-column: 1 / -1; margin: 0; padding: 14px; border: 1px solid #dfe5ee; border-radius: 10px; background: #fbfcfe; }
.settings-label-picker legend { padding: 0 6px; color: #42516a; font-size: 12px; font-weight: 800; }
.settings-label-picker > p { margin: 0 0 12px; color: #7b8799; font-size: 11px; line-height: 1.6; }
.settings-label-options { display: flex; flex-wrap: wrap; gap: 9px; }
.settings-label-options label { display: inline-flex; align-items: center; cursor: pointer; }
.settings-label-options input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; pointer-events: none; }
.settings-label-options span { display: inline-flex; align-items: center; min-height: 32px; padding: 0 11px; border: 1px solid #dce3ed; border-radius: 999px; background: #fff; color: #65738a; font-size: 12px; font-weight: 700; transition: .15s ease; }
.settings-label-options input:checked + span { border-color: var(--label-color,#3478ef); background: var(--label-color,#3478ef); color: var(--label-text,#fff); box-shadow: 0 4px 12px rgba(39,106,228,.16); }
.settings-label-options input:focus-visible + span { outline: 3px solid rgba(52,120,239,.2); outline-offset: 2px; }
.settings-label-empty { width: 100%; padding: 13px; border-radius: 8px; background: #f3f5f8; color: #8a95a6; font-size: 12px; text-align: center; }
.settings-save { margin: 18px 0 0 auto; min-width: 180px; display: flex; }
.settings-quota-panel { margin-top: 18px; }
.quota-add-form { margin-bottom: 18px; padding: 14px; display: grid; grid-template-columns: 130px minmax(160px,1fr) 130px 140px 130px; gap: 10px; align-items: center; border-radius: 11px; background: #f7f9fc; }
.quota-add-form input:not([type="checkbox"]) { width: 100%; min-height: 40px; padding: 0 10px; border: 1px solid #dfe5ee; border-radius: 8px; background: #fff; }
.quota-add-form label { color: #5e6c80; }

@media (max-width: 980px) {
  .settings-grid { grid-template-columns: 1fr; }
  .quota-add-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 560px) {
  .settings-fields, .quota-add-form { grid-template-columns: 1fr; }
  .settings-login-card { margin: 30px auto; }
}
.dashboard-grid .span-2 { grid-column: span 2; }
.panel-card { background: #fff; border: 1px solid #e3e8f0; border-radius: 15px; box-shadow: 0 10px 28px rgba(28,45,77,.05); padding: 20px; min-width: 0; }
.panel-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-title h3 { margin: 0; font-size: 17px; }
.panel-title a { color: #3473e7; text-decoration: none; font-size: 12px; font-weight: 700; }
.panel-badges { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.source-badge { min-height: 27px; padding: 5px 9px; border-radius: 7px; display: inline-flex; align-items: center; gap: 6px; background: #eaf8f3; color: #198362; font-size: 10px; font-weight: 750; white-space: nowrap; }
.source-badge i { width: 6px; height: 6px; border-radius: 50%; background: #1ab889; }
.source-badge.local { background: #f1f4f8; color: #748197; }
.source-badge.local i { background: #9aa5b4; }
.count-badge { background: #f1f4f8; color: #748197; border-radius: 7px; padding: 6px 9px; font-size: 11px; font-weight: 700; }
.expiry-radar { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.expiry-radar > div { min-height: 84px; padding: 15px; border-radius: 11px; background: #f5f7fb; display: grid; align-content: center; gap: 5px; }
.expiry-radar strong { font-size: 25px; }
.expiry-radar span { color: #8490a2; font-size: 11px; }
.expiry-radar .danger { background: #fff0f3; color: var(--rose); }
.expiry-radar .warning { background: #fff7e7; color: #bf7712; }
.data-stats { margin: 0; display: grid; gap: 12px; }
.data-stats div { padding: 12px 0; border-bottom: 1px solid #edf0f5; display: flex; justify-content: space-between; }
.data-stats div:last-child { border-bottom: 0; }
.data-stats dt { color: #7e8a9d; }
.data-stats dd { margin: 0; font-size: 17px; font-weight: 800; }
.mini-empty { padding: 45px 0; text-align: center; color: #99a4b4; }

.page-toolbar { margin-bottom: 16px; padding: 16px; background: #fff; border: 1px solid #e3e8f0; border-radius: 14px; box-shadow: 0 8px 25px rgba(28,45,77,.04); }
.saas-filter-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.saas-filter-form .filter-field { min-width: 145px; }
.saas-filter-form .search-field { min-width: 210px; flex: 1; }
.short-form .search-field { max-width: 420px; }
.inline-metrics { margin-bottom: 16px; padding: 15px 20px; display: flex; gap: 0; background: #fff; border: 1px solid #e3e8f0; border-radius: 14px; }
.inline-metrics div { min-width: 150px; padding: 2px 28px; border-right: 1px solid #e8ecf2; display: grid; gap: 4px; }
.inline-metrics div:first-child { padding-left: 0; }
.inline-metrics div:last-child { border: 0; }
.inline-metrics span { color: #8792a4; font-size: 11px; }
.inline-metrics strong { font-size: 19px; }
.table-panel { padding: 0; overflow: visible; }
.table-panel > .panel-title { padding: 20px 22px 0; }
.saas-table-wrap { overflow-x: auto; }
.saas-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 920px; }
.saas-table th { padding: 13px 16px; background: #f7f8fc; border-top: 1px solid #e7ebf2; border-bottom: 1px solid #e7ebf2; color: #758297; font-size: 11px; text-align: left; white-space: nowrap; }
.saas-table td { padding: 15px 16px; border-bottom: 1px solid #edf0f4; color: #445166; font-size: 12px; vertical-align: middle; }
.saas-table tbody tr:hover td { background: #fafcff; }
.saas-table td > strong { display: block; color: #1c293d; font-size: 12px; }
.saas-table td > small { display: block; color: #929dad; margin-top: 4px; }
.customer-link { display: inline-flex; align-items: center; gap: 5px; color: #1c293d; text-decoration: none; font-weight: 750; transition: color .16s ease; }
.customer-link strong { color: inherit; font-size: 12px; }
.customer-link span { color: #8ea4c7; font-size: 11px; transition: transform .16s ease, color .16s ease; }
.customer-link:hover { color: #2f70e8; }
.customer-link:hover span { color: #2f70e8; transform: translate(1px,-1px); }
.compact-table { min-width: 700px; }
.compact-table th,.compact-table td { padding: 12px 13px; }
.table-empty { text-align: center!important; padding: 70px 20px!important; color: #96a1b2!important; }
.status-pill,.expiry-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 8px; border-radius: 7px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.status-pill.success { background: #e8f8f2; color: #10815f; }
.status-pill.waiting,.status-pill.info,.expiry-pill.info { background: #edf3ff; color: #3769c9; }
.status-pill.warning,.expiry-pill.warning { background: #fff4df; color: #a9670b; }
.status-pill.danger,.expiry-pill.danger { background: #ffedf1; color: #c43a55; }
.expiry-pill.gray { background: #eef1f5; color: #778397; }
.row-detail { position: relative; }
.row-detail summary { color: #2f70e8; cursor: pointer; font-weight: 700; list-style: none; }
.row-detail summary::-webkit-details-marker { display: none; }
.row-detail > div { position: absolute; right: 0; top: 28px; z-index: 20; width: 270px; padding: 14px; border: 1px solid #dfe5ee; border-radius: 10px; background: #fff; box-shadow: 0 18px 45px rgba(20,36,62,.16); }
.row-detail p { margin: 0 0 9px; display: flex; justify-content: space-between; gap: 12px; }
.row-detail p span { color: #8995a6; }
.row-detail em,.flag-stack em { display: inline-flex; margin: 3px 3px 0 0; padding: 4px 7px; border-radius: 5px; background: #fff0f3; color: #b9324c; font-style: normal; font-size: 10px; }
.flag-stack { display: flex; flex-wrap: wrap; max-width: 260px; }
.pagination { padding: 16px 20px; display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.pagination a { padding: 7px 11px; border: 1px solid #dfe5ee; border-radius: 7px; color: #4d5c72; text-decoration: none; }
.pagination a.disabled { opacity: .4; pointer-events: none; }
.pagination span { color: #8490a3; font-size: 11px; }

.sync-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.sync-monitor-hero { min-height: 132px; margin-bottom: 16px; padding: 24px 26px; display: grid; grid-template-columns: 58px minmax(0,1fr) auto; align-items: center; gap: 18px; color: #fff; border-radius: 16px; background: linear-gradient(120deg,#174f45,#1a8068); box-shadow: 0 15px 34px rgba(18,111,88,.16); }
.sync-monitor-hero.warning { background: linear-gradient(120deg,#86530e,#c48725); box-shadow: 0 15px 34px rgba(166,104,20,.16); }
.sync-monitor-hero.danger { background: linear-gradient(120deg,#7f2639,#c4435d); box-shadow: 0 15px 34px rgba(164,45,69,.17); }
.sync-monitor-hero.running { background: linear-gradient(120deg,#214f8d,#3379e4); box-shadow: 0 15px 34px rgba(37,93,175,.18); }
.monitor-health-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px; background: rgba(255,255,255,.15); font-size: 25px; font-weight: 850; }
.monitor-health-copy h2 { margin: 0; font-size: 26px; letter-spacing: -.03em; }
.monitor-health-copy p:last-child { margin: 7px 0 0; color: rgba(255,255,255,.76); }
.monitor-health-copy .eyebrow { color: rgba(255,255,255,.65); }
.monitor-live { min-width: 130px; display: grid; justify-items: end; gap: 3px; }
.monitor-live span { margin-bottom: 5px; display: inline-flex; align-items: center; gap: 7px; color: rgba(255,255,255,.76); font-size: 11px; }
.monitor-live span i { width: 7px; height: 7px; border-radius: 50%; background: #8dffd6; box-shadow: 0 0 0 5px rgba(141,255,214,.1); }
.monitor-live strong { font-size: 22px; }
.monitor-live small { color: rgba(255,255,255,.55); }
.monitor-metric-grid { margin-bottom: 18px; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.monitor-metric { min-height: 112px; padding: 18px 20px; display: grid; align-content: space-between; gap: 7px; border: 1px solid #e3e8f0; border-radius: 14px; background: #fff; box-shadow: 0 8px 24px rgba(28,45,77,.04); }
.monitor-metric span { color: #7e8a9d; font-size: 11px; font-weight: 700; }
.monitor-metric strong { color: #1c2b41; font-size: 23px; letter-spacing: -.025em; }
.monitor-metric strong.busy { color: #2e6fe5; }
.monitor-metric small { color: #9aa4b2; }
.monitor-metric.has-error { border-color: #f2cdd5; background: #fffafb; }
.monitor-metric.has-error strong { color: var(--rose); }
.monitor-content-grid { margin-bottom: 18px; display: grid; grid-template-columns: minmax(0,1.65fr) minmax(300px,.85fr); gap: 18px; }
.monitor-pipeline-list { display: grid; }
.monitor-pipeline-row { min-height: 62px; padding: 10px 2px; display: grid; grid-template-columns: 10px minmax(170px,1fr) 105px 76px 60px; align-items: center; gap: 12px; border-top: 1px solid #edf0f4; }
.monitor-pipeline-row:first-child { border-top: 0; }
.monitor-pipeline-row > i { width: 8px; height: 8px; border-radius: 50%; background: #c0c8d3; }
.monitor-pipeline-row > i.success { background: var(--green); box-shadow: 0 0 0 5px rgba(21,155,114,.08); }
.monitor-pipeline-row > i.info { background: var(--blue); box-shadow: 0 0 0 5px rgba(47,109,246,.08); }
.monitor-pipeline-row > i.warning { background: #d99a32; }
.monitor-pipeline-row > i.danger { background: var(--rose); box-shadow: 0 0 0 5px rgba(217,75,103,.08); }
.monitor-pipeline-row > div { display: grid; gap: 4px; }
.monitor-pipeline-row > div strong { color: #25344a; font-size: 12px; }
.monitor-pipeline-row > div small,.monitor-pipeline-row > span { color: #8b96a6; font-size: 11px; }
.monitor-pipeline-row > b { justify-self: end; }
.monitor-ok-empty { min-height: 255px; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center; }
.monitor-ok-empty i { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 20px; font-style: normal; font-weight: 800; }
.monitor-ok-empty strong { color: #334257; }
.monitor-ok-empty span { color: #98a2b0; font-size: 11px; }
.monitor-error-list { display: grid; max-height: 275px; overflow: auto; }
.monitor-error-list > div { padding: 12px 0; display: grid; gap: 4px; border-top: 1px solid #edf0f4; }
.monitor-error-list > div:first-child { border-top: 0; }
.monitor-error-list strong { color: #b83650; font-size: 11px; }
.monitor-error-list span { color: #536177; font-size: 12px; line-height: 1.5; word-break: break-word; }
.monitor-error-list small { color: #9aa4b2; }
.monitor-refresh-card { margin-bottom: 18px; padding: 0; overflow: hidden; }
.monitor-refresh-card > .panel-title { padding: 20px 22px 0; }
.sync-operation-card { display: grid; grid-template-columns: 56px 1fr; gap: 18px; align-items: start; }
.operation-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: #eaf1ff; color: #2e6de0; font-size: 22px; font-weight: 800; }
.operation-icon.violet { background: #f0ebff; color: #7356d7; }
.sync-operation-card h3 { margin: 0 0 6px; font-size: 19px; }
.sync-operation-card p:not(.eyebrow) { margin: 0; color: #7e8a9d; line-height: 1.6; }
.sync-operation-card dl { grid-column: 1/-1; margin: 4px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid #e8ecf2; border-radius: 10px; }
.sync-operation-card dl div { padding: 12px 14px; display: flex; justify-content: space-between; border-bottom: 1px solid #edf0f4; }
.sync-operation-card dl div:nth-child(odd) { border-right: 1px solid #edf0f4; }
.sync-operation-card dl div:nth-last-child(-n+2) { border-bottom: 0; }
.sync-operation-card dt { color: #8490a2; }
.sync-operation-card dd { margin: 0; font-weight: 750; }
.sync-operation-card .primary-action { grid-column: 1/-1; justify-self: start; }
.cron-panel > p { color: #748196; }
.command-box { min-height: 52px; padding: 8px 9px 8px 15px; border-radius: 10px; background: #141722; color: #dfe7f5; display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.command-box code { overflow: auto; white-space: nowrap; }
.command-box button { border: 0; border-radius: 7px; padding: 7px 12px; background: #2e70ef; color: #fff; cursor: pointer; }
.rule-note { margin-top: 14px; padding: 12px; border-radius: 9px; background: #f3f6fb; display: flex; gap: 12px; color: #758196; }
.rule-note strong { color: #334157; }

@media (max-width: 1180px) {
  .app-sidebar { width: 218px; }
  .app-main { margin-left: 218px; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid .span-2 { grid-column: 1/-1; }
  .sync-grid { grid-template-columns: 1fr; }
  .monitor-content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 850px) {
  .app-sidebar { transform: translateX(-102%); width: 250px; transition: transform .22s ease; }
  .sidebar-open .app-sidebar { transform: translateX(0); }
  .mobile-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(10,17,30,.48); }
  .sidebar-open .mobile-backdrop { display: block; }
  .app-main { margin-left: 0; }
  .app-header { height: 76px; padding: 0 16px; }
  .mobile-menu { display: block; }
  .page-heading { margin-right: auto; }
  .page-heading p { display: none; }
  .app-content { padding: 20px 14px 45px; }
  .dashboard-metrics,.expiry-metrics { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .span-2 { grid-column: auto; }
  .inline-metrics { overflow-x: auto; }
  .monitor-metric-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 590px) {
  .header-actions .sync-status { display: none; }
  .page-heading h1 { font-size: 18px; }
  .dashboard-hero { align-items: flex-start; flex-direction: column; padding: 22px 20px; }
  .dashboard-hero h2 { font-size: 22px; }
  .dashboard-metrics,.expiry-metrics { grid-template-columns: 1fr 1fr; }
  .saas-filter-form { display: grid; grid-template-columns: 1fr 1fr; }
  .saas-filter-form .filter-field,.saas-filter-form .search-field { min-width: 0; max-width: none; }
  .saas-filter-form .search-field { grid-column: 1/-1; }
  .sync-operation-card { grid-template-columns: 45px 1fr; }
  .sync-monitor-hero { padding: 20px; grid-template-columns: 48px 1fr; }
  .monitor-health-icon { width: 46px; height: 46px; border-radius: 13px; }
  .monitor-live { grid-column: 1/-1; min-width: 0; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.14); display: flex; align-items: center; justify-content: space-between; }
  .monitor-live span { margin: 0; }
  .monitor-live small { display: none; }
  .monitor-metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .monitor-metric { min-height: 100px; padding: 15px; }
  .monitor-metric strong { font-size: 19px; }
  .monitor-pipeline-row { grid-template-columns: 9px minmax(0,1fr) 58px; }
  .monitor-pipeline-row > span { display: none; }
  .sync-operation-card dl { grid-template-columns: 1fr; }
  .sync-operation-card dl div,.sync-operation-card dl div:nth-child(odd) { border-right: 0; border-bottom: 1px solid #edf0f4; }
  .sync-operation-card dl div:last-child { border-bottom: 0; }
}
