/* Polaris-faithful tokens (hand-written so the page renders identically in
   the admin iframe and in headless screenshots). */
:root {
  --p-bg: #f1f1f1; --p-surface: #ffffff; --p-surface-hover: #f7f7f7; --p-surface-sub: #f7f7f7;
  --p-text: #303030; --p-text-sub: #616161; --p-text-disabled: #b5b5b5;
  --p-border: #e3e3e3; --p-border-strong: #8a8a8a;
  --p-primary: #008060; --p-primary-hover: #006e52; --p-primary-active: #005e46; --p-on-primary: #fff;
  --p-critical: #d82c0d; --p-critical-hover: #bc2200;
  --p-focus: #005bd3;
  --b-success-bg: #affebf; --b-success-fg: #0c5132;
  --b-attention-bg: #ffd6a4; --b-attention-fg: #5e4200;
  --b-warning-bg: #ffeb78; --b-warning-fg: #4f4700;
  --b-critical-bg: #fed3d1; --b-critical-fg: #8e1f0b;
  --b-info-bg: #e0f0ff; --b-info-fg: #00527c;
  --b-default-bg: #e3e3e3; --b-default-fg: #303030;
  --r-100: 4px; --r-200: 8px; --r-300: 12px;
  --shadow-card: 0 1px 0 0 rgba(26,26,26,.07), inset 0 0 0 1px rgba(0,0,0,.06);
  --shadow-btn: 0 -1px 0 0 #b5b5b5 inset, 0 0 0 1px rgba(0,0,0,.1) inset, 0 .5px 0 1.5px #fff inset;
  --font: -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--p-bg); color: var(--p-text); font: 13px/20px var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--p-focus); }
.hidden { display: none !important; }
.p-page { max-width: 1160px; margin: 0 auto; padding: 20px 24px 96px; }
.p-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.p-title { font-size: 20px; line-height: 24px; font-weight: 650; margin: 0; }
.p-subtitle { margin: 4px 0 0; color: var(--p-text-sub); }
.p-header-actions { display: flex; align-items: center; gap: 12px; }
.p-who { color: var(--p-text-sub); display: inline-flex; align-items: center; gap: 8px; }
.h-md { font-size: 14px; line-height: 20px; font-weight: 650; margin: 0; }
.h-lg { font-size: 16px; line-height: 24px; font-weight: 650; margin: 0; }
.p-body { margin: 0; }
.p-body p { margin: 0 0 8px; }
.p-subdued { color: var(--p-text-sub); margin: 0; }
.p-help { color: var(--p-text-sub); font-size: 12px; line-height: 16px; }
.p-label { display: block; font-weight: 550; margin-bottom: 4px; }
.p-error { color: var(--p-critical); font-size: 12px; line-height: 16px; margin-top: 4px; }
.pad-x { padding: 0 16px 12px; }
.small { font-size: 12px; line-height: 16px; }

/* tabs */
.p-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--p-border); margin-bottom: 16px; overflow-x: auto; }
.p-tab { background: none; border: 0; padding: 8px 12px; margin-bottom: -1px; border-bottom: 3px solid transparent; color: var(--p-text-sub); font-weight: 550; cursor: pointer; white-space: nowrap; border-radius: var(--r-200) var(--r-200) 0 0; }
.p-tab:hover { background: rgba(0,0,0,.04); color: var(--p-text); }
.p-tab.active { color: var(--p-text); border-bottom-color: var(--p-text); }
.p-tabcount { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--b-info-bg); color: var(--b-info-fg); font-size: 11px; line-height: 18px; text-align: center; }
.p-tabcount:empty { display: none; }

/* layout */
.p-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.p-main, .p-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* cards */
.card { background: var(--p-surface); border-radius: var(--r-300); box-shadow: var(--shadow-card); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 16px 0; }
.card-head.wrap { flex-wrap: wrap; row-gap: 8px; }
.card-head + .card-body { padding-top: 12px; }
.card-body { padding: 16px; }
.card-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--p-border); flex-wrap: wrap; }
.card-welcome { background: linear-gradient(135deg, #f0fbf7 0%, #ffffff 60%); }
.welcome-row { display: flex; gap: 16px; align-items: flex-start; }
.welcome-icon { color: var(--p-primary); background: #e3f5ee; border-radius: var(--r-300); width: 48px; height: 48px; display: grid; place-items: center; flex: none; }
.welcome-steps { margin: 8px 0 0; padding-left: 18px; }
.welcome-steps li { margin: 2px 0; }
.welcome-row > .btn-plain { margin-left: auto; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 28px; padding: 4px 12px; border-radius: var(--r-200); border: 0; background: var(--p-surface); color: var(--p-text); font-weight: 550; text-decoration: none; cursor: pointer; box-shadow: var(--shadow-btn); }
.btn:hover { background: #fafafa; }
.btn:active { background: #f0f0f0; }
.btn:focus-visible { outline: 2px solid var(--p-focus); outline-offset: 1px; }
.btn:disabled { color: var(--p-text-disabled); background: #f7f7f7; box-shadow: none; cursor: default; }
.btn-primary { background: var(--p-primary); color: var(--p-on-primary); box-shadow: 0 -1px 0 0 rgba(0,0,0,.2) inset, 0 0 0 1px rgba(0,0,0,.08) inset; }
.btn-primary:hover { background: var(--p-primary-hover); }
.btn-primary:active { background: var(--p-primary-active); }
.btn-primary:disabled { background: #cfe8df; color: #fff; }
.btn-critical { background: var(--p-critical); color: #fff; box-shadow: none; }
.btn-critical:hover { background: var(--p-critical-hover); }
.btn-critical-plain { background: none; box-shadow: none; color: var(--p-critical); }
.btn-critical-plain:hover { background: #fff4f2; }
.btn-plain { background: none; box-shadow: none; color: var(--p-focus); padding: 4px 6px; }
.btn-plain:hover { background: rgba(0,91,211,.06); text-decoration: underline; }
.btn-sm { min-height: 24px; padding: 2px 8px; font-size: 12px; }
.btn-block { width: 100%; min-height: 40px; font-size: 14px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-group.right { justify-content: flex-end; }

/* inputs */
textarea, input[type=search] { width: 100%; border: 1px solid var(--p-border-strong); border-radius: var(--r-200); padding: 6px 12px; background: #fdfdfd; resize: vertical; }
textarea { min-height: 96px; line-height: 20px; }
textarea:focus, input:focus { outline: 2px solid var(--p-focus); outline-offset: -1px; border-color: transparent; }
textarea.invalid { border-color: var(--p-critical); background: #fff8f7; }
.p-fieldrow { display: flex; justify-content: space-between; margin-top: 4px; }
.p-chips { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-top: 12px; }
.p-chiprow { display: flex; gap: 8px; flex-wrap: wrap; }
.p-chip { border: 0; background: var(--p-surface); box-shadow: inset 0 0 0 1px var(--p-border); border-radius: var(--r-200); padding: 4px 10px; font-size: 12px; line-height: 16px; cursor: pointer; text-align: left; color: var(--p-text); }
.p-chip:hover { background: var(--p-surface-hover); }
.p-chip.active { background: var(--p-text); color: #fff; box-shadow: none; }
.p-check { display: inline-flex; gap: 6px; align-items: center; color: var(--p-text-sub); white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row input[type=search] { width: 240px; }

/* banners */
.p-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-300); background: var(--b-info-bg); color: var(--b-info-fg); margin-bottom: 12px; }
.p-banner.small { padding: 8px 12px; }
.p-banner.critical { background: var(--b-critical-bg); color: var(--b-critical-fg); }
.p-banner.warning { background: var(--b-warning-bg); color: var(--b-warning-fg); }
.p-banner.success { background: var(--b-success-bg); color: var(--b-success-fg); }
.p-banner.info { background: var(--b-info-bg); color: var(--b-info-fg); }
.p-banner ul { margin: 4px 0 0; padding-left: 18px; }
.p-banner .banner-text { flex: 1; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-200); font-size: 12px; line-height: 16px; font-weight: 550; background: var(--b-default-bg); color: var(--b-default-fg); white-space: nowrap; }
.badge.success { background: var(--b-success-bg); color: var(--b-success-fg); }
.badge.attention { background: var(--b-attention-bg); color: var(--b-attention-fg); }
.badge.warning { background: var(--b-warning-bg); color: var(--b-warning-fg); }
.badge.critical { background: var(--b-critical-bg); color: var(--b-critical-fg); }
.badge.info { background: var(--b-info-bg); color: var(--b-info-fg); }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.progress .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: .9; } }

/* plan preview */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 4px; }
.slot { border: 1px solid var(--p-border); border-radius: var(--r-300); padding: 12px; background: var(--p-surface); }
.slot-role { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--p-text-sub); margin-bottom: 8px; }
.slot-role strong { color: var(--p-text); text-transform: uppercase; letter-spacing: .02em; font-size: 11px; }
.tile { display: flex; gap: 12px; align-items: center; }
.thumb { width: 56px; height: 56px; border-radius: var(--r-200); object-fit: contain; background: var(--p-surface-sub); border: 1px solid var(--p-border); flex: none; }
.thumb.sm { width: 40px; height: 40px; }
.thumb.empty { display: grid; place-items: center; color: var(--p-text-disabled); }
.tile-title { font-weight: 550; }
.tile-sub { color: var(--p-text-sub); font-size: 12px; line-height: 16px; }
.alts { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--p-border); font-size: 12px; line-height: 18px; color: var(--p-text-sub); }
.alts span { display: inline-block; background: var(--p-surface-sub); border-radius: var(--r-100); padding: 0 6px; margin: 2px 4px 2px 0; color: var(--p-text); }
.footer-total .total { display: flex; align-items: baseline; gap: 8px; font-size: 16px; }
.footer-total .total strong { font-size: 20px; font-weight: 650; }

/* progress */
.steps { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.steps li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-200); background: var(--p-surface-sub); color: var(--p-text-sub); font-size: 12px; line-height: 16px; }
.steps li .ic { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 1.5px solid var(--p-border-strong); font-size: 11px; }
.steps li.done { color: var(--b-success-fg); background: #f1fbf5; }
.steps li.done .ic { background: var(--p-primary); border-color: var(--p-primary); color: #fff; }
.steps li.current { color: var(--b-info-fg); background: var(--b-info-bg); font-weight: 550; }
.steps li.current .ic { border-color: var(--b-info-fg); border-top-color: transparent; animation: spin 1s linear infinite; }
.steps li.failed, .steps li.cancelled { color: var(--b-critical-fg); background: var(--b-critical-bg); }
.steps li.failed .ic { border-color: var(--b-critical-fg); }
@keyframes spin { to { transform: rotate(360deg); } }
.p-details summary { cursor: pointer; color: var(--p-text-sub); font-weight: 550; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
.p-details summary::before { content: "\25B8"; font-size: 10px; }
.p-details[open] summary::before { content: "\25BE"; }
.log { margin: 8px 0 0; background: #1a1a1a; color: #e3e3e3; font: 12px/18px ui-monospace, Menlo, monospace; padding: 12px; border-radius: var(--r-200); max-height: 300px; overflow: auto; white-space: pre-wrap; }

/* index tables / lists */
.index { display: flex; flex-direction: column; }
.index .irow { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--p-border); }
.index .irow:hover { background: var(--p-surface-hover); }
.index .irow.simple { grid-template-columns: minmax(0, 1fr) auto auto; }
.index .irow.top { grid-template-columns: minmax(0, 1fr) 70px 110px; }
.index .irow.head { color: var(--p-text-sub); font-size: 12px; font-weight: 550; padding: 8px 16px; border-top: 0; }
.index .irow.head:hover { background: none; }
.index.compact .irow { grid-template-columns: 80px 1fr auto; padding: 8px 16px; }
.ititle { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.isub { color: var(--p-text-sub); font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iactions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.iactions .btn { min-height: 26px; padding: 2px 10px; font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.expander { grid-column: 1 / -1; background: var(--p-surface-sub); border-radius: var(--r-200); padding: 12px; }
.comp { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--p-border); }
.comp:first-child { border-top: 0; }
.comp .alts { margin-top: 4px; padding-top: 0; border: 0; }
.empty { padding: 40px 16px; text-align: center; color: var(--p-text-sub); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty svg { color: var(--p-text-disabled); }
.empty h3 { margin: 0; font-size: 14px; color: var(--p-text); }

/* KPIs */
.kpis { display: grid; gap: 12px; margin-bottom: 16px; }
.kpis-3 { grid-template-columns: repeat(3, 1fr); }
.kpis-5 { grid-template-columns: repeat(5, 1fr); }
.kpi { background: var(--p-surface); border-radius: var(--r-300); box-shadow: var(--shadow-card); padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-label { color: var(--p-text-sub); font-size: 12px; line-height: 16px; font-weight: 550; }
.kpi-value { font-size: 20px; line-height: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 12px; line-height: 16px; color: var(--p-text-sub); display: inline-flex; gap: 4px; align-items: center; }
.kpi-delta.up { color: var(--b-success-fg); }
.kpi-delta.down { color: var(--b-critical-fg); }
.kpi.soon .kpi-value { font-size: 14px; color: var(--p-text-sub); font-weight: 550; }

/* segmented */
.segmented { display: inline-flex; background: var(--p-surface-sub); border-radius: var(--r-200); padding: 2px; gap: 2px; }
.segmented button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; font-weight: 550; color: var(--p-text-sub); cursor: pointer; }
.segmented button.active { background: var(--p-surface); color: var(--p-text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* chart */
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--p-primary); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .bar.empty { fill: var(--p-border); }
.chart text { font: 11px var(--font); fill: var(--p-text-sub); }
.chart text.val { fill: var(--p-text); font-weight: 550; }
.chart line { stroke: var(--p-border); }

/* skeletons */
.sk { background: linear-gradient(90deg, #ececec 25%, #f5f5f5 37%, #ececec 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-100); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.sk-title { height: 16px; width: 40%; margin-bottom: 12px; }
.sk-line { height: 12px; width: 90%; margin-bottom: 8px; }
.sk-line.short { width: 55%; }
.sk-num { height: 24px; width: 60%; }
.sk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.sk-tile { height: 84px; border-radius: var(--r-300); }
.sk-rows { display: flex; flex-direction: column; gap: 1px; }
.sk-row { height: 56px; border-radius: 0; margin: 0 16px; }

/* activity */
.act { display: flex; justify-content: space-between; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--p-border); align-items: center; }
.act:first-child { border-top: 0; }
.act .ititle { font-size: 13px; }
.tips p { margin: 0 0 8px; }

/* modal + toasts */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--p-surface); border-radius: var(--r-300); padding: 20px; max-width: 460px; width: 100%; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #303030; color: #fff; padding: 10px 16px; border-radius: var(--r-200); box-shadow: 0 4px 12px rgba(0,0,0,.25); font-weight: 550; animation: rise .2s ease; }
.toast.error { background: var(--p-critical); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.p-footer { margin: 24px 4px 0; }
.mobile-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--p-border); z-index: 40; }

@media (max-width: 1040px) {
  .p-layout { grid-template-columns: 1fr; }
  .kpis-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .p-page { padding: 16px 16px 120px; }
  .p-header { flex-direction: column; }
  .p-header-actions { width: 100%; justify-content: space-between; }
  .kpis-3, .kpis-5 { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 18px; }
  .index .irow { grid-template-columns: 40px minmax(0, 1fr); row-gap: 8px; }
  .index .irow > .badge, .index .irow > .iactions { grid-column: 2; justify-self: start; }
  .index .irow.top, .index .irow.simple { grid-template-columns: minmax(0, 1fr) auto; }
  .index .irow.head { display: none; }
  .row input[type=search] { width: 100%; }
  .footer-total { flex-direction: column; align-items: stretch; }
  .footer-total .btn-group { justify-content: stretch; }
  .footer-total .btn-group .btn { flex: 1; }
  .welcome-row { flex-wrap: wrap; }
  .card-footer > .btn-primary { width: 100%; }
}
