:root {
  color-scheme: light;
  --ink: #17231e;
  --muted: #65716b;
  --faint: #8d9792;
  --canvas: #f4f6f3;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --line: #dfe5e1;
  --line-strong: #cbd4cf;
  --brand: #176b4b;
  --brand-deep: #114d38;
  --brand-soft: #e4f3eb;
  --blue: #3169c6;
  --blue-soft: #eaf1fc;
  --purple: #7358b5;
  --purple-soft: #f0ecfa;
  --orange: #b7641d;
  --orange-soft: #fbefe3;
  --red: #b33e3e;
  --red-soft: #fae9e8;
  --shadow-sm: 0 1px 2px rgba(18, 38, 29, 0.05), 0 7px 22px rgba(18, 38, 29, 0.035);
  --shadow-lg: 0 24px 70px rgba(18, 38, 29, 0.18);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --topbar-height: 72px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 4%, rgba(221, 239, 229, 0.78), transparent 28rem),
    var(--canvas);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body.drawer-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

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

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 9px 13px;
  color: #fff;
  background: var(--brand-deep);
  border-radius: 8px;
  transform: translateY(-150%);
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid rgba(49, 105, 198, 0.4);
  outline-offset: 2px;
}

.surface {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(203, 212, 207, 0.86);
  box-shadow: var(--shadow-sm);
}

.eyebrow,
.rail-label {
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-weight: 680;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.button--primary {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 7px 18px rgba(23, 107, 75, 0.18);
}

.button--primary:hover:not(:disabled) {
  background: var(--brand-deep);
}

.button--quiet {
  color: #33423b;
  background: var(--surface);
  border-color: var(--line);
}

.button--quiet:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.button--wide {
  width: 100%;
  margin-top: 8px;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  padding: 9px;
  place-items: center;
  color: #435048;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease, transform 140ms ease;
}

.icon-button:hover {
  color: var(--brand);
  background: #fff;
  transform: translateY(-1px);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

/* Sign in */

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(380px, 520px);
  gap: clamp(36px, 8vw, 130px);
  align-items: center;
  padding: clamp(28px, 7vw, 100px);
  background:
    linear-gradient(118deg, rgba(18, 65, 48, 0.97), rgba(23, 107, 75, 0.88) 48%, rgba(230, 241, 234, 0.96) 48.1%),
    var(--canvas);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  color: #fff;
  font-size: clamp(1.7rem, 3.2vw, 3.4rem);
  font-weight: 780;
  letter-spacing: -0.04em;
}

.brand-mark {
  display: inline-grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  background: var(--brand);
  border-radius: 12px;
  font-size: 0.69rem;
  font-weight: 850;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.brand-mark--large {
  width: 66px;
  height: 66px;
  color: var(--brand-deep);
  background: #fff;
  border-radius: 20px;
  font-size: 1rem;
}

.login-card {
  padding: clamp(28px, 5vw, 46px);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin: 8px 0 6px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.login-copy {
  margin: 0 0 28px;
  color: var(--muted);
}

.field-label {
  display: block;
  margin: 17px 0 6px;
  font-size: 0.82rem;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}

.login-card input:focus {
  background: #fff;
  border-color: var(--brand);
}

.form-message {
  min-height: 1.4em;
  margin: 11px 0 0;
  color: var(--red);
  font-size: 0.84rem;
}

/* Application frame */

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 40;
  top: 0;
  display: grid;
  min-height: var(--topbar-height);
  grid-template-columns: 210px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 11px 18px;
  background: rgba(250, 252, 249, 0.9);
  border-bottom: 1px solid rgba(203, 212, 207, 0.8);
  backdrop-filter: blur(18px) saturate(150%);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-name {
  overflow: hidden;
  font-weight: 780;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-tabs {
  display: flex;
  gap: 7px;
  min-width: 0;
  overflow-x: auto;
  padding: 1px;
  scrollbar-width: none;
}

.site-tabs::-webkit-scrollbar {
  display: none;
}

.site-tab {
  display: flex;
  min-width: 156px;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  color: #46544d;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.site-tab:hover {
  background: #fff;
  border-color: var(--line);
}

.site-tab.is-active {
  color: #fff;
  background: var(--brand-deep);
  border-color: var(--brand-deep);
  box-shadow: 0 7px 20px rgba(17, 77, 56, 0.18);
}

.site-tab-badge {
  display: grid;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--brand-deep);
  background: var(--brand-soft);
  border-radius: 9px;
  font-size: 0.63rem;
  font-weight: 850;
}

.site-tab.is-active .site-tab-badge {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.site-tab-copy {
  display: grid;
  min-width: 0;
}

.site-tab-name {
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-tab-state {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.68rem;
}

.site-tab.is-active .site-tab-state {
  color: rgba(255, 255, 255, 0.74);
}

.mini-dot,
.status-dot,
.source-pulse {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: #2e9a63;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(46, 154, 99, 0.11);
}

.mini-dot.is-warn,
.status-dot.is-warn,
.source-pulse.is-warn {
  background: #d58731;
  box-shadow: 0 0 0 3px rgba(213, 135, 49, 0.11);
}

.mini-dot.is-error,
.status-dot.is-error,
.source-pulse.is-error {
  background: #c84c4c;
  box-shadow: 0 0 0 3px rgba(200, 76, 76, 0.11);
}

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

.workspace {
  display: grid;
  min-height: calc(100vh - var(--topbar-height));
  grid-template-columns: 218px minmax(0, 1fr);
}

.jump-rail {
  position: sticky;
  top: var(--topbar-height);
  display: flex;
  height: calc(100vh - var(--topbar-height));
  flex-direction: column;
  padding: 18px 11px 14px;
  overflow-y: auto;
  background: rgba(248, 250, 247, 0.88);
  border-right: 1px solid var(--line);
}

.rail-group + .rail-group {
  margin-top: 17px;
}

.rail-label {
  margin: 0 11px 7px;
  color: var(--faint);
  font-size: 0.65rem;
}

.rail-link {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: #425049;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.86rem;
  text-align: left;
}

.rail-link:hover {
  color: var(--brand-deep);
  background: #edf3ef;
}

.rail-link.is-active {
  color: var(--brand-deep);
  background: var(--brand-soft);
  font-weight: 720;
}

.rail-icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  color: var(--faint);
  font-size: 0.92rem;
}

.rail-link.is-active .rail-icon {
  color: var(--brand);
}

.rail-footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 8px;
  align-items: center;
  margin-top: auto;
  padding: 14px 10px 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.version-label {
  grid-column: 2;
  color: var(--faint);
}

.main-content {
  min-width: 0;
  padding: 24px clamp(18px, 3vw, 38px) 64px;
}

.page-view {
  width: min(100%, 1500px);
  margin: 0 auto;
}

.offline-banner {
  max-width: 1500px;
  margin: 0 auto 14px;
  padding: 9px 13px;
  color: #7f4b16;
  background: #fff6e9;
  border: 1px solid #efd8b8;
  border-radius: 10px;
  font-size: 0.84rem;
}

.page-header,
.subscription-hero {
  display: flex;
  gap: 22px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 22px;
  border-radius: var(--radius-lg);
}

.page-heading h1,
.subscription-hero h1 {
  margin: 4px 0 4px;
  font-size: clamp(1.75rem, 3vw, 2.45rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.subscription-hero p {
  max-width: 700px;
  margin: 5px 0 0;
  color: var(--muted);
}

.freshness {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.83rem;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.range-control {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding: 3px;
  background: #edf1ee;
  border: 1px solid #e0e6e2;
  border-radius: 11px;
}

.range-control.has-custom {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.custom-range-fields {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding-left: 4px;
}

.custom-range-fields input {
  width: 124px;
  min-height: 30px;
  padding: 4px 7px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 0.71rem;
}

.custom-range-separator {
  color: var(--faint);
  font-size: 0.68rem;
}

.range-apply {
  min-height: 30px;
  padding: 4px 9px;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 720;
}

.range-button {
  min-height: 32px;
  padding: 6px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 690;
  white-space: nowrap;
}

.range-button:hover {
  color: var(--ink);
}

.range-button.is-active {
  color: var(--brand-deep);
  background: #fff;
  box-shadow: 0 1px 5px rgba(18, 38, 29, 0.11);
}

.layout-menu {
  position: relative;
}

.layout-menu summary {
  list-style: none;
}

.layout-menu summary::-webkit-details-marker {
  display: none;
}

.layout-menu-panel {
  position: absolute;
  z-index: 25;
  top: calc(100% + 8px);
  right: 0;
  width: min(310px, calc(100vw - 30px));
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.layout-menu-title {
  padding: 5px 7px 8px;
  color: var(--muted);
  font-size: 0.75rem;
}

.layout-toggle {
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 38px;
  padding: 7px;
  border-radius: 8px;
  cursor: pointer;
}

.layout-toggle:hover {
  background: var(--surface-soft);
}

.layout-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

/* Dashboard sections */

.dashboard-sections {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.dashboard-section {
  position: relative;
  padding: 20px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: calc(var(--topbar-height) + 18px);
  transition: border-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.dashboard-section.is-dragging {
  opacity: 0.45;
}

.dashboard-section.is-drop-target {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 75, 0.12), var(--shadow-sm);
}

.dashboard-section.is-collapsed .section-header {
  margin-bottom: 0;
}

.section-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 17px;
}

.section-heading {
  min-width: 0;
}

.section-heading-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.14rem;
  letter-spacing: -0.025em;
}

.section-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.drag-handle {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--faint);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: grab;
  font-size: 1rem;
  letter-spacing: -0.15em;
}

.drag-handle:active {
  cursor: grabbing;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.chart-style-select {
  min-height: 32px;
  padding: 5px 28px 5px 9px;
  color: #47544e;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 650;
}

.section-hide {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--faint);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.section-hide:hover {
  color: var(--ink);
  background: var(--surface-soft);
  border-color: var(--line);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 10px;
}

.metric-grid--spaced {
  margin-top: 10px;
}

.metric-card {
  position: relative;
  min-width: 0;
  min-height: 115px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid #e7ece8;
  border-radius: 14px;
  text-align: left;
}

button.metric-card {
  width: 100%;
  color: inherit;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

button.metric-card:hover {
  background: #fff;
  border-color: #b8cbc1;
  transform: translateY(-2px);
}

.metric-kicker {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 680;
}

.metric-value {
  display: block;
  margin-top: 7px;
  color: var(--ink);
  font-size: clamp(1.35rem, 2.1vw, 1.7rem);
  font-variant-numeric: tabular-nums;
  font-weight: 780;
  letter-spacing: -0.055em;
  line-height: 1.08;
  white-space: nowrap;
}

.metric-detail {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.35;
}

.metric-card[data-tone="positive"] .metric-value,
.metric-detail.is-positive {
  color: var(--brand);
}

.metric-card[data-tone="warning"] .metric-value,
.metric-detail.is-warning {
  color: var(--orange);
}

.metric-card[data-tone="danger"] .metric-value,
.metric-detail.is-danger {
  color: var(--red);
}

.metric-card-arrow {
  position: absolute;
  top: 12px;
  right: 12px;
  color: var(--faint);
}

.chart-wrap {
  min-width: 0;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #edf0ee;
}

.chart-title-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.chart-title {
  font-size: 0.82rem;
  font-weight: 720;
}

.chart-note {
  color: var(--faint);
  font-size: 0.69rem;
}

.chart {
  width: 100%;
  min-height: 210px;
  overflow: visible;
}

.chart .grid-line {
  stroke: #e8ece9;
  stroke-width: 1;
}

.chart .axis-label {
  fill: #89928d;
  font-size: 10px;
}

.chart .line-primary {
  fill: none;
  stroke: var(--brand);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart .line-secondary {
  fill: none;
  stroke: var(--blue);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  opacity: 0.8;
}

.chart .area-primary {
  fill: url(#areaGradient);
}

.chart .point-primary {
  fill: #fff;
  stroke: var(--brand);
  stroke-width: 2;
}

.chart .bar-primary {
  fill: var(--brand);
}

.chart .bar-secondary {
  fill: var(--blue);
}

.chart-legend,
.breakdown-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
}

.legend-item,
.breakdown-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
}

.legend-dot {
  width: 8px;
  height: 8px;
  background: var(--brand);
  border-radius: 50%;
}

.legend-item:nth-child(2) .legend-dot,
.breakdown-item:nth-child(2) .legend-dot {
  background: var(--blue);
}

.legend-item:nth-child(3) .legend-dot,
.breakdown-item:nth-child(3) .legend-dot {
  background: var(--purple);
}

.legend-item:nth-child(4) .legend-dot,
.breakdown-item:nth-child(4) .legend-dot {
  background: var(--orange);
}

.legend-dot--0 { background: #176b4b !important; }
.legend-dot--1 { background: #3169c6 !important; }
.legend-dot--2 { background: #7358b5 !important; }
.legend-dot--3 { background: #b7641d !important; }
.legend-dot--4 { background: #5d8f7a !important; }
.legend-dot--5 { background: #89938d !important; }

.breakdown-list--vertical {
  flex-direction: column;
}

.donut-layout {
  display: grid;
  grid-template-columns: minmax(170px, 260px) minmax(180px, 1fr);
  gap: 26px;
  align-items: center;
}

.donut-layout .chart {
  min-height: 190px;
}

.activity-preview-list,
.activity-list {
  display: grid;
  gap: 9px;
}

.activity-row {
  display: grid;
  width: 100%;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 13px;
  color: inherit;
  background: var(--surface-soft);
  border: 1px solid #e7ece8;
  border-radius: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.activity-row:hover {
  background: #fff;
  border-color: #bdcec5;
  transform: translateY(-1px);
}

.activity-symbol {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 11px;
  font-weight: 800;
}

.activity-symbol[data-tone="warning"] {
  color: var(--orange);
  background: var(--orange-soft);
}

.activity-symbol[data-tone="danger"] {
  color: var(--red);
  background: var(--red-soft);
}

.activity-symbol[data-tone="info"] {
  color: var(--blue);
  background: var(--blue-soft);
}

.activity-copy {
  min-width: 0;
}

.activity-title-line {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  align-items: center;
}

.activity-kind {
  color: var(--brand);
  font-size: 0.74rem;
  font-weight: 760;
}

.activity-title {
  overflow: hidden;
  font-weight: 710;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-meta,
.activity-detail {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-time {
  color: var(--faint);
  font-size: 0.7rem;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 720;
}

.status-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.status-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 13px;
  background: var(--surface-soft);
  border: 1px solid #e7ece8;
  border-radius: 12px;
}

.status-card strong {
  display: block;
  font-size: 0.84rem;
}

.status-card span:last-child {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.7rem;
}

.empty-chart {
  display: grid;
  min-height: 150px;
  place-items: center;
  color: var(--faint);
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  font-size: 0.8rem;
}

/* Subscription workspace */

.subscription-hero {
  align-items: center;
}

.subscription-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.subscription-summary {
  min-height: 108px;
  padding: 14px;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.subscription-summary:hover,
.subscription-summary.is-active {
  border-color: rgba(23, 107, 75, 0.52);
  box-shadow: 0 8px 24px rgba(18, 38, 29, 0.07);
  transform: translateY(-2px);
}

.summary-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 680;
}

.summary-icon {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 8px;
}

.summary-value {
  display: block;
  margin-top: 9px;
  font-size: 1.7rem;
  font-weight: 790;
  letter-spacing: -0.04em;
}

.activity-toolbar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 15px 17px;
  border-radius: 15px;
}

.activity-toolbar h2 {
  margin: 0;
  font-size: 1rem;
}

.activity-toolbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.filter-chips {
  display: flex;
  max-width: 760px;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}

.filter-chip {
  min-height: 30px;
  padding: 5px 9px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 670;
}

.filter-chip:hover {
  color: var(--ink);
  background: #fff;
}

.filter-chip.is-active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.empty-state {
  display: grid;
  justify-items: start;
  margin-top: 16px;
  padding: 26px;
  border-radius: var(--radius);
}

.empty-state-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 13px;
  font-weight: 820;
}

.empty-state h2 {
  margin: 12px 0 3px;
  font-size: 1rem;
}

.empty-state p {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Loading */

.dashboard-loading {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.skeleton {
  min-height: 150px;
  background: linear-gradient(100deg, #e8ece9 20%, #f5f7f5 38%, #e8ece9 56%);
  background-size: 220% 100%;
  border-radius: var(--radius-lg);
  animation: shimmer 1.35s linear infinite;
}

.skeleton--hero {
  min-height: 220px;
}

@keyframes shimmer {
  to { background-position-x: -220%; }
}

/* Detail drawer */

.drawer-scrim {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgba(11, 24, 18, 0.28);
  backdrop-filter: blur(2px);
}

.detail-drawer {
  position: fixed;
  z-index: 90;
  top: 0;
  right: 0;
  display: flex;
  width: min(440px, 100vw);
  height: 100vh;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 55px rgba(18, 38, 29, 0.14);
  transform: translateX(102%);
  transition: transform 220ms cubic-bezier(0.22, 0.8, 0.22, 1);
}

.detail-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  margin: 4px 0 0;
  font-size: 1.45rem;
  letter-spacing: -0.035em;
}

.drawer-content {
  flex: 1;
  padding: 21px;
  overflow-y: auto;
}

.drawer-lead {
  margin: 0 0 18px;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.detail-field {
  min-width: 0;
  padding: 11px;
  background: var(--surface-soft);
  border: 1px solid #e7ece8;
  border-radius: 11px;
}

.detail-field.is-wide {
  grid-column: 1 / -1;
}

.detail-label {
  display: block;
  color: var(--faint);
  font-size: 0.65rem;
  font-weight: 720;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-value {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 0.85rem;
  font-weight: 620;
}

.drawer-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 15px 21px max(15px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.drawer-footer a {
  display: inline-flex;
  align-items: center;
  color: #fff;
  text-decoration: none;
}

/* Settings */

.settings-dialog {
  width: min(820px, calc(100vw - 28px));
  max-height: min(780px, calc(100vh - 28px));
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}

.settings-dialog::backdrop {
  background: rgba(11, 24, 18, 0.34);
  backdrop-filter: blur(3px);
}

.dialog-shell {
  display: flex;
  max-height: min(780px, calc(100vh - 28px));
  flex-direction: column;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px 14px;
}

.dialog-header h2 {
  margin: 3px 0 0;
  font-size: 1.65rem;
  letter-spacing: -0.04em;
}

.settings-tabs {
  display: flex;
  gap: 5px;
  padding: 0 24px 13px;
  border-bottom: 1px solid var(--line);
}

.settings-tab {
  min-height: 35px;
  padding: 7px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 680;
}

.settings-tab.is-active {
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.settings-panel {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
}

.settings-intro {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.settings-intro h3 {
  margin: 0;
  font-size: 1rem;
}

.settings-intro p {
  max-width: 570px;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.77rem;
}

.notification-global-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 9px;
  margin-bottom: 22px;
}

.global-setting-card {
  display: flex;
  min-height: 74px;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.global-setting-card strong {
  display: block;
  font-size: 0.79rem;
}

.global-setting-card span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.67rem;
}

.global-setting-card select {
  min-height: 36px;
  padding: 6px 26px 6px 8px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.switch-control {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  width: 42px;
  height: 24px;
  padding: 3px;
  background: #c9d1cd;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease;
}

.switch-track::after {
  display: block;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(18, 38, 29, 0.2);
  content: "";
  transition: transform 140ms ease;
}

.switch-control input:checked + .switch-track {
  background: var(--brand);
}

.switch-control input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch-control input:focus-visible + .switch-track {
  outline: 3px solid rgba(49, 105, 198, 0.4);
  outline-offset: 2px;
}

.settings-subheader {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
  margin: 3px 0 10px;
}

.settings-subheader--sources {
  align-items: flex-start;
  margin-top: 22px;
}

.settings-subheader h3 {
  margin: 0;
  font-size: 0.94rem;
}

.settings-subheader p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.settings-site-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: #edf1ee;
  border-radius: 9px;
}

.settings-site-tab {
  min-height: 30px;
  padding: 5px 9px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 720;
}

.settings-site-tab.is-active {
  color: var(--brand-deep);
  background: #fff;
  box-shadow: 0 1px 4px rgba(18, 38, 29, 0.1);
}

.notification-matrix {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.notification-header,
.notification-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 135px 135px;
  gap: 12px;
  align-items: center;
}

.notification-header {
  padding: 9px 14px;
  color: var(--faint);
  background: #f1f4f2;
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.notification-row {
  padding: 13px 14px;
  background: #fff;
}

.notification-row + .notification-row {
  border-top: 1px solid var(--line);
}

.notification-row strong {
  display: block;
  font-size: 0.82rem;
}

.notification-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.69rem;
}

.notification-row select {
  width: 100%;
  min-height: 37px;
  padding: 7px 28px 7px 9px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
}

.integration-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.integration-card {
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.integration-card-header {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.integration-card h4 {
  margin: 0;
  font-size: 0.86rem;
}

.integration-card p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
}

.integration-status {
  flex: 0 0 auto;
  padding: 3px 7px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 730;
}

.integration-status.is-off {
  color: var(--muted);
  background: #e9edeb;
}

.credential-row {
  display: flex;
  gap: 7px;
  align-items: center;
}

.credential-row input {
  min-width: 0;
  min-height: 38px;
  flex: 1;
  padding: 7px 9px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
}

.credential-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.credential-actions .button {
  min-height: 34px;
  padding-block: 6px;
  font-size: 0.7rem;
}

.source-settings-list {
  display: grid;
  gap: 10px;
}

.source-settings-card {
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.source-settings-header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.source-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.source-field {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 670;
}

.source-field.is-wide {
  grid-column: 1 / -1;
}

.source-field input,
.source-field select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 7px 9px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-weight: 500;
}

.source-secret-row {
  display: flex;
  gap: 7px;
}

.source-secret-row input {
  flex: 1;
}

.source-enabled {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 660;
}

.source-enabled input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.source-settings-card h4 {
  margin: 0;
  font-size: 0.88rem;
}

.source-url {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-actions {
  display: flex;
  gap: 7px;
}

.source-actions--spaced {
  margin-top: 11px;
}

.dialog-footer {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: flex-end;
  padding: 13px 24px max(13px, env(safe-area-inset-bottom));
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
}

.save-state {
  margin: 0 auto 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.toast-region {
  position: fixed;
  z-index: 150;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(350px, calc(100vw - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 13px;
  color: #fff;
  background: #23372e;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 11px;
  box-shadow: var(--shadow-lg);
  font-size: 0.79rem;
  animation: toast-in 180ms ease both;
}

.toast.is-error {
  background: #7c2f2f;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

/* Responsive */

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .brand-name {
    display: none;
  }

  .workspace {
    grid-template-columns: 184px minmax(0, 1fr);
  }

  .subscription-summary-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .activity-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-chips {
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  :root {
    --topbar-height: 126px;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 45px 56px;
    gap: 4px 10px;
    padding: 8px 12px;
  }

  .site-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .site-tab {
    min-width: 146px;
    padding-block: 7px;
  }

  .workspace {
    display: block;
  }

  .jump-rail {
    position: sticky;
    z-index: 30;
    top: var(--topbar-height);
    display: flex;
    height: auto;
    flex-direction: row;
    gap: 5px;
    padding: 7px 12px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }

  .rail-group {
    display: flex;
    gap: 5px;
  }

  .rail-group + .rail-group,
  .rail-footer,
  .rail-label,
  .rail-jumps {
    display: none;
  }

  .rail-link {
    width: auto;
    white-space: nowrap;
  }

  .main-content {
    padding: 16px 14px 54px;
  }

  .page-header,
  .subscription-hero {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .page-header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .range-control {
    width: 100%;
    overflow-x: auto;
  }

  .range-button {
    flex: 1 0 auto;
  }

  .layout-menu > summary {
    width: 100%;
    text-align: center;
  }

  .layout-menu-panel {
    right: auto;
    left: 0;
  }

  .subscription-summary-grid {
    grid-template-columns: repeat(2, minmax(135px, 1fr));
  }

  .donut-layout {
    grid-template-columns: 1fr;
  }

  .donut-layout .chart {
    max-width: 260px;
    margin: 0 auto;
  }

  .login-screen {
    grid-template-columns: 1fr;
    padding: 22px;
    background: linear-gradient(155deg, var(--brand-deep), var(--brand) 28%, var(--canvas) 28.1%);
  }

  .login-brand {
    margin-top: 18px;
    font-size: 1.55rem;
  }

  .brand-mark--large {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }
}

@media (max-width: 560px) {
  .topbar-actions .icon-button:first-child {
    display: none;
  }

  .metric-grid,
  .skeleton-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric-card {
    min-height: 105px;
  }

  .section-header {
    gap: 8px;
  }

  .section-actions {
    align-items: flex-end;
    flex-direction: column-reverse;
  }

  .activity-row {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .activity-symbol {
    width: 34px;
    height: 34px;
  }

  .activity-time {
    grid-column: 2;
  }

  .subscription-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .settings-intro,
  .settings-subheader {
    align-items: stretch;
    flex-direction: column;
  }

  .notification-global-controls,
  .integration-settings,
  .source-fields {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    padding-inline: 14px;
  }

  .notification-header,
  .notification-row {
    grid-template-columns: minmax(90px, 1fr) 72px 72px;
    gap: 4px;
    padding-inline: 8px;
  }

  .notification-row select {
    padding-inline: 4px;
    font-size: 0.66rem;
  }

  .notification-row > div > span {
    display: none;
  }

  .source-field.is-wide {
    grid-column: auto;
  }

  .source-actions .button {
    flex: 1;
  }

  .credential-actions,
  .source-secret-row {
    flex-wrap: wrap;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-field.is-wide {
    grid-column: auto;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
