/* Focus.Cloud.Web stylesheet: the React site's index.css as plain CSS. The block below stands in
   for the Tailwind 4 preflight the React build imported (no utilities were used); everything after
   it is the original cascade, in its original order, followed by the Blazor-specific additions. */

/* ---- preflight (the subset the layout relies on) ---- */
*,
::before,
::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: currentColor;
  margin: 0;
  padding: 0;
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  line-height: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: inherit;
  font-weight: inherit;
}

ol,
ul {
  list-style: none;
}

sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
  top: -0.5em;
}

button,
input,
optgroup,
select,
textarea {
  font: inherit;
  font-feature-settings: inherit;
  font-variation-settings: inherit;
  letter-spacing: inherit;
  color: inherit;
  background-color: transparent;
  border-radius: 0;
}

button,
[type='button'],
[type='submit'] {
  appearance: button;
  cursor: pointer;
}

:disabled {
  cursor: default;
}

a {
  color: inherit;
  text-decoration: inherit;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* ---- index.css (verbatim, minus the tailwind import) ---- */

:root {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #1c1c1e;
  background: #f5f5f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.app-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.app-header h1 {
  font-size: 1.5rem;
}

.version {
  font-size: 0.85rem;
  color: #6b6b70;
}

.error {
  color: #b00020;
  background: #fde8ea;
  padding: 8px 12px;
  border-radius: 6px;
}

.zone {
  background: #fff;
  border: 1px solid #e3e3e6;
  border-radius: 10px;
  padding: 16px;
  margin-top: 16px;
}

.zone h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.rules {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.rule {
  padding: 8px 0;
  border-top: 1px solid #f0f0f2;
}

.empty {
  color: #8a8a8e;
  font-style: italic;
}

.rule-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.rule-window {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.rule-recurrence {
  color: #4a4a4e;
}

.rule-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

button {
  font: inherit;
  padding: 6px 12px;
  border: 1px solid #c7c7cc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #f0f0f2;
}

.add-rule {
  border-style: dashed;
}

.rule-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: #fafafa;
  border: 1px solid #e3e3e6;
  border-radius: 8px;
}

.field-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: #4a4a4e;
}

input,
select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid #c7c7cc;
  border-radius: 6px;
}

.weekday-picker {
  border: 1px solid #e3e3e6;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.weekday {
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.editor-actions {
  display: flex;
  gap: 8px;
}

/* --- two-pane editor --- */

.loading {
  color: #8a8a8e;
}

.two-pane {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 880px) {
  .two-pane {
    grid-template-columns: 1fr;
  }
}

.rules-pane {
  display: flex;
  flex-direction: column;
}

.rule-tag {
  font-size: 0.72rem;
  color: #7a4d00;
  background: #fff3e0;
  border-radius: 4px;
  padding: 1px 6px;
}

/* --- draft bar + queue --- */

.draft-bar {
  background: #fff;
  border: 1px solid #e3e3e6;
  border-radius: 10px;
  padding: 12px;
  margin: 16px 0;
}

.draft-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.current-version {
  font-weight: 600;
}

.draft-state {
  color: #6b6b70;
  font-size: 0.85rem;
}

.draft-notice {
  color: #13602a;
  font-size: 0.85rem;
  margin: 8px 0 0;
}

.queue {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.queue-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  background: #faf7ef;
  border: 1px solid #ecdfba;
  border-radius: 6px;
  padding: 4px 8px;
}

.queue-index {
  font-weight: 600;
  color: #7a4d00;
}

.queue-when {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.queue-at {
  color: #8a8a8e;
  margin-left: auto;
}

.queue-entry {
  cursor: context-menu;
}

.context-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.context-menu {
  position: fixed;
  z-index: 50;
  list-style: none;
  margin: 0;
  padding: 4px;
  min-width: 160px;
  background: #fff;
  border: 1px solid #d0d0d4;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

.context-menu button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: 6px;
}

.context-menu button:hover {
  background: #f0f0f2;
}

.context-menu-disabled {
  padding: 6px 10px;
  color: #9a9aa0;
  font-size: 0.85rem;
}

/* --- week (7-day) calendar --- */

.week-view {
  background: #fff;
  border: 1px solid #e3e3e6;
  border-radius: 10px;
  padding: 12px;
}

.week-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.week-range {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.week-today {
  margin-left: auto;
}

.week-grid {
  display: grid;
  grid-template-columns: 40px repeat(7, minmax(0, 1fr));
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
}

.day-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border-left: 1px solid #f0f0f2;
  border-bottom: 1px solid #eee;
  font-size: 0.8rem;
}

.day-head--today {
  background: #eef4ff;
}

.day-head .dow {
  color: #6b6b70;
}

.day-head .dom {
  font-weight: 600;
}

.day-add {
  padding: 0 8px;
  line-height: 1.5;
}

.time-gutter {
  position: relative;
}

.hour-label {
  position: absolute;
  right: 4px;
  font-size: 0.62rem;
  color: #9a9aa0;
  transform: translateY(-50%);
  font-variant-numeric: tabular-nums;
}

.day-column {
  position: relative;
  border-left: 1px solid #f0f0f2;
  overflow: hidden;
}

.hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid #f5f5f7;
}

.occ {
  position: absolute;
  overflow: hidden;
  border: 1px solid;
  border-radius: 4px;
  padding: 1px 3px;
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.1;
  text-align: left;
  display: flex;
  flex-direction: column;
}

.occ:not(:disabled) {
  cursor: pointer;
}

.occ-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.occ-time {
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

/* Flight-style next-day marker on a cross-midnight window's end time. */
.day-plus {
  font-size: 0.7em;
  font-weight: 600;
  opacity: 0.65;
  margin-left: 1px;
}

.occ--recurring {
  background: #e8f0fe;
  border-color: #9bb8f0;
  color: #1b3a7a;
}

.occ--oneoff {
  background: #e9f9ec;
  border-color: #86d39a;
  color: #13602a;
}

.occ--exception {
  background: #fff3e0;
  border-color: #f0c067;
  color: #7a4d00;
  border-style: dashed;
}

.occ--continuation {
  opacity: 0.85;
  border-top-style: dashed;
}

.occ-editor {
  margin-bottom: 10px;
}

.occ-editor-head {
  font-size: 0.9rem;
}

/* --- Calendar (materialized occurrence grid) --- */

.schedule-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 880px) {
  .schedule-layout {
    grid-template-columns: 1fr;
  }
}

.calendar {
  background: #fff;
  border: 1px solid #e2e2e6;
  border-radius: 12px;
  overflow: hidden;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #ececed;
}

.calendar-nav button {
  border: 1px solid #d0d0d4;
  background: #fafafb;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.9rem;
}

.calendar-nav button:hover {
  background: #f0f0f2;
}

.calendar-day-label {
  margin-left: auto;
  font-weight: 600;
  font-size: 0.95rem;
}

.calendar-scroll {
  max-height: 70vh;
  overflow-y: auto;
}

.day-cal {
  position: relative;
  display: flex;
}

.day-cal-gutter {
  position: relative;
  width: 52px;
  flex: 0 0 52px;
  border-right: 1px solid #ececed;
}

.day-cal-hour-label {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 0.72rem;
  color: #8a8a90;
  font-variant-numeric: tabular-nums;
}

.day-cal-canvas {
  position: relative;
  flex: 1 1 auto;
  touch-action: none;
}

.day-cal-gridline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid #f1f1f3;
  pointer-events: none;
}

.day-cal-gridline-major {
  border-top-color: #e3e3e7;
}

.day-cal-block {
  position: absolute;
  left: 6px;
  right: 10px;
  border: 1px solid;
  border-radius: 7px;
  padding: 3px 7px;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.78rem;
  line-height: 1.15;
  user-select: none;
}

.day-cal-block-title {
  font-weight: 600;
}

.day-cal-block-time {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.day-cal-block-badge {
  align-self: flex-start;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.8;
}

.day-cal-block-selected {
  outline: 2px solid #111;
  outline-offset: 1px;
  z-index: 3;
}

.day-cal-preview {
  position: absolute;
  left: 6px;
  right: 10px;
  border: 2px dashed #2563eb;
  background: rgba(37, 99, 235, 0.12);
  border-radius: 7px;
  pointer-events: none;
  z-index: 4;
}

.calendar-hint {
  margin: 0;
  padding: 8px 14px;
  font-size: 0.78rem;
  color: #555;
  border-bottom: 1px solid #f0f0f2;
}

.calendar-hint-muted {
  color: #9a9aa0;
}

.occ-popover {
  border-bottom: 1px solid #e6e6ea;
  background: #fbfbfd;
  padding: 10px 14px;
}

.occ-popover-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.occ-popover-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.occ-popover-close {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #888;
}

.occ-popover-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.occ-popover-kind {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #9a9aa0;
}

.occ-popover-actions button {
  border: 1px solid #d0d0d4;
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.85rem;
}

.occ-popover-actions button.danger {
  border-color: #e0a3a3;
  color: #b00020;
}

.occ-popover-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
}

/* --- Rules view (recurring rules per zone type) --- */

.rules {
  background: #fff;
  border: 1px solid #e2e2e6;
  border-radius: 12px;
  padding: 14px 16px;
}

.rules-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rules-head h2 {
  font-size: 1.05rem;
  margin: 0;
}

.rules-head button {
  border: 1px solid #d0d0d4;
  background: #fafafb;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.85rem;
}

.rules-group h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #8a8a90;
  margin: 16px 0 6px;
}

.rules-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid #ececed;
  border-radius: 8px;
  flex-wrap: wrap;
}

.rule-times {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.88rem;
}

.rule-desc {
  font-size: 0.85rem;
  color: #555;
}

.rule-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.rule-actions button,
.rule-form-actions button {
  border: 1px solid #d0d0d4;
  background: #fff;
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 0.82rem;
}

.rule-actions button.danger {
  border-color: #e0a3a3;
  color: #b00020;
}

.rule-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid #d8d8dc;
  border-radius: 8px;
  background: #fbfbfd;
  margin-bottom: 8px;
  width: 100%;
}

.rule-form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rule-form-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.rule-form button.ghost,
.rule-form-actions button.ghost {
  background: none;
  color: #777;
}

.empty {
  color: #9a9aa0;
  font-size: 0.9rem;
}

/* ===================== Calendar v2 polish ===================== */

.calendar-nav {
  gap: 10px;
}

.calendar-pager {
  display: flex;
  gap: 4px;
}

.calendar-pager button {
  width: 30px;
  font-size: 1.05rem;
  line-height: 1;
}

.calendar-day-label {
  margin: 0 auto 0 4px;
  font-size: 1rem;
  font-weight: 600;
  color: #1c1c1e;
}

/* Blocks: lane width/left come from inline style; clear the old fixed insets. */
.day-cal-block {
  left: auto;
  right: auto;
  padding: 2px 8px;
  gap: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.day-cal-block-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.8rem;
}

.day-cal-block-time {
  font-size: 0.74rem;
  opacity: 0.82;
}

.day-cal-block-tight {
  padding-top: 0;
  justify-content: center;
}

.day-cal-block-tight .day-cal-block-title {
  font-size: 0.73rem;
}

.day-cal-block-cont {
  font-weight: 400;
  opacity: 0.6;
  font-size: 0.72rem;
}

.day-cal-block-badge {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(0, 0, 0, 0.12);
  padding: 0 4px;
  border-radius: 3px;
}

/* Current-time indicator */
.day-cal-now {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px solid #ef4444;
  z-index: 6;
  pointer-events: none;
}

.day-cal-now-dot {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
}

/* Incoming (pending) occurrences, ghosted behind live blocks */
.day-cal-ghost {
  position: absolute;
  left: 8px;
  right: 12px;
  border: 1.5px dashed;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.015);
  opacity: 0.7;
  z-index: 1;
  padding: 2px 8px;
  box-sizing: border-box;
  pointer-events: none;
}

.day-cal-ghost-label {
  font-size: 0.72rem;
  opacity: 0.75;
  font-style: italic;
}

/* Hover-revealed rule controls (no global edit mode) */
.rule-actions {
  opacity: 0;
  transition: opacity 0.12s ease;
}

.rule-row:hover .rule-actions,
.rule-row:focus-within .rule-actions {
  opacity: 1;
}

/* Lifecycle bar */
.draft-bar {
  background: #fff;
  border: 1px solid #e2e2e6;
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}

.draft-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}

.draft-status {
  font-weight: 600;
  font-size: 0.9rem;
}

.draft-bar button {
  border: 1px solid #d0d0d4;
  background: #fafafb;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.88rem;
}

.draft-bar button.primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.draft-bar button.primary:hover {
  background: #1d4ed8;
}

.draft-bar button.ghost {
  background: none;
  color: #666;
}

.draft-bar button:disabled {
  opacity: 0.5;
  cursor: default;
}

.draft-notice {
  margin: 0;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #15803d;
}

.draft-error {
  margin: 0;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #b00020;
}

.pending-banner {
  display: flex;
  flex-direction: column;
}

.pending-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid #f0f0f2;
  background: #fffdf5;
  font-size: 0.85rem;
}

.pending-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d97706;
  flex: 0 0 auto;
}

.pending-text {
  color: #92400e;
}

.pending-cancel {
  margin-left: auto;
  border: 1px solid #e0c08a;
  background: #fff;
  color: #92400e;
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 0.8rem;
}

/* ===================== Calendar v3 fixes ===================== */

/* Uniform hour lines; fainter half-hour lines (no arbitrary 6-hour emphasis). */
.day-cal-gridline {
  border-top-color: #e4e4e8;
}

.day-cal-gridline-half {
  border-top-color: #f2f2f5;
}

/* Occurrence popover: a floating card anchored to its block — an overlay, so it
   never reflows the grid. */
.day-cal-popover {
  position: absolute;
  right: 14px;
  width: 290px;
  max-width: calc(100% - 28px);
  z-index: 20;
}

.occ-popover {
  border: 1px solid #e0e0e5;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  padding: 12px 14px;
}

.occ-popover-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.occ-popover-actions button {
  text-align: left;
}

/* Rule rows: a stable single line with an always-present kebab menu (no
   hover-reveal, no reserved-but-invisible buttons, no size jump). */
.rule-row {
  flex-wrap: nowrap;
  padding: 7px 8px 7px 10px;
  position: relative;
  gap: 10px;
}

.rule-times {
  flex: 0 0 auto;
}

.rule-desc {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rule-actions {
  display: none;
}

.rule-menu-wrap {
  position: relative;
  margin-left: auto;
  flex: 0 0 auto;
}

.rule-kebab {
  border: none;
  background: none;
  color: #9a9aa0;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 6px;
}

.rule-kebab:hover {
  background: #ececed;
  color: #444;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.rule-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  z-index: 31;
  background: #fff;
  border: 1px solid #e0e0e5;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
  min-width: 120px;
  overflow: hidden;
}

.rule-menu button {
  border: none;
  background: none;
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}

.rule-menu button:hover {
  background: #f4f4f6;
}

.rule-menu button.danger {
  color: #b00020;
}

/* ===================== Layout v4: full-height shell ===================== */

html,
body,
#root {
  height: 100%;
}

.app-root {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f5f7;
}

.app-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 48px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid #e2e2e6;
}
.app-nav-brand {
  font-weight: 600;
  letter-spacing: 0.02em;
}
.app-nav-tabs {
  display: flex;
  gap: 4px;
}
.app-nav-tabs button {
  border: none;
  background: transparent;
  color: #6b6b70;
  padding: 6px 14px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.app-nav-tabs button:hover:not(.on) {
  background: #f0f0f2;
}
.app-nav-tabs button.on {
  background: #1c1c1e;
  color: #fff;
}

.app-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
  background: #f5f5f7;
}

/* --- Per-device roster views (Intervals, Sessions): one card per device, rows of
       time-stamped facts inside. --- */
.devices-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 48px;
  background: #f5f5f7;
}
.devices-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.devices-head h2 {
  margin: 0;
  font-size: 1.15rem;
}
.devices-empty {
  color: #6b6b70;
}
.devices-error {
  color: #b00020;
}
.devices-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.device-card {
  min-width: 240px;
  flex: 0 1 280px;
  background: #fff;
  border: 1px solid #e2e2e6;
  border-radius: 10px;
  padding: 12px 14px;
}
.device-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  margin-bottom: 8px;
}
.device-card-meta {
  color: #6b6b70;
  font-weight: 400;
  font-size: 0.85rem;
}
.device-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
}
.device-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  border-top: 1px solid #f0f0f2;
}
.device-row:first-child {
  border-top: none;
}
.device-row time {
  font-variant-numeric: tabular-nums;
  color: #3a3a3e;
}
.device-row-label {
  color: #9a9aa0;
}
.device-row-empty {
  color: #9a9aa0;
  padding: 3px 0;
}
/* Session-specific badges: what it cost, and whether it's running right now. */
.session-charge {
  color: #c2620a;
  font-variant-numeric: tabular-nums;
}
.session-live {
  color: #1a7f37;
  font-weight: 600;
}
.session-emergency {
  color: #b3261e;
  font-weight: 600;
}

/* Left: rules pane as a flush full-height column. */
.rules {
  flex: 0 0 450px;
  width: 450px;
  height: 100%;
  overflow-y: auto;
  border: none;
  border-right: 1px solid #e2e2e6;
  border-radius: 0;
  background: #fff;
  padding: 16px 16px 40px;
}

.cal-region {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
}

.cal-main {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #fff;
  border-right: 1px solid #e2e2e6;
}

.calendar-nav {
  flex: 0 0 auto;
  border-bottom: 1px solid #ececed;
}

.calendar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

/* Right: event-detail sidebar. */
.detail {
  flex: 0 0 320px;
  width: 320px;
  height: 100%;
  overflow-y: auto;
  background: #fff;
  padding: 18px 18px 40px;
}

.detail-empty {
  color: #9a9aa0;
  font-size: 0.9rem;
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.detail-title {
  font-weight: 600;
  font-size: 1rem;
}

.detail-recurring {
  margin-left: auto;
  color: #9a9aa0;
  font-size: 1rem;
}

.detail-time {
  color: #555;
  margin: 6px 0 18px;
  font-variant-numeric: tabular-nums;
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-actions button {
  border: 1px solid #d0d0d4;
  background: #fff;
  border-radius: 7px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.88rem;
  text-align: left;
}

.detail-actions button.danger {
  border-color: #e0a3a3;
  color: #b00020;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.82rem;
  color: #555;
}

.detail-field select {
  padding: 6px 8px;
  border: 1px solid #d0d0d4;
  border-radius: 6px;
}

/* Events: flat solid blocks, fixed width (left/width set inline). */
.day-cal-block {
  left: 0;
  right: auto;
  border: none;
  border-radius: 4px;
  box-shadow: none;
  color: #fff;
  padding: 2px 8px;
}

.day-cal-block-title {
  color: #fff;
  font-weight: 600;
}

.day-cal-block-time {
  color: rgba(255, 255, 255, 0.85);
}

.day-cal-block-selected {
  outline: 1.5px dashed rgba(255, 255, 255, 0.95);
  outline-offset: -3px;
}

.day-cal-block-cycle {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1;
}

/* Server-owned system block: a background fixture — visible, never a gesture
 * target (pointer events fall through to the canvas), lock badge top-right. */
.day-cal-block-system {
  pointer-events: none;
  opacity: 0.9;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0 6px,
    rgba(255, 255, 255, 0.14) 6px 12px
  );
}
.day-cal-block-lock {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 0.7rem;
  line-height: 1;
  opacity: 0.9;
}

.day-cal-ghost {
  left: 0;
  right: auto;
}

/* Floating, width-constrained unsaved/pending bar. */
.draft-bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(420px, calc(100% - 32px));
  margin: 0;
  z-index: 40;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.draft-bar-row {
  padding: 8px 12px;
}

/* Delete confirmation modal. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 20px 22px;
  width: 320px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.modal-actions .ghost {
  border: 1px solid #d0d0d4;
  background: #fff;
  border-radius: 7px;
  padding: 7px 14px;
  cursor: pointer;
}

.danger-solid {
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 7px 16px;
  cursor: pointer;
  font-weight: 600;
}

.danger-solid:hover {
  background: #b91c1c;
}

/* Right-click zone delete menu: a transparent click-catcher + a small popover
   anchored at the cursor, holding the red delete button. */
.ctx-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
}

.ctx-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #e2e2e6;
  border-radius: 9px;
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.ctx-menu .ctx-delete {
  display: block;
  width: 100%;
  white-space: nowrap;
}

/* --- Lifecycle bar + pending changes --- */

.draft-bar {
  margin: 12px 0 16px;
}

.draft-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.draft-status {
  font-weight: 600;
  font-size: 0.95rem;
}

.draft-bar-row button {
  border: 1px solid #c9c9cf;
  background: #fafafb;
  border-radius: 7px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.88rem;
}

.draft-bar-row button:disabled {
  opacity: 0.5;
  cursor: default;
}

.draft-bar-row button.ghost {
  background: none;
  color: #777;
}

.draft-notice {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: #2c6e2c;
}

.pending-banner {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pending-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  background: #fff8e6;
  border: 1px solid #f0d99a;
  border-radius: 8px;
  font-size: 0.86rem;
}

.pending-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e0a000;
}

.pending-text {
  color: #7a5b00;
}

.pending-cancel {
  margin-left: auto;
  border: 1px solid #e0c98a;
  background: #fff;
  border-radius: 6px;
  padding: 2px 9px;
  cursor: pointer;
  font-size: 0.8rem;
}

.day-cal-ghost {
  position: absolute;
  left: 6px;
  right: 10px;
  border: 1.5px dashed;
  border-radius: 7px;
  background: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.03),
    rgba(0, 0, 0, 0.03) 6px,
    rgba(0, 0, 0, 0.06) 6px,
    rgba(0, 0, 0, 0.06) 12px
  );
  opacity: 0.7;
  z-index: 1;
  padding: 2px 7px;
  font-size: 0.72rem;
  color: #555;
  box-sizing: border-box;
}

/* ===================== Rules surface v5 (click-to-edit + modal) ===================== */

/* The header "+" is a quiet icon button, not a labelled action. */
.rules-head button {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  color: #6b6b70;
}

/* Whole row is the edit target; right-click gives Delete. No persistent chrome. */
.rule-row-click {
  cursor: pointer;
}
.rule-row-click:hover {
  background: #f3f3f6;
  border-color: #dcdce0;
}

/* Server-owned system rule: read-only row, lock badge instead of affordances. */
.rule-row-locked {
  cursor: default;
  opacity: 0.85;
}
.rule-lock {
  margin-left: auto;
  font-size: 0.75rem;
  opacity: 0.6;
  line-height: 1;
}

/* Day-offset superscript (shared: rules list + time picker). */
.day-sup {
  font-size: 0.62em;
  font-weight: 700;
  opacity: 0.5;
  margin-left: 1px;
  vertical-align: super;
}

/* Right-click context menu (Delete only). */
.rule-ctx {
  position: fixed;
  z-index: 120;
  background: #fff;
  border: 1px solid #e6e6ea;
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  padding: 4px;
  min-width: 130px;
}
.rule-ctx button {
  display: flex;
  width: 100%;
  align-items: center;
  border: none;
  background: none;
  padding: 6px 10px;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
}
.rule-ctx button.danger {
  color: #c1121f;
}
.rule-ctx button.danger:hover {
  background: #fdeaec;
}

/* --- Rule modal editor --- */
.rule-modal {
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  text-align: left;
}
.rule-modal .modal-title {
  font-size: 1.05rem;
}
.rm-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rm-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #a0a0a6;
}
.rm-time {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rm-arrow {
  color: #a0a0a6;
}

/* --- TimeField: single-box, single-scroll time picker --- */
/* The wrapper IS the bordered box, so the day-offset superscript sits inside it,
   right after the time. The input is borderless and sized to its content. */
.tf {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  border: 1px solid #d7d7dc;
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  cursor: text;
}
.tf.tf-open,
.tf:focus-within {
  border-color: #1c1c1e;
  box-shadow: 0 0 0 3px rgba(28, 28, 30, 0.08);
}
.tf-input {
  font: inherit;
  font-size: 0.9rem;
  border: none;
  outline: none;
  background: none;
  padding: 0;
  width: 68px;
  font-variant-numeric: tabular-nums;
}
.tf .day-sup {
  margin-left: 2px;
}
.tf-pop {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  width: 134px;
  max-height: 212px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e2e2e7;
  border-radius: 11px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tf-row {
  flex: 0 0 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #444;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.tf-row:hover {
  background: #f3f3f6;
}
.tf-row-sel {
  background: #1c1c1e;
  color: #fff;
  font-weight: 600;
}
.rm-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #6b6b70;
}
.rm-inline input {
  width: 70px;
}

/* Segmented control (Repeat). */
.seg {
  display: inline-flex;
  background: #f0f0f3;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  align-self: flex-start;
}
.seg button {
  border: none;
  background: none;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  color: #5a5a60;
}
.seg button.on {
  background: #fff;
  color: #111;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

/* Weekday pills. */
.wd-pills {
  display: flex;
  gap: 5px;
}
.wd-pills button {
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 0.76rem;
  border: none;
  border-radius: 50%;
  background: #f0f0f3;
  color: #8a8a90;
  cursor: pointer;
}
.wd-pills button.on {
  background: #1c1c1e;
  color: #fff;
}

/* Ends row. */
.rm-ends {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rm-count {
  width: 70px;
}

.rule-modal .modal-actions {
  margin-top: 2px;
}
.rm-primary {
  background: #1c1c1e;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
}
.rm-primary:hover {
  background: #333;
}

/* ===================== Blazor port additions ===================== */

/* The nav tabs are router links here, not buttons; same look. */
.app-nav-tabs a {
  border: none;
  background: transparent;
  color: #6b6b70;
  padding: 6px 14px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.app-nav-tabs a:hover:not(.on) {
  background: #f0f0f2;
}
.app-nav-tabs a.on {
  background: #1c1c1e;
  color: #fff;
}

/* The canvas is the single gesture surface (it receives every pointer event, so OffsetX/Y are
   canvas-relative and hit-testing runs in C#); it is focusable so Delete/Escape reach it. */
.day-cal-canvas:focus {
  outline: none;
}
.day-cal-canvas > * {
  pointer-events: none;
}
.day-cal-block {
  pointer-events: none;
}

/* Session row extras: the override window and a foreign origin device. */
.session-override {
  color: #6b6b70;
  margin-left: 4px;
}
.session-origin {
  color: #9a9aa0;
  font-size: 0.72rem;
}

/* Blazor's reconnect overlay, kept quiet. */
#components-reconnect-modal {
  font-family: inherit;
}
