:root {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: #242424;
  background: #f3f3f3;
  line-height: 1.3;
  font-size: 13px;
  --office-blue: #185abd;
  --office-blue-dark: #0f4c81;
  --office-blue-pale: #eaf2fb;
  --office-gray: #f3f2f1;
  --office-gray-2: #edebe9;
  --office-line: #d2d0ce;
  --office-line-dark: #a19f9d;
  --text: #242424;
  --muted: #605e5c;
  --danger: #a4262c;
  --danger-pale: #fde7e9;
  --ok: #107c10;
  --ok-pale: #dff6dd;
  --warning: #8a6d1d;
  --warning-pale: #fff4ce;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: #f3f3f3; }
button, input, select, textarea { font: inherit; }
button {
  min-height: 28px;
  border: 1px solid #8a8886;
  border-radius: 2px;
  padding: 4px 12px;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: #f3f2f1; border-color: #605e5c; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--office-blue); outline-offset: 1px; }
button.primary, button:not([class]), .primary {
  background: var(--office-blue);
  border-color: var(--office-blue);
  color: #fff;
}
.button-link { display: inline-flex; min-height: 28px; align-items: center; justify-content: center; border: 1px solid #8a8886; border-radius: 2px; padding: 4px 12px; color: var(--text); font-weight: 600; text-decoration: none; }
.button-link.primary { border-color: var(--office-blue); color: #fff; }
.button-link.primary:hover { background: var(--office-blue-dark); }
button.primary:hover, button:not([class]):hover, .primary:hover { background: var(--office-blue-dark); }
button.secondary { background: #fff; color: var(--text); }
button.danger, .danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover, .danger:hover { background: #8e1f25; }
button:disabled, input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: 21px; font-weight: 600; }
h2 { margin-bottom: 0; font-size: 14px; font-weight: 600; }
h3 { font-size: 13px; }
.hidden { display: none !important; }
.muted, .panel-hint { color: var(--muted); }
.error { color: var(--danger); white-space: pre-wrap; }

input, select, textarea {
  width: 100%;
  min-height: 28px;
  border: 1px solid #8a8886;
  border-radius: 0;
  padding: 3px 7px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 76px; resize: vertical; }
label { display: grid; gap: 3px; font-weight: 600; color: #323130; }

.login-shell { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #f8fbff, #dce8f5); }
.login-panel { width: min(420px, calc(100% - 32px)); background: #fff; border: 1px solid #c8c6c4; box-shadow: 0 12px 36px #0002; }
.login-brand { display: flex; align-items: center; gap: 14px; padding: 22px 26px; color: #fff; background: var(--office-blue); }
.login-brand h1 { margin: 0; font-size: 24px; }
.login-brand p { margin: 3px 0 0; color: #fff; opacity: .88; }
.login-panel form { padding: 24px 26px 26px; }
.app-mark { display: grid; place-items: center; width: 48px; height: 48px; background: #fff; color: var(--office-blue); font-size: 20px; font-weight: 700; box-shadow: 0 1px 3px #0003; }
.small-mark { width: 27px; height: 27px; font-size: 11px; }
.office-form { display: grid; gap: 12px; }

.office-header { position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 3px #0002; }
.office-titlebar { height: 42px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; color: #fff; background: var(--office-blue); }
.brand-lockup, .account-area { display: flex; align-items: center; gap: 10px; }
.brand-lockup strong { font-size: 15px; font-weight: 600; }
#environment-badge { padding: 1px 5px; border: 1px solid #ffffff80; border-radius: 2px; font-size: 9px; font-weight: 700; letter-spacing: .5px; }
#current-user { font-size: 12px; opacity: .94; }
.title-button { min-height: 26px; border-color: transparent; background: transparent; color: #fff; padding: 2px 8px; }
.title-button:hover { border-color: #ffffff60; background: #ffffff18; }
.office-tabs { height: 34px; display: flex; align-items: end; gap: 1px; padding: 0 10px; background: #fff; border-bottom: 1px solid var(--office-line); }
.office-tabs .nav { min-height: 32px; padding: 5px 17px; border: 0; border-radius: 0; background: transparent; color: #323130; font-weight: 500; }
.office-tabs .nav:hover { background: var(--office-gray); }
.office-tabs .nav.active { color: var(--office-blue); border-bottom: 3px solid var(--office-blue); background: #fff; }

.layout { width: 100%; padding: 12px 14px 30px; }
.view { max-width: 1800px; margin: 0 auto; }
.view-heading { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; padding: 6px 2px; }
.view-heading p { margin: 0; color: var(--muted); }
.compact-heading { min-height: 44px; margin-bottom: 7px; }
.view-actions { display: flex; align-items: center; gap: 6px; }
.breadcrumb-bar { height: 30px; display: flex; align-items: center; border-bottom: 1px solid var(--office-line); }
.text-button { min-height: 24px; padding: 1px 3px; border: 0; background: transparent; color: var(--office-blue); }
.text-button:hover { background: transparent; text-decoration: underline; }

.office-panel, .table-panel { margin-bottom: 10px; background: #fff; border: 1px solid var(--office-line); }
.utility-download-details { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 8px 10px; font-size: 11px; }
.utility-download-details > span { white-space: nowrap; }
.utility-download-details .utility-checksum { flex: 1 1 100%; white-space: normal; }
.utility-checksum code { overflow-wrap: anywhere; }
.panel-heading { min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 9px; background: var(--office-gray); border-bottom: 1px solid var(--office-line); }
.panel-heading > div:not(.metric-controls) { display: grid; gap: 2px; }
.toolbar-heading { align-items: end; }
.panel-hint { font-size: 11px; font-weight: 400; }
.table-scroll { width: 100%; overflow: auto; }
.compact-table-height { max-height: 270px; }

.data-table { width: 100%; border-collapse: collapse; table-layout: auto; font-size: 12px; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 5px 7px; border-right: 1px solid #dedede; border-bottom: 1px solid #a19f9d; background: #f3f2f1; color: #323130; text-align: left; font-weight: 600; white-space: nowrap; }
.data-table td { height: 30px; padding: 4px 7px; border-right: 1px solid #edebe9; border-bottom: 1px solid #edebe9; vertical-align: middle; }
.data-table tbody tr:nth-child(even) { background: #faf9f8; }
.data-table tbody tr:hover { background: #eaf2fb; }
.data-table .clickable-row { cursor: pointer; }
.data-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .actions-cell { width: 1%; white-space: nowrap; text-align: right; }
.data-table .empty-cell { height: 66px; color: var(--muted); text-align: center; }
.data-table code { font-family: Consolas, monospace; font-size: 11px; }
.table-action { min-height: 24px; padding: 2px 8px; color: var(--office-blue); border-color: #8aadd5; }

.status { display: inline-flex; align-items: center; gap: 4px; min-height: 20px; padding: 1px 7px; border: 1px solid #c8c6c4; border-radius: 10px; background: #f3f2f1; color: #605e5c; font-size: 11px; font-weight: 600; white-space: nowrap; }
.status.online { border-color: #8bd18b; background: var(--ok-pale); color: #0b6a0b; }
.status.alarm { border-color: #d8797e; background: var(--danger-pale); color: var(--danger); }
.status.warning { border-color: #e6c458; background: var(--warning-pale); color: var(--warning); }

.summary-strip { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); margin-bottom: 10px; border: 1px solid var(--office-line); background: #fff; }
.summary-cell { min-width: 0; padding: 7px 10px; border-right: 1px solid var(--office-line); }
.summary-cell:last-child { border-right: 0; }
.summary-cell span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .25px; }
.summary-cell strong { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 600; white-space: nowrap; }

.station-toolbar { display: flex; align-items: stretch; gap: 0; min-height: 78px; margin-bottom: 10px; border: 1px solid var(--office-line); background: #fff; overflow-x: auto; }
.station-tool { min-width: 180px; display: grid; grid-template-columns: 34px 1fr; grid-template-rows: 1fr 1fr; align-items: center; column-gap: 7px; padding: 9px 14px; border: 0; border-right: 1px solid var(--office-line); border-radius: 0; background: #fff; text-align: left; }
.station-tool:hover { background: var(--office-blue-pale); }
.station-tool .button-icon { grid-row: 1 / 3; font-size: 25px; text-align: center; }
.station-tool strong { align-self: end; color: #323130; font-size: 13px; }
.station-tool small { align-self: start; color: var(--muted); font-size: 10px; font-weight: 400; }
.station-landing { min-height: 190px; display: grid; place-content: center; gap: 5px; border: 1px dashed var(--office-line-dark); background: #faf9f8; color: var(--muted); text-align: center; }
.station-landing strong { color: #323130; }

.station-workspace { display: grid; grid-template-columns: 238px minmax(0, 1fr); align-items: start; gap: 10px; }
.station-side-rail { position: sticky; top: 88px; max-height: calc(100vh - 100px); overflow: auto; border: 1px solid var(--office-line-dark); background: #fff; box-shadow: 0 1px 2px #00000012; }
.station-main-workspace { min-width: 0; }
.station-main-workspace .station-landing { margin: 0; }
.station-side-rail .summary-strip { grid-template-columns: 1fr; margin: 0; border: 0; border-bottom: 1px solid var(--office-line-dark); }
.station-side-rail .summary-cell { padding: 8px 11px; border-right: 0; border-bottom: 1px solid var(--office-line); }
.station-side-rail .summary-cell:last-child { border-bottom: 0; }
.station-side-rail .station-toolbar { display: grid; min-height: 0; margin: 0; border: 0; overflow: visible; }
.station-side-rail .station-tool { width: 100%; min-width: 0; min-height: 58px; grid-template-columns: 34px minmax(0, 1fr); padding: 7px 10px; border-right: 0; border-bottom: 1px solid var(--office-line); }
.station-side-rail .station-tool:last-child { border-bottom: 0; }
.station-side-rail .station-tool .button-icon { font-size: 22px; }
.station-side-rail .active-station-tool { background: var(--office-blue-pale); box-shadow: inset 4px 0 var(--office-blue); }

.workspace-grid { display: grid; gap: 10px; }
.two-columns { grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); }
.admin-grid { grid-template-columns: minmax(260px, 1fr) minmax(520px, 2fr); }
.full-width-field { grid-column: 1 / -1; }
select[multiple] { min-height: 9rem; padding: 6px; }
select[multiple] option { padding: 5px 7px; }
.history-panel { overflow: hidden; }
.metric-controls, .toolbar-heading > .metric-controls { display: flex; align-items: end; gap: 5px; flex-wrap: wrap; }
.metric-controls label { gap: 1px; font-size: 10px; }
.metric-controls select { min-width: 110px; }
.chart-wrap { height: 182px; padding: 7px 8px 0; }
#metric-chart { width: 100%; height: 100%; background: #f7fafb; border: 1px solid var(--office-line); }
.chart-plot { fill: #fbfdfe; }
.chart-band { fill: #edf5f8; }
.chart-band.alternate { fill: #f8fbfc; }
.chart-grid-minor { stroke: #d7e4e9; stroke-width: .65; vector-effect: non-scaling-stroke; }
.chart-grid-major { stroke: #9fb4bd; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-axis { stroke: #405761; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.chart-range-band { fill: #5b9bd533; stroke: #5b9bd566; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-line { fill: none; stroke: var(--office-blue); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.chart-y-label, .chart-x-label { fill: #435660; font: 11px Segoe UI, sans-serif; }
.chart-title { fill: #123f5a; font: 700 13px Segoe UI, sans-serif; }
.chart-last-point { fill: #fff; stroke: var(--office-blue); stroke-width: 3; vector-effect: non-scaling-stroke; }
.chart-last-label { fill: #123f5a; paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; font: 700 12px Consolas, monospace; }
.chart-legend text { fill: #52646d; font: 10px Segoe UI, sans-serif; }
.status-line { min-height: 25px; padding: 5px 9px; color: var(--muted); background: #faf9f8; border-top: 1px solid var(--office-line); font-size: 11px; }

.ribbon-groups { display: flex; align-items: stretch; min-height: 78px; border-bottom: 1px solid var(--office-line); background: #fff; overflow-x: auto; }
.ribbon-group { display: grid; grid-template-rows: 1fr auto; min-width: max-content; padding: 6px 8px 3px; border-right: 1px solid var(--office-line); }
.ribbon-actions { display: flex; align-items: stretch; gap: 4px; }
.ribbon-label { padding-top: 3px; color: var(--muted); font-size: 10px; text-align: center; }
.ribbon-button { min-height: 42px; padding: 4px 9px; border-color: transparent; background: #fff; font-weight: 500; }
.ribbon-button:hover { border-color: #c8c6c4; background: var(--office-gray); }
.ribbon-button.danger { background: var(--danger-pale); border-color: #d8797e; color: var(--danger); }
.button-icon { display: block; color: var(--office-blue); font-size: 18px; line-height: 17px; }
.inline-ribbon-form label { width: 72px; font-size: 10px; }
.inline-ribbon-form input { text-align: center; }

.dense-form-row { display: flex; align-items: end; gap: 8px; padding: 7px 9px; border-bottom: 1px solid var(--office-line); background: #faf9f8; }
.dense-form-row > strong { align-self: center; min-width: 180px; }
.dense-form-row label { min-width: 135px; font-size: 11px; }
.dense-form-row input, .dense-form-row select { min-height: 26px; }
.warning-row { background: var(--warning-pale); }
.subsection-title { padding: 5px 8px; border-bottom: 1px solid var(--office-line); background: var(--office-gray); font-weight: 600; }
.info-row { display: flex; justify-content: space-between; gap: 15px; padding: 8px 9px; border-bottom: 1px solid var(--office-line); }
.permission-editor { border-top: 1px solid #fff; }
.permission-editor .dense-form-row { border-bottom: 1px solid var(--office-line); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 9px; }
.compact-form { padding: 10px; align-items: end; }
.compact-form button { align-self: end; }
.dialog-title { margin: -14px -14px 3px; padding: 10px 14px; border-bottom: 1px solid var(--office-line); background: var(--office-gray); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 6px; padding-top: 6px; }
.office-dialog { width: min(700px, calc(100% - 28px)); padding: 14px; border: 1px solid #8a8886; border-radius: 2px; box-shadow: 0 16px 50px #0005; }
.workspace-dialog { width: min(1450px, calc(100% - 26px)); height: min(900px, calc(100vh - 26px)); max-width: none; max-height: none; padding: 0; overflow: hidden; border: 1px solid #605e5c; border-radius: 2px; box-shadow: 0 20px 70px #0006; }
.workspace-dialog-shell { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.workspace-dialog-header { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 12px; color: #fff; background: var(--office-blue); }
.workspace-dialog-header h2 { margin: 0 0 2px; font-size: 16px; }
.workspace-dialog-header p { margin: 0; font-size: 11px; opacity: .9; }
.workspace-dialog-header .secondary { border-color: #ffffff80; background: transparent; color: #fff; }
.workspace-dialog-header .secondary:hover { background: #ffffff18; }
.workspace-dialog-body { overflow: auto; padding: 9px; background: #f3f3f3; }
.workspace-dialog-footer { min-height: 42px; display: flex; justify-content: flex-end; align-items: center; padding: 6px 9px; border-top: 1px solid var(--office-line); background: #fff; }
.dialog-table-height { height: calc(100vh - 155px); min-height: 360px; }
.dialog-chart { height: calc(100vh - 195px); min-height: 360px; }
dialog::backdrop { background: #0006; }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 100; max-width: 480px; padding: 8px 12px; border-left: 4px solid #62a5e6; background: #323130; color: #fff; box-shadow: 0 8px 24px #0004; }

@media (max-width: 1180px) {
  .station-workspace { display: block; }
  .station-side-rail { position: static; max-height: none; overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .station-side-rail .summary-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 10px; border: 1px solid var(--office-line); }
  .station-side-rail .summary-cell { border-right: 1px solid var(--office-line); border-bottom: 1px solid var(--office-line); }
  .station-side-rail .summary-cell:nth-child(3n) { border-right: 0; }
  .station-side-rail .summary-cell:nth-last-child(-n + 3) { border-bottom: 0; }
  .station-side-rail .station-toolbar { display: flex; min-height: 68px; margin-bottom: 10px; border: 1px solid var(--office-line); overflow-x: auto; }
  .station-side-rail .station-tool { width: auto; min-width: 175px; min-height: 66px; border-right: 1px solid var(--office-line); border-bottom: 0; }
  .station-side-rail .station-tool:last-child { border-right: 0; }
  .station-side-rail .active-station-tool { box-shadow: inset 0 -3px var(--office-blue); }
}

@media (max-width: 1000px) {
  .summary-strip { grid-template-columns: repeat(3, 1fr); }
  .summary-cell:nth-child(3) { border-right: 0; }
  .two-columns, .admin-grid { grid-template-columns: 1fr; }
  .dense-form-row { flex-wrap: wrap; }
}

@media (max-width: 700px) {
  :root { font-size: 12px; }
  .office-titlebar { height: 38px; }
  #current-user { display: none; }
  .office-tabs { padding: 0 3px; overflow-x: auto; }
  .office-tabs .nav { padding: 5px 10px; }
  .layout { padding: 8px 7px 56px; }
  .view-heading { align-items: flex-start; }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .summary-cell:nth-child(2n) { border-right: 0; }
  .station-side-rail .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .station-side-rail .summary-cell { border-right: 1px solid var(--office-line); border-bottom: 1px solid var(--office-line); }
  .station-side-rail .summary-cell:nth-child(3n) { border-right: 1px solid var(--office-line); }
  .station-side-rail .summary-cell:nth-child(2n) { border-right: 0; }
  .station-side-rail .summary-cell:nth-last-child(-n + 3) { border-bottom: 1px solid var(--office-line); }
  .station-side-rail .summary-cell:nth-last-child(-n + 2) { border-bottom: 0; }
  .toolbar-heading { align-items: flex-start; flex-direction: column; }
  .station-tool { min-width: 155px; }
  .metric-controls { width: 100%; }
  .metric-controls label { flex: 1; min-width: 100px; }
  .chart-wrap { height: 150px; }
  .form-grid { grid-template-columns: 1fr; }
  .dense-form-row > strong { width: 100%; }
  .workspace-dialog { width: 100%; height: 100%; border: 0; }
  .workspace-dialog-body { padding: 4px; }
  .dialog-table-height { height: auto; min-height: 260px; max-height: 45vh; }
}
