:root {
  --blue: #4c97d3;
  --blue-strong: #2f7fbe;
  --orange: #eab836;
  --yellow: #fddc39;
  --ink: #171a22;
  --sidebar: #1f2029;
  --sidebar-deep: #15161d;
  --muted: #667085;
  --line: #dfe5ee;
  --line-dark: #2d303b;
  --surface: #ffffff;
  --surface-soft: #f5f8fb;
  --table-head: #edf3f9;
  --success: #2ec27e;
  --danger: #e5484d;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef2f6;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: inherit;
}

code {
  background: #eef3f8;
  border: 1px solid #dbe4ee;
  border-radius: 4px;
  color: #263241;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  padding: 2px 5px;
  white-space: normal;
  word-break: break-word;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line-dark);
  color: #f4f7fb;
  min-height: 100vh;
}

.brand-block {
  align-items: center;
  border-bottom: 1px solid var(--line-dark);
  display: flex;
  gap: 12px;
  min-height: 48px;
  padding: 10px 18px;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--blue), var(--yellow));
  border-radius: 6px;
  color: #11141b;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  min-width: 44px;
}

.brand-mark.large {
  height: 42px;
  min-width: 58px;
}

.brand-logo {
  display: block;
  height: 34px;
  object-fit: contain;
  width: 44px;
}

.brand-logo.large {
  height: auto;
  width: 100%;
}

.brand-block small {
  color: #a8b0bf;
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.sidebar-nav {
  display: grid;
  gap: 2px;
  padding: 12px 0;
}

.tenant-filter {
  border-bottom: 1px solid var(--line-dark);
  display: grid;
  gap: 6px;
  padding: 12px 16px;
}

.tenant-filter label {
  color: #a8b0bf;
  font-size: 11px;
  text-transform: uppercase;
}

.tenant-filter select {
  background: #2a2d38;
  border-color: #3d4251;
  color: #ffffff;
  min-height: 34px;
}

.tenant-filter select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(76, 151, 211, 0.28);
}

.nav-item {
  align-items: center;
  color: #e9edf5;
  display: flex;
  gap: 10px;
  min-height: 42px;
  padding: 0 18px;
  text-decoration: none;
}

.nav-item:hover {
  background: #272a36;
}

.nav-item.active {
  background: var(--blue);
  color: #ffffff;
}

.nav-icon {
  align-items: center;
  border: 1px solid currentColor;
  border-radius: 4px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 750;
  height: 20px;
  justify-content: center;
  opacity: 0.9;
  width: 20px;
}

.workspace {
  background: #eef2f6;
  min-width: 0;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #d7dee8;
  display: flex;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 18px;
}

.tenant-switcher {
  align-items: center;
  color: #253044;
  display: flex;
  font-size: 14px;
  gap: 12px;
  min-width: 0;
}

.menu-mark {
  color: #273143;
  font-size: 22px;
  line-height: 1;
}

.userbar {
  align-items: center;
  display: flex;
  gap: 12px;
}

.user-chip {
  color: #253044;
  font-size: 14px;
}

.page {
  padding: 14px 24px 28px;
}

.page-header {
  align-items: end;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 12px;
  min-height: 84px;
}

.eyebrow {
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 760;
  margin: 0 0 5px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

h2 {
  font-size: 15px;
  margin: 0;
}

h3 {
  font-size: 14px;
  margin: 0 0 4px;
}

p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.metric {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 110px;
  padding: 9px 12px;
}

.metric strong {
  color: #263241;
  display: block;
  font-size: 18px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.metric.accent {
  border-color: rgba(234, 184, 54, 0.75);
  box-shadow: inset 3px 0 0 var(--orange);
}

.toolbar {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px 6px 0 0;
  display: flex;
  justify-content: space-between;
  min-height: 46px;
  padding: 7px 10px 7px 14px;
}

.toolbar-title {
  font-size: 14px;
  font-weight: 760;
}

.toolbar-actions,
.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-actions {
  justify-content: flex-end;
}

.toolbar-filter {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-filter input,
.toolbar-filter select {
  min-height: 34px;
}

.toolbar-filter input[type="search"] {
  width: 300px;
}

.toolbar-filter select {
  width: 210px;
}

.inline-filter-label {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  white-space: nowrap;
}

.inline-filter-label input {
  width: 150px;
}

.data-section {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 14px;
  overflow: hidden;
}

.toolbar + .data-section {
  border-radius: 0 0 6px 6px;
  border-top: 0;
}

.highlight-section {
  border-color: rgba(76, 151, 211, 0.45);
  box-shadow: inset 4px 0 0 var(--blue);
}

.section-head {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 42px;
  padding: 10px 14px;
}

.table-wrap {
  overflow-x: hidden;
}

table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #e5ebf3;
  font-size: 13px;
  padding: 9px 12px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.value-stack {
  display: grid;
  gap: 3px;
}

.value-stack small {
  color: var(--muted);
  font-size: 12px;
}

th {
  background: var(--table-head);
  color: #42516a;
  font-size: 12px;
  font-weight: 760;
}

tbody tr:hover {
  background: #f8fbff;
}

tbody tr:nth-child(even) {
  background: #fcfdff;
}

tbody tr:nth-child(even):hover {
  background: #f4f9ff;
}

.check-col {
  width: 42px;
}

.check-col input[type='checkbox'],
input[data-access-row] {
  height: 14px;
  min-height: 14px;
  width: 14px;
}

.row-check {
  border: 1px solid #cad3df;
  border-radius: 2px;
  display: inline-block;
  height: 14px;
  width: 14px;
}

.status-dot {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.status-dot.online {
  background: var(--success);
}

.empty-row {
  color: var(--muted);
  padding: 18px 12px;
  text-align: center;
}

.pill {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 720;
  min-height: 22px;
  padding: 2px 9px;
}

.pill.success {
  background: #e8f8f0;
  color: #19734b;
}

.pill.danger {
  background: #ffecee;
  color: #aa2530;
}

.pill.warning {
  background: #fff7dc;
  color: #7a5a08;
}

.pill.neutral {
  background: #eef2f6;
  color: #526071;
}

.form-board {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  padding: 14px;
}

.form-board.compact {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.modal-dialog {
  background: transparent;
  border: 0;
  max-height: calc(100dvh - 28px);
  max-width: min(780px, calc(100vw - 28px));
  padding: 0;
  width: 100%;
}

.modal-dialog::backdrop {
  background: rgba(18, 24, 34, 0.48);
}

.modal-card {
  background: #ffffff;
  border: 1px solid #cfd8e5;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(18, 24, 34, 0.28);
  max-height: calc(100dvh - 28px);
  overflow: hidden;
}

.modal-head {
  align-items: center;
  background: var(--table-head);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 48px;
  padding: 10px 14px;
}

.modal-head h2 {
  font-size: 15px;
}

.modal-body {
  max-height: calc(100dvh - 90px);
  overflow: auto;
  padding: 16px;
}

.modal-form-actions {
  border-top: 1px solid #e5ebf3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
  padding-top: 12px;
}

.access-log-preview {
  display: inline-flex;
  margin-left: 8px;
  vertical-align: middle;
}

.image-preview-button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  height: 44px;
  padding: 2px;
  width: 64px;
}

.image-preview-button img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.image-modal-card {
  max-width: min(92vw, 980px);
}

.image-modal-preview {
  display: block;
  max-height: 76vh;
  max-width: 100%;
  object-fit: contain;
}

.close-button {
  background: transparent;
  border-color: transparent;
  color: #42516a;
  min-height: 30px;
  padding: 4px 8px;
}

.close-button:hover {
  background: #ffffff;
  border-color: #cbd6e3;
  color: var(--blue-strong);
}

.panel,
.card,
.tool-panel {
  background: var(--surface-soft);
  border: 1px solid #dce4ee;
  border-radius: 6px;
  padding: 14px;
}

.card {
  display: grid;
  gap: 8px;
}

.tool-panel summary {
  cursor: pointer;
  font-weight: 760;
  margin-bottom: 12px;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.inline {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.period-rule-form {
  display: grid;
  gap: 12px;
}

.period-rule-row {
  align-items: center;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(145px, 0.75fr) minmax(0, 1fr);
}

.period-rule-row > label,
.period-rule-row > span {
  color: #273244;
  font-weight: 640;
}

.period-rule-row > input,
.period-rule-row > select,
.period-rule-row > textarea {
  width: 100%;
}

.period-repeat-panel[hidden] {
  display: none;
}

.period-checks {
  align-items: center;
  display: grid;
  gap: 12px 18px;
  min-width: 0;
}

.period-checks.weekly {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.period-checks.monthly {
  grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
}

.period-checks label {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  min-height: 24px;
  min-width: 0;
  white-space: nowrap;
}

.period-checks input {
  height: 14px;
  width: 14px;
}

.period-time-range {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(110px, 1fr) auto minmax(110px, 1fr);
}

.period-selector {
  align-items: stretch;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  margin: 4px 0;
}

.period-selector[hidden] {
  display: none;
}

.period-panel {
  border: 1px solid #dce4ee;
  border-radius: 4px;
  min-height: 190px;
  overflow: hidden;
}

.period-panel-head {
  align-items: center;
  background: #eef2f6;
  border-bottom: 1px solid #dce4ee;
  color: #263241;
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  min-height: 38px;
  padding: 8px 10px;
}

.period-panel-head small {
  color: var(--muted);
  font-size: 11px;
}

.period-list {
  display: grid;
  gap: 0;
  padding: 6px 0;
}

.period-row {
  align-items: center;
  color: #263241;
  display: flex;
  font-size: 13px;
  font-weight: 500;
  gap: 8px;
  min-height: 34px;
  padding: 6px 10px;
}

.period-row:hover {
  background: #f4f9ff;
}

.period-row input {
  height: 14px;
  min-height: 14px;
  width: 14px;
}

.period-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 10px;
}

.period-transfer {
  align-items: center;
  color: #ffffff;
  display: grid;
  gap: 12px;
  justify-content: center;
}

.period-transfer-button {
  align-items: center;
  background: #b6cff5;
  border: 0;
  border-radius: 4px;
  display: inline-flex;
  font-size: 20px;
  height: 36px;
  justify-content: center;
  min-height: 36px;
  padding: 0;
  width: 42px;
}

.period-transfer-button:hover,
.period-transfer-button.is-actionable {
  background: var(--blue);
}

label {
  color: #42516a;
  display: grid;
  font-size: 12px;
  font-weight: 650;
  gap: 5px;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #cfd8e5;
  border-radius: 4px;
  color: #1f2937;
  font: inherit;
  font-size: 13px;
  min-height: 34px;
  padding: 7px 9px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(76, 151, 211, 0.18);
  outline: 0;
}

textarea {
  min-height: 74px;
  resize: vertical;
}

button,
.button {
  align-items: center;
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 4px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 13px;
  font-weight: 720;
  justify-content: center;
  min-height: 34px;
  padding: 7px 13px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--blue-strong);
  border-color: var(--blue-strong);
}

button:disabled,
.button:disabled,
.button.disabled {
  background: #d9e1ea;
  border-color: #d9e1ea;
  color: #7b8796;
  cursor: not-allowed;
}

button:disabled:hover,
.button:disabled:hover,
.button.disabled:hover {
  background: #d9e1ea;
  border-color: #d9e1ea;
  color: #7b8796;
}

button.secondary,
.button.secondary,
.ghost-button {
  background: #ffffff;
  border-color: #cbd6e3;
  color: #263241;
}

button.secondary:hover,
.button.secondary:hover,
.ghost-button:hover {
  background: #f4f8fc;
  border-color: var(--blue);
  color: var(--blue-strong);
}

button.secondary:disabled,
.button.secondary:disabled,
.ghost-button:disabled,
button.secondary:disabled:hover,
.button.secondary:disabled:hover,
.ghost-button:disabled:hover {
  background: #d9e1ea;
  border-color: #d9e1ea;
  color: #7b8796;
  cursor: not-allowed;
}

.button.tiny {
  font-size: 12px;
  min-height: 28px;
  padding: 4px 9px;
}

.pagination-bar {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  margin: 10px 0 14px;
  padding: 10px 12px;
}

.pagination-bar > div {
  align-items: center;
  display: flex;
  gap: 8px;
}

.pagination-current {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.button-count {
  align-items: center;
  background: rgba(38, 50, 65, 0.09);
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  justify-content: center;
  margin-left: 7px;
  min-width: 20px;
  padding: 1px 6px;
}

.choice-list {
  border: 1px solid #dce4ee;
  border-radius: 4px;
  display: grid;
  max-height: 260px;
  overflow: auto;
}

.choice-row {
  align-items: center;
  border-bottom: 1px solid #edf2f7;
  display: flex;
  gap: 9px;
  margin: 0;
  min-height: 42px;
  padding: 9px 10px;
}

.choice-row:last-child {
  border-bottom: 0;
}

.choice-row:hover {
  background: #f4f9ff;
}

.choice-row input {
  height: 14px;
  min-height: 14px;
  width: 14px;
}

.choice-row span {
  display: grid;
  gap: 2px;
}

.choice-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.endpoint-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.error {
  background: #fff1f1;
  border: 1px solid #efb8b8;
  border-radius: 6px;
  color: #912c2c;
  padding: 10px 12px;
}

.login-shell {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(76, 151, 211, 0.18), rgba(253, 220, 57, 0.14)),
    #eef2f6;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  background: #ffffff;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(31, 41, 55, 0.12);
  max-width: 430px;
  padding: 28px;
  width: 100%;
}

.login-brand {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.login-brand h1 {
  font-size: 20px;
}

.login-brand p {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar {
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    width: 100%;
  }

  .workspace {
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
  }

  .sidebar-nav {
    display: flex;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    padding: 8px;
  }

  .tenant-filter {
    border-bottom: 0;
    grid-template-columns: 90px minmax(0, 1fr);
    padding: 10px 12px 2px;
  }

  .tenant-filter label {
    align-self: center;
  }

  .nav-item {
    border-radius: 4px;
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 12px;
  }

  .page {
    padding: 12px;
  }

  .page-header,
  .toolbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .metric-strip,
  .toolbar-actions {
    justify-content: flex-start;
  }

  .toolbar-filter,
  .toolbar-filter input,
  .toolbar-filter select {
    width: 100%;
  }

  .table-wrap {
    overflow-x: hidden;
  }

  .period-rule-row {
    align-items: stretch;
    gap: 6px;
    grid-template-columns: 1fr;
  }

  .period-checks.weekly,
  .period-checks.monthly {
    grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  }

  .period-time-range {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  table {
    max-width: 100%;
    table-layout: fixed;
  }

  th,
  td {
    padding: 7px 8px;
    white-space: normal;
    word-break: break-word;
  }

  .check-col {
    display: none;
  }
}

@media (max-width: 640px) {
  .brand-block {
    padding: 10px 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
  }

  .tenant-switcher,
  .userbar {
    justify-content: space-between;
    width: 100%;
  }

  .metric-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .metric {
    min-width: 0;
  }

  .toolbar-actions,
  .actions,
  .modal-form-actions {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .toolbar-actions .button,
  .toolbar-actions button,
  .toolbar-actions a,
  .actions .button,
  .actions button,
  .modal-form-actions button {
    justify-content: center;
    width: 100%;
  }

  .modal-dialog {
    max-height: 100dvh;
    max-width: 100vw;
  }

  .modal-card {
    border-radius: 0;
    max-height: 100dvh;
  }

  .modal-body {
    max-height: calc(100dvh - 56px);
    padding: 12px;
  }

  .inline,
  .period-selector,
  .period-time-range {
    grid-template-columns: 1fr;
  }

  .period-transfer {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .period-transfer-button {
    width: 100%;
  }

  .choice-list {
    max-height: 48dvh;
    overflow: auto;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
    display: grid;
    gap: 8px;
    padding: 10px;
  }

  tbody tr:nth-child(even),
  tbody tr:hover,
  tbody tr:nth-child(even):hover {
    background: #ffffff;
  }

  td {
    border-bottom: 0;
    display: grid;
    gap: 3px;
    padding: 0;
  }

  td::before {
    color: #607089;
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 760;
    text-transform: uppercase;
  }

  td[data-label="Actions"]::before {
    margin-bottom: 2px;
  }

  td:empty {
    display: none;
  }

  .actions-cell {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions-cell .button,
  .actions-cell button,
  .actions-cell form {
    width: 100%;
  }
}
