:root {
  color-scheme: light;
  --navy: #132738;
  --ink: #182633;
  --muted: #657583;
  --line: #d9e1e6;
  --surface: #ffffff;
  --background: #f4f7f9;
  --blue: #176b87;
  --green: #087f5b;
  --warning-bg: #fff8e7;
  --warning-line: #ead49b;
  --warning-ink: #684b08;
  --shadow: 0 8px 28px rgba(22, 45, 61, .06);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
.app-header { background: var(--navy); color: white; padding: 16px clamp(14px, 3vw, 32px); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand-row, .connection-box { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; border: 1px solid #8ba0ad; border-radius: 12px; display: grid; place-items: center; font-weight: 800; letter-spacing: -.05em; color: #d1f4ee; }
.eyebrow { margin: 0 0 5px; font-size: .68rem; font-weight: 800; letter-spacing: .12em; color: var(--muted); }
.app-header .eyebrow { color: #a8bac5; }
h1, h2, p { margin-top: 0; }
h1 { margin: 0; font-size: 1.25rem; letter-spacing: -.02em; }
h2 { margin: 0; font-size: 1.18rem; letter-spacing: -.025em; }
.connection-box { flex-wrap: wrap; font-size: .88rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #d09b37; box-shadow: 0 0 0 4px rgba(208,155,55,.15); }
.status-dot.connected { background: #4bd6aa; box-shadow: 0 0 0 4px rgba(75,214,170,.15); }
.page-shell { width: min(1260px, 100%); margin: 0 auto; padding: 20px clamp(12px, 2.5vw, 28px) 30px; }
.notice { border: 1px solid; border-radius: 12px; padding: 12px 14px; font-size: .88rem; line-height: 1.55; margin-bottom: 16px; }
.notice-warning { background: var(--warning-bg); border-color: var(--warning-line); color: var(--warning-ink); }
.notice code { overflow-wrap: anywhere; }
.tab-bar { display: flex; gap: 6px; padding: 5px; background: #e9eef1; border-radius: 12px; margin-bottom: 20px; }
.tab-button { flex: 1; min-height: 42px; border: 0; background: transparent; border-radius: 9px; color: #50616d; font-weight: 700; }
.tab-button.active { background: white; color: var(--navy); box-shadow: 0 2px 8px rgba(15,36,50,.08); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.section-heading, .panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-heading { margin-top: 8px; }
.subtle-state { color: var(--muted); font-size: .78rem; text-align: right; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.metric-card { padding: 15px; min-width: 0; }
.metric-label { color: var(--muted); font-size: .8rem; font-weight: 650; }
.metric-value { margin-top: 8px; font-size: clamp(1.25rem, 2.6vw, 1.85rem); font-weight: 750; letter-spacing: -.045em; white-space: nowrap; }
.metric-value small { color: var(--muted); font-size: .65em; font-weight: 600; }
.metric-foot { color: #8a98a2; font-size: .7rem; margin-top: 7px; }
.panel { padding: clamp(14px, 2vw, 22px); margin-bottom: 16px; min-width: 0; }
.helper-text { font-size: .83rem; line-height: 1.5; color: var(--muted); margin: 0 0 14px; }
.helper-text.compact { font-size: .75rem; margin-bottom: 0; }
.tag { border-radius: 999px; padding: 6px 9px; background: #eaf3f7; color: #15556c; font-size: .72rem; font-weight: 750; white-space: nowrap; }
.tag-warning { background: #fff0cc; color: #75560c; }
.diagram-wrap { width: 100%; overflow-x: auto; border: 1px solid #e3e8eb; border-radius: 10px; background: #fff; }
#profileSvg { display: block; width: 100%; min-width: 660px; height: auto; touch-action: none; }
.diagram-footer { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: .78rem; color: var(--muted); }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; }
.legend-dot.opening { background: var(--blue); }
.legend-dot.closing { background: var(--green); }
.profile-readout { color: var(--muted); font-size: .75rem; padding-top: 8px; line-height: 1.45; }
.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.content-grid .panel { margin-bottom: 16px; }
.field-label { display: block; font-size: .81rem; font-weight: 750; margin: 15px 0 7px; }
.field-label:first-of-type { margin-top: 0; }
input:not([type="checkbox"]), select { min-width: 0; width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid #cdd7dd; border-radius: 9px; background: white; color: var(--ink); }
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(23,107,135,.22); outline-offset: 1px; }
.input-action-row { display: flex; align-items: stretch; gap: 8px; }
.input-action-row input, .input-action-row select { flex: 1; }
.button { border: 1px solid transparent; border-radius: 9px; min-height: 40px; padding: 9px 13px; font-weight: 750; font-size: .82rem; white-space: nowrap; }
.button-primary { background: #16708b; color: white; }
.button-primary:hover:not(:disabled) { background: #105d74; }
.button-secondary { background: #edf3f6; border-color: #d9e3e8; color: #1c3c4c; }
.button-secondary:hover:not(:disabled) { background: #e1ebf0; }
.button-quiet { background: transparent; color: inherit; border-color: #738997; }
.button-small { min-height: 32px; padding: 6px 10px; font-size: .76rem; }
.full-width { width: 100%; }
.spaced { margin-top: 9px; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px; background: #eef2f4; border-radius: 10px; }
.segment { border: 0; min-height: 40px; border-radius: 7px; background: transparent; font-size: .8rem; font-weight: 700; color: var(--muted); }
.segment.selected { background: white; color: var(--navy); box-shadow: 0 1px 5px rgba(17,37,52,.12); }
.action-row { display: flex; align-items: center; gap: 12px; }
.split-action { margin-top: 18px; }
.manual-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.button-motion { background: #e4f2f7; color: #13556d; border-color: #c7e0e9; min-height: 48px; }
.button-motion[data-manual="CLOSE"] { background: #fff0e9; color: #8a3d21; border-color: #f0d0c2; }
.safe-confirm { display: flex; gap: 10px; align-items: flex-start; padding: 12px; margin-top: 16px; background: #f6f8f9; border: 1px solid #e2e8eb; border-radius: 10px; }
.safe-confirm input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; accent-color: #176b87; }
.safe-confirm label { font-size: .78rem; line-height: 1.4; font-weight: 650; }
.inline-status { margin-top: 10px; color: var(--muted); font-size: .78rem; }
.trend-panel canvas { width: 100%; height: 230px; display: block; border: 1px solid #edf0f2; border-radius: 9px; }
.select-inline { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8rem; }
.select-inline select { width: auto; min-width: 130px; min-height: 36px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting-row.separated { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; }
.switch { position: relative; display: inline-block; width: 47px; height: 27px; flex: 0 0 auto; }
.switch input { width: 0; height: 0; opacity: 0; }
.slider { position: absolute; inset: 0; border-radius: 20px; background: #c9d3d9; cursor: pointer; transition: .15s; }
.slider::before { content: ""; width: 19px; height: 19px; position: absolute; left: 4px; top: 4px; border-radius: 50%; background: white; transition: .15s; box-shadow: 0 1px 3px #0002; }
.switch input:checked + .slider { background: #137c62; }
.switch input:checked + .slider::before { transform: translateX(20px); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.button-apply { padding-inline: 9px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar input { flex: 1; }
.debug-log { min-height: 320px; max-height: 55vh; overflow: auto; background: #101a22; color: #d6e3e9; border-radius: 10px; padding: 14px; font: .76rem/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.app-footer { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 22px; color: #7b8b95; font-size: .72rem; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; width: min(92vw, 520px); padding: 12px 14px; color: white; background: #172b38; box-shadow: 0 8px 32px #10283844; border-radius: 10px; font-size: .85rem; transition: .18s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
[hidden] { display: none !important; }
@media (max-width: 820px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 540px) {
  .app-header { align-items: flex-start; }
  .connection-box { width: 100%; }
  .connection-box #connectBtn, .connection-box #disconnectBtn { flex: 1; }
  .page-shell { padding-top: 12px; }
  .metric-card { padding: 12px; }
  .panel-heading { align-items: flex-start; }
  .panel-heading .tag { white-space: normal; text-align: center; }
  .field-pair { grid-template-columns: 1fr; gap: 0; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input { flex: 1 1 100%; }
  .select-inline { align-items: flex-start; flex-direction: column; }
  .select-inline select { width: 100%; }
  .app-footer { flex-direction: column; }
}
