/* Shared styles for the Chart Vision and Optimiser tool pages (extends s1.css, light theme) */
.tool-main { flex: 1; min-width: 0; margin-left: 280px; padding: 40px; background: var(--slate-50); min-height: 100vh; }
.tool-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 32px; flex-wrap: wrap; }
.tool-header h1 { font-size: 40px; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; color: var(--slate-900); }
.tool-header h1 .accent { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.tool-header p { color: var(--slate-500); font-size: 16px; max-width: 640px; margin-top: 10px; line-height: 1.55; }
.tool-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.tool-grid .card:hover { transform: none; box-shadow: var(--shadow-soft); }
.tool-grid .card-title { font-size: 16px; }
.muted { color: var(--slate-500); }
.small { font-size: 12px; }
.strong { color: var(--slate-900); font-weight: 700; }
.hidden { display: none !important; }

/* Upload zone */
.dropzone { border: 1.5px dashed var(--slate-300); border-radius: 16px; padding: 32px 20px; text-align: center; cursor: pointer;
    transition: all .2s ease; background: var(--slate-50); }
.dropzone:hover, .dropzone.drag, .dropzone:focus-visible { border-color: var(--brand-primary); background: #eff6ff; outline: none; }
.dropzone i { font-size: 28px; color: var(--brand-primary); margin-bottom: 12px; }
.dropzone strong { display: block; color: var(--slate-900); font-size: 15px; margin-bottom: 6px; }
.dropzone img { max-width: 100%; max-height: 220px; border-radius: 10px; display: block; margin: 0 auto; }
kbd { background: white; border: 1px solid var(--slate-200); border-radius: 6px; padding: 1px 6px; font-size: 12px; color: var(--slate-700); }

.field-label { font-size: 12px; font-weight: 700; color: var(--slate-500); text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 8px; display: block; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
details.calib summary { cursor: pointer; color: var(--slate-700); font-weight: 600; font-size: 14px; margin-top: 18px; list-style: none; }
details.calib summary::-webkit-details-marker { display: none; }
details.calib summary::before { content: "\25B8  "; color: var(--brand-primary); }
details.calib[open] summary::before { content: "\25BE  "; }

/* Segmented control */
.segmented { display: inline-flex; background: white; border: 1px solid var(--slate-200); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button { background: transparent; border: 0; color: var(--slate-500); font: 600 13px 'Inter', sans-serif; padding: 9px 16px; border-radius: 9px; cursor: pointer; transition: all .2s; }
.segmented button:hover { color: var(--slate-900); }
.segmented button.active { background: var(--brand-primary); color: white; box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25); }

/* Metric tiles */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.metric { background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: 14px; padding: 16px 18px; }
.metric .k { font-size: 11px; font-weight: 700; color: var(--slate-500); text-transform: uppercase; letter-spacing: .05em; }
.metric .v { font-family: 'Outfit', sans-serif; font-size: 26px; font-weight: 800; color: var(--slate-900); margin-top: 4px; font-variant-numeric: tabular-nums; }
.metric .s { font-size: 12px; color: var(--slate-500); margin-top: 2px; font-weight: 500; }
.up { color: var(--success) !important; } .down { color: var(--danger) !important; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
    background: var(--slate-100); border: 1px solid var(--slate-200); color: var(--slate-600); }
.pill.ok { color: #047857; border-color: #a7f3d0; background: #ecfdf5; }
.pill.warn { color: #b45309; border-color: #fde68a; background: #fffbeb; }

.notice { border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.5; background: #fffbeb;
    border: 1px solid #fde68a; color: #92400e; margin-top: 12px; }
.notice.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.notice.err { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

.img-frame { border-radius: 14px; overflow: hidden; border: 1px solid var(--slate-200); background: var(--slate-100); }
.img-frame img { width: 100%; display: block; }
.canvas-frame { border-radius: 14px; border: 1px solid var(--slate-200); background: white; padding: 12px; }

/* Pipeline steps */
.steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; counter-reset: s; }
.step { padding: 16px; border-radius: 14px; background: var(--slate-50); border: 1px solid var(--slate-200); counter-increment: s; }
.step::before { content: counter(s, decimal-leading-zero); font: 800 12px 'Outfit', sans-serif; color: var(--brand-primary); }
.step b { display: block; color: var(--slate-900); font-size: 14px; margin: 6px 0 4px; }
.step span { font-size: 12px; color: var(--slate-500); line-height: 1.45; }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: white; border-radius: 50%; animation: tool-spin .8s linear infinite; }
@keyframes tool-spin { to { transform: rotate(360deg); } }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }

/* Tables */
.wtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.wtable th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-500); font-weight: 700; padding: 0 8px 10px; }
.wtable td { padding: 10px 8px; border-top: 1px solid var(--slate-200); color: var(--slate-700); font-variant-numeric: tabular-nums; }
.wtable td.num { text-align: right; color: var(--slate-900); font-weight: 700; }
.bar { height: 6px; border-radius: 4px; background: var(--slate-200); overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--brand-gradient); }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 8px; vertical-align: -1px; }
.chart-box { position: relative; height: 340px; }

/* Responsive */
@media (max-width: 1100px) {
    .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
    .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* s1.css slides the sidebar off-screen below 1024px; these pages have no
   toggle for it, so it becomes a horizontal top bar instead */
@media (max-width: 1024px) {
    .tool-shell { flex-direction: column; }
    .tool-shell .sidebar { transform: none; position: sticky; top: 0; bottom: auto; width: 100%; height: auto; padding: 10px 0;
        flex-direction: row; align-items: center; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--slate-200); }
    .tool-shell .sidebar-logo { margin: 0; padding: 0 16px; font-size: 20px; flex-shrink: 0; }
    .tool-shell .sidebar-nav { flex-direction: row; gap: 4px; }
    .tool-shell .sidebar-item { margin: 0; padding: 8px 12px; white-space: nowrap; font-size: 13px; }
    .tool-shell .sidebar-item:hover { transform: none; }
    .tool-main { margin-left: 0; }
}
@media (max-width: 760px) {
    .tool-main { padding: 20px 16px; }
    .tool-header h1 { font-size: 30px; }
    .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card { padding: 20px; }
    .field-row { grid-template-columns: 1fr; }
}
