/* Shared desktop design. All phone/tablet rules remain in the established stylesheets. */
@media (min-width:901px) {
  /* One outer width for header, status, forms and information sections. */
  body {--portal-content-width:1280px}
  body #main {--field-width:420px;--space:24px;box-sizing:border-box;max-width:calc(var(--portal-content-width) + 84px);padding-left:42px!important;padding-right:42px!important}
  body .portal-header {box-sizing:border-box;max-width:calc(var(--portal-content-width) + 84px)}
  body #main h1 {font-size:32px;line-height:1.2;font-weight:650;letter-spacing:-.8px}
  body #main .page-title {margin:24px 0}
  body #main .page-title .eyebrow {font-size:13px;letter-spacing:1.5px}
  body #main :is(.card,.control-card) {box-sizing:border-box;min-width:0;border-radius:20px;border-color:var(--line);padding:24px}
  body #main :is(.card,.control-card) :is(h2,h3) {font-size:20px;font-weight:650;line-height:1.4}
  body #main :is(input,select,button,[tabindex],section[id]) {scroll-margin-top:110px}
  body #main :is(#overview-page,#sensors-page,#settings-page,.connection-stages,.vehicle-grid,.boxes-layout,.user-management) {width:100%;max-width:var(--portal-content-width)}
  body #main :is(.settings-grid,.box-list,.vehicle-grid) {gap:24px}
  body #main :is(.form-card,.user-form,.portal-update-card) {width:100%;max-width:var(--portal-content-width);margin:24px 0}
  body #main > .form-card>form {max-width:var(--field-width)}
  body #main .user-fields {gap:24px}
  body #main .field {margin:0 0 20px}
  body #main .field label,body #main .control-card label {font-size:14px;font-weight:650;line-height:1.5}
  body #main .field label {margin:0 0 8px}
  body #main .field :is(input:not([type=checkbox]):not([type=radio]),select),body #main .control-card select {
    min-height:48px;border-radius:12px;border-color:var(--line);font-size:16px;box-sizing:border-box;
  }
  body #main :is(a,button):is(.primary,.secondary,.danger),
  body #main :is(button[type=submit],#heat-save,button[data-discard],button.draft-discard) {
    display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;
    width:auto;max-width:100%;min-height:48px;margin:0;padding:12px 18px;
    border-radius:12px;font-family:inherit;font-size:16px;font-weight:600;line-height:1.4;white-space:normal;
  }
  body #main .desktop-actions {display:flex;flex-wrap:wrap;align-items:center;gap:12px;margin:0}
  body #main .desktop-actions>button {flex:0 1 auto;align-self:stretch;margin:0}
  body #main :is(.action-feedback,[data-form-status],#alarm-save-state) {text-align:left;align-self:flex-start;min-height:0;line-height:1.5;margin:12px 0 0!important}
  body #main :is(.action-feedback,[data-form-status]):empty {display:none}
  body #main :is(.unified-switch,.switch-label) {width:100%;max-width:var(--field-width);gap:12px;min-height:44px}
  body #main .unified-switch .switch-caption {flex:1;min-width:0}
  body #main .unified-switch .switch-text {flex:none}
  body #main .alarm-switch input[type=checkbox] {width:46px;min-width:46px;max-width:46px;height:26px;min-height:26px;flex:0 0 46px;background:#adc1d0;border-radius:20px}
  body #main .alarm-switch input[type=checkbox]::before {width:20px;height:20px;left:3px;top:3px;transform:none}
  body #main .alarm-switch input[type=checkbox]:checked {background:var(--blue)}
  body #main .alarm-switch input[type=checkbox]:checked::before {left:23px;transform:none}

  /* Shared outer edges; compact fields live inside two equal columns. */
  body #main :is(#heat-settings,#schedule-editor) {width:100%;max-width:var(--portal-content-width);padding:24px;margin:24px 0;gap:0}
  body #main #heat-settings .heat-settings-grid,body #main #schedule-form .schedule-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:24px}
  body #main .heat-settings-grid>.control-card {padding:0;margin:0;border:0;border-radius:0;background:transparent;box-shadow:none}
  body #main #climate-panel {width:100%;max-width:var(--portal-content-width);padding:24px;gap:20px}
  body #main #climate-panel>form {width:100%;max-width:var(--field-width)}
  body #main #control-page :is(#heat-panel,#water-panel,#heat-energy,#climate-panel) :is(label,.current,.stepper),
  body #main #climate-summary {box-sizing:border-box;width:100%;max-width:var(--field-width);min-width:0}
  body #main #control-page .current {margin:0;padding:12px 14px;border-radius:12px;line-height:1.5}
  body #main #control-page form {gap:16px}
  body #main #control-page fieldset {gap:20px}
  body #main #heat-energy {padding:24px 0;margin:24px 0 0}
  body #main #heat-energy .current {margin:0 0 20px;overflow-wrap:break-word}
  body #main #heat-summary {gap:24px;padding:16px 18px;margin:20px 0}
  body #main #climate-summary {margin:0;padding:14px;border-radius:12px}
  body #main #climate-panel :is(.control-availability,.draft-note) {max-width:var(--field-width);line-height:1.5;margin:0}
  body #main #climate-panel .desktop-actions>button {flex:1 1 170px;padding:12px;min-height:48px}
  body #main .device-status-grid .device-setting {order:1}
  body #main .device-status-grid .device-freshness {order:2}
  body #main .device-status-grid .device-power-note {order:3;margin:0 0 12px}
  body #main .device-status-grid .device-planning {order:4}
  body #main .device-status-grid [data-device-control] {order:5}

  body #main #schedule-editor h2 {margin:0 0 24px}
  body #main #schedule-form {margin:0}
  body #main #schedule-form>.toggle {margin:16px 0 24px!important;min-height:44px}
  body #main #schedule-form [data-field] {min-width:0;margin:0}
  body #main #schedule-form .schedule-grid>[data-field] {grid-column:auto}
  body #main #schedule-form .schedule-grid>:is([data-field=name],[data-field=weekdays]) {grid-column:1/-1}
  body #main #schedule-form label {margin:0 0 8px;max-width:none}
  body #main #schedule-form .time-picker {max-width:var(--field-width);width:100%}
  body #main #schedule-form .time-picker>input {font-size:16px!important;letter-spacing:normal}
  body #main #schedule-form .time-open {font-size:16px;border-radius:12px;min-height:48px}
  body #main #schedule-form .schedule-grid>[data-field]>:is(input,select) {width:100%;max-width:var(--field-width);min-height:48px;border-radius:12px}
  body #main #schedule-form .stepper {max-width:var(--field-width)!important;width:100%;margin:0}
  body #main #schedule-form .choices {margin-top:0}
  body #main #schedule-form #id_weekdays {max-width:640px}
  body #main #schedule-form [data-field=weekdays] .actions {margin:12px 0 0;gap:12px}
  body #main #schedule-form .planning-help {margin:24px 0}
  body #main #schedule-form .planning-energy {padding-top:24px;margin:0 0 24px}
  body #main #schedule-form #id_energy {max-width:var(--field-width);min-height:48px}
  body #main #schedule-form .planning-energy .hint {margin-top:8px}
  body #main #schedule-form>.hint {margin:0 0 20px}
  body #main #schedule-editor~:is(.schedule-list,.planning-rules) {max-width:var(--portal-content-width)}
  body #main :is(.mode-tabs,.planning-tabs) {max-width:540px;margin:24px 0}
  body #main nav.planning-tabs a {min-height:64px;padding:10px}

  /* Alarms use the same form width; switches and units belong to their own fields. */
  body #main .alarm-page {width:100%;max-width:var(--portal-content-width);padding-top:24px}
  body #main .alarm-page>.card {padding:24px;margin:24px 0 0}
  body #main .alarm-grid {gap:24px;margin:24px 0}
  body #main :is(.alarm-row,.automation-panel) {padding:20px;border-radius:16px}
  body #main .alarm-row .alarm-switch {width:100%;gap:10px}
  body #main .alarm-row .alarm-switch label {font-size:14px}
  body #main .alarm-page .alarm-input-wrap {width:100%;max-width:none;height:48px}
  body #main .alarm-page .alarm-input-wrap input[type=number] {flex:1 1 0;width:0;max-width:none}
  body #main .alarm-page .alarm-save {align-items:flex-start;gap:12px;margin-top:24px;padding-top:24px}
  body #main .alarm-page .alarm-save p {width:100%;text-align:left;margin:0!important}
  body #main .automation-grid {gap:24px;margin-top:24px}
  body #main .automation-toggle {max-width:var(--field-width)}
  body #main .automation-fields {grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}
  body #main .automation-fields>label:last-child {grid-column:1/-1;max-width:var(--field-width);width:100%}
  body #main .automation-fields :is(.automation-input,select) {height:48px}
  body #main .alarm-page .automation-input input[type=number] {flex:1 1 0;width:0;max-width:none}
  body #main .automation-details {margin-top:20px}
  body #main .alarm-page .alarm-explanation {margin:0 0 20px}

  /* Information cards and administrative actions keep a calm, regular rhythm. */
  body #main .box-list>.box-card {gap:12px;padding:24px}
  body #main .box-card>:is(h2,p) {margin:0}
  body #main .box-card>.status {margin:0 0 4px}
  body #main .box-card .box-actions {display:flex;gap:12px;flex-wrap:wrap;margin-top:auto;padding-top:12px}
  body #main .box-actions>.secondary {flex:0 1 auto;margin:0;min-height:48px}
  body #main .settings-grid .actions {margin-top:auto;padding-top:20px}
  body #main .settings-grid .control-card {gap:12px}
  body #main .settings-grid .control-card>:is(h2,p) {margin:0}
  body #main #recognized-devices {margin-top:8px}
  body #main #sensors-page>:is(details,form.control-card) {width:100%;max-width:var(--portal-content-width);margin:24px 0}
  body #main #sensors-page>form.control-card fieldset {gap:20px}
  body #main #sensors-page>form.control-card p {margin:0}
  body #main .user-search {align-items:flex-end;gap:16px;margin:0 0 24px}
  body #main .user-search .field {margin:0;min-width:0;flex:1}
  body #main .user-search button {align-self:flex-end;margin:0}
  body #main .user-search input {min-height:48px}
  body #main .user-row {padding:16px 0}
}
@media (min-width:901px) and (max-width:1100px) {
  body #main #schedule-form .schedule-grid,body #main #heat-settings .heat-settings-grid {grid-template-columns:minmax(0,1fr)}
  body #main #water-panel {grid-column:auto;grid-row:auto;border-top:1px solid var(--line);padding-top:24px}
  body #main .alarm-grid {grid-template-columns:minmax(0,1fr)}
}

@media(min-width:901px){
 body #main #sensors-page .measurement-mode {width:100%;max-width:52rem;}
 body #main #sensors-page [data-kind="sensor_measure_all"] [data-feedback] {margin-top:16px;}
 body #main .extended-controls {width:100%;max-width:var(--portal-content-width);}
 body #main .extended-controls .extended-grid {max-width:900px;}
}
