:root {
    --ds-blue: #4D70FF;
    --ds-blue-hover: #395beb;
    --text-primary: #4A4A4A;
    --text-secondary: #8c8c8c;
    --text-heading: #202124;
    --bg-surface: rgba(255, 255, 255, 0.9);
    --border-soft: rgba(0, 0, 0, 0.05);
    --border-input: #e5e5e5;
    --shadow-float: 0 12px 32px rgba(0, 0, 0, 0.06);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.03);
    --shadow-focus: 0 4px 20px rgba(77, 112, 255, 0.12);
    --radius-xl: 16px;
    --radius-md: 12px;
    --radius-sm: 10px;
    --radius-pill: 9999px;
    --blue-tint: #f7f9ff;
    --blue-tint-2: #eef3ff;
    --success: #16835f;
    --warning: #a45f00;
    --danger: #c62828;
    --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    min-height: 100vh;
    color: var(--text-primary);
    background-color: #f7f9ff;
    background-image:
        radial-gradient(circle at 10% 90%, rgba(77, 112, 255, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 10%, rgba(77, 112, 255, 0.05) 0%, transparent 30%);
    background-attachment: fixed;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
h1 { color: var(--text-heading); font-size: 1.75rem; font-weight: 700; line-height: 1.25; }
h2 { color: var(--text-heading); font-size: 1.2rem; font-weight: 600; }
h3 { color: var(--text-heading); font-size: 1rem; font-weight: 600; }
p { color: var(--text-secondary); line-height: 1.65; }
a { color: inherit; }

.topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-surface);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.topbar-brand, .topbar-session { display: flex; align-items: center; gap: 0.75rem; }
.brand-mark { color: var(--ds-blue); font-size: 1.1rem; font-weight: 700; text-decoration: none; }
.brand-sep { color: #d0d0d0; }
.brand-page, .topbar-link { color: var(--text-secondary); font-size: 0.9rem; }
.topbar-link { font-weight: 500; text-decoration: none; transition: color 0.2s; }
.topbar-link:hover { color: var(--ds-blue); }
.session-user { color: var(--text-primary); font-size: 0.9rem; font-weight: 600; }

.main-content { width: min(960px, calc(100% - 2rem)); min-height: calc(100vh - 120px); margin: 0 auto; padding: 2rem 0; }
.wide-content { width: min(1240px, calc(100% - 2rem)); }
.form-content { width: min(1040px, calc(100% - 2rem)); }
.site-footer { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 2rem 1.5rem; color: var(--text-secondary); font-size: 0.8rem; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ds-blue); text-decoration: underline; }

.panel { padding: 1.5rem; border: 1px solid var(--border-soft); border-radius: var(--radius-xl); background: #fff; box-shadow: var(--shadow-card); }
.panel-head { margin-bottom: 1rem; }
.panel-head p { margin-top: 0.35rem; }
.eyebrow { display: block; margin-bottom: 0.45rem; color: var(--ds-blue); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.page-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; padding: 0.5rem 0; }
.page-hero p { margin-top: 0.45rem; }
.compact-hero { align-items: center; }
.back-link { display: inline-block; margin-bottom: 0.6rem; color: var(--ds-blue); font-size: 0.85rem; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.62rem 1.25rem; border: 0; border-radius: var(--radius-pill);
    color: #fff; background: var(--ds-blue); font: inherit; font-weight: 600;
    text-decoration: none; cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.btn:hover { background: var(--ds-blue-hover); transform: scale(0.98); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }
.btn-sm { padding: 0.36rem 0.85rem; font-size: 0.85rem; }
.btn-large { padding: 0.8rem 1.6rem; }
.btn-block { width: 100%; }
.btn-secondary { color: var(--ds-blue); background: var(--blue-tint-2); }
.btn-secondary:hover { background: #dbe5ff; }
.btn-ghost { color: var(--text-secondary); border: 1px solid var(--border-input); background: transparent; }
.btn-ghost:hover { color: var(--ds-blue); border-color: var(--ds-blue); background: var(--blue-tint); }
.text-link { color: var(--ds-blue); font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.form-stack { display: grid; gap: 0.9rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: 0.38rem; color: var(--text-secondary); font-size: 0.875rem; font-weight: 500; }
label small { color: var(--text-secondary); font-weight: 400; }
input, textarea, select {
    width: 100%; padding: 0.68rem 0.85rem; border: 1px solid var(--border-input); border-radius: var(--radius-sm);
    outline: 0; color: #333; background: #fff; font: inherit; transition: var(--transition);
}
input:focus, textarea:focus, select:focus { border-color: var(--ds-blue); box-shadow: var(--shadow-focus); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 4rem; }
.password-field button { position: absolute; top: 0; right: 0; bottom: 0; width: 4rem; border: 0; color: var(--ds-blue); background: transparent; cursor: pointer; }
.checkbox-label { display: flex; align-items: center; align-self: end; gap: 0.55rem; min-height: 42px; }
.checkbox-label input { width: auto; }
.status { min-height: 1.25rem; margin-top: 0.65rem; color: var(--text-secondary); font-size: 0.875rem; }
.status.error { color: var(--danger); }
.status.success { color: var(--success); }
.hidden { display: none !important; }

.auth-shell { display: grid; min-height: calc(100vh - 190px); place-items: center; }
.auth-card { width: min(410px, 100%); padding: 2rem; }
.auth-card .panel-head { margin-bottom: 1.5rem; }
.auth-card h1 { margin-bottom: 0.5rem; }

.run-form { display: grid; gap: 1rem; }
.form-section { display: grid; gap: 1.25rem; }
.section-heading { display: flex; align-items: flex-start; gap: 0.9rem; }
.section-heading > span { display: grid; width: 2rem; height: 2rem; flex: 0 0 2rem; place-items: center; border-radius: 50%; color: #fff; background: var(--ds-blue); font-weight: 700; }
.section-heading p { margin-top: 0.2rem; }
.choice-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; border: 0; }
.choice-group legend { margin-bottom: 0.5rem; color: var(--text-secondary); font-size: 0.875rem; font-weight: 600; }
.choice-card, .template-card { position: relative; display: block; cursor: pointer; }
.choice-card input, .template-card input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.choice-card span, .template-card span { display: grid; gap: 0.25rem; height: 100%; padding: 0.95rem; border: 1px solid var(--border-input); border-radius: var(--radius-md); background: #fff; transition: var(--transition); }
.choice-card strong, .template-card strong { color: var(--text-heading); }
.choice-card small, .template-card small { color: var(--text-secondary); font-weight: 400; line-height: 1.5; }
.choice-card input:checked + span, .template-card input:checked + span { border-color: var(--ds-blue); background: var(--blue-tint-2); box-shadow: var(--shadow-focus); }
.template-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.65rem; }
.url-preview { display: grid; gap: 0.35rem; padding: 1rem; border: 1px solid rgba(77,112,255,0.18); border-radius: var(--radius-md); background: var(--blue-tint); }
.url-preview span, .url-preview small { color: var(--text-secondary); }
.url-preview strong { color: var(--ds-blue); overflow-wrap: anywhere; }
.advanced-panel { border-top: 1px solid var(--border-soft); padding-top: 1rem; }
.advanced-panel summary { color: var(--ds-blue); font-weight: 600; cursor: pointer; }
.advanced-grid { margin-top: 1rem; }
.budget-panel { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.budget-panel h2 { margin-bottom: 0.25rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 0.75rem; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: top; }
th { color: var(--text-secondary); background: var(--blue-tint); font-weight: 600; }
.runs-table { min-width: 900px; }
.cell-sub { display: block; max-width: 360px; margin-top: 0.25rem; color: var(--text-secondary); font-size: 0.76rem; font-weight: 400; }
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { display: grid; gap: 0.75rem; justify-items: center; padding: 3rem 1rem; text-align: center; }

.status-badge { display: inline-flex; align-items: center; padding: 0.34rem 0.7rem; border-radius: var(--radius-pill); color: var(--ds-blue); background: var(--blue-tint-2); font-size: 0.8rem; font-weight: 700; }
.status-completed { color: var(--success); background: #eaf8f3; }
.status-failed, .status-cancelled { color: var(--danger); background: #fff0f0; }
.status-partial, .status-awaiting_confirmation { color: var(--warning); background: #fff7e8; }

.progress-strip { display: grid; grid-template-columns: repeat(5, 1fr); margin-bottom: 1rem; overflow: hidden; border: 1px solid var(--border-soft); border-radius: var(--radius-md); background: #fff; box-shadow: var(--shadow-card); }
.progress-strip div { display: flex; align-items: center; gap: 0.55rem; padding: 0.85rem; color: var(--text-secondary); border-right: 1px solid var(--border-soft); }
.progress-strip div:last-child { border-right: 0; }
.progress-strip span { display: grid; width: 1.7rem; height: 1.7rem; place-items: center; border-radius: 50%; background: #edf0f5; font-size: 0.76rem; }
.progress-strip .active { color: var(--ds-blue); background: var(--blue-tint); }
.progress-strip .active span { color: #fff; background: var(--ds-blue); }
.progress-strip .done { color: var(--success); }
.progress-strip .done span { color: #fff; background: var(--success); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr); gap: 1rem; }
.notice-card { margin-bottom: 1rem; padding: 1rem; border: 1px solid #f0d7a5; border-radius: var(--radius-md); background: #fff9ed; }
.notice-card strong { color: var(--warning); }
.notice-card p { margin-top: 0.35rem; }
.action-row { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; margin-top: 1rem; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.metric-card { min-width: 0; padding: 0.9rem; border-radius: var(--radius-md); background: var(--blue-tint); }
.metric-card span, .metric-card small { display: block; color: var(--text-secondary); }
.metric-card strong { display: block; margin: 0.4rem 0 0.25rem; color: var(--text-heading); font-size: 1.35rem; overflow-wrap: anywhere; }
.timeline { display: grid; gap: 0.9rem; list-style: none; }
.timeline li { position: relative; padding-left: 1.1rem; border-left: 2px solid #dfe6ff; }
.timeline li::before { position: absolute; top: 0.2rem; left: -0.38rem; width: 0.62rem; height: 0.62rem; border-radius: 50%; background: var(--ds-blue); content: ""; }
.timeline span { color: var(--text-secondary); font-size: 0.76rem; }
.timeline strong { display: block; margin: 0.15rem 0; color: var(--text-heading); }
.timeline p { overflow-wrap: anywhere; font-size: 0.85rem; }

.report-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.report-meta span { color: var(--text-secondary); font-size: 0.8rem; }
.report-meta strong { display: block; margin-top: 0.45rem; color: var(--text-heading); }
.definition-grid { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 0.75rem 1rem; }
.definition-grid dt { color: var(--text-secondary); }
.definition-grid dd { overflow-wrap: anywhere; }
.report-stage-panel, .report-boundary, .report-conclusions, .error-panel { margin-top: 1rem; }
.report-conclusions ul { display: grid; gap: 0.65rem; padding-left: 1.25rem; }
.report-conclusions li { color: var(--text-primary); line-height: 1.7; }
.report-subhead { margin: 1.25rem 0 0.75rem; }
.report-subhead.first { margin-top: 0; }
.report-table-wrap { border: 1px solid var(--border-soft); border-radius: var(--radius-md); }
.report-table { min-width: 720px; table-layout: fixed; font-variant-numeric: tabular-nums; }
.report-table th, .report-table td { padding: 0.78rem 0.9rem; text-align: center; vertical-align: middle; white-space: nowrap; }
.report-table th { color: var(--text-heading); background: #f4f7ff; font-size: 0.8rem; }
.report-table th small { display: block; margin-top: 0.18rem; color: var(--text-secondary); font-size: 0.68rem; font-weight: 400; }
.report-table th:first-child, .report-table td:first-child { width: 5.5rem; text-align: center; }
.report-table td:first-child { color: var(--ds-blue); font-weight: 700; }
.report-table--latency th:nth-child(2), .report-table--latency td:nth-child(2),
.report-table--image th:nth-child(2), .report-table--image td:nth-child(2) { width: 6.5rem; text-align: center; }
.report-table--latency th:nth-child(3), .report-table--latency td:nth-child(3),
.report-table--image th:nth-child(3), .report-table--image td:nth-child(3) { width: 7rem; }
.report-table tbody tr:nth-child(even) td { background: #fafbff; }
.report-table tbody tr:hover td { background: var(--blue-tint-2); }
.report-table tbody tr:last-child td { border-bottom: 0; }
.report-table .sample-note { color: var(--text-secondary); font-size: 0.78rem; white-space: nowrap; }
.error-panel { border-color: #f2c7c7; background: #fffafa; }
.error-panel p { margin-top: 0.5rem; }

@media (max-width: 900px) {
    .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: 1fr; }
    .report-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .progress-strip { grid-template-columns: 1fr; }
    .progress-strip div { border-right: 0; border-bottom: 1px solid var(--border-soft); }
    .progress-strip div:last-child { border-bottom: 0; }
}

@media (max-width: 640px) {
    .topbar { align-items: flex-start; padding: 0.75rem 1rem; }
    .brand-page, .brand-sep, .topbar-link { display: none; }
    .topbar-session { gap: 0.5rem; }
    .main-content, .wide-content, .form-content { width: min(100% - 1rem, 100%); padding: 1rem 0; }
    .panel { padding: 1rem; }
    .page-hero, .budget-panel { align-items: stretch; flex-direction: column; }
    .form-grid, .choice-group, .template-grid, .metric-grid, .report-summary-grid { grid-template-columns: 1fr; }
    .definition-grid { grid-template-columns: 1fr; gap: 0.25rem; }
    .definition-grid dd { margin-bottom: 0.65rem; }
    .btn-large { width: 100%; }
}
