:root {
  color-scheme: light;
  --navy: #001c44;
  --navy-soft: #0a315f;
  --teal: #00a896;
  --teal-dark: #008c7d;
  --sidebar: #eaf2f7;
  --canvas: #f8fafc;
  --surface: #ffffff;
  --line: #e2e8f0;
  --ink: #0f2747;
  --muted: #64748b;
  --success-bg: #e8f7f1;
  --success: #16835b;
  --warning-bg: #fff7e6;
  --warning: #b76a00;
  --danger-bg: #fff0f0;
  --danger: #c43d3d;
  --shadow: 0 12px 32px rgba(0, 28, 68, .06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 14px/1.5 Inter, Roboto, system-ui, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.sidebar {
  position: static;
  z-index: 10;
  display: flex;
  width: auto;
  flex-direction: column;
  padding: 10px 14px;
  border-bottom: 1px solid #d7e3ec;
  background: var(--sidebar);
  color: var(--navy);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 0;
  color: var(--navy);
  text-decoration: none;
}

.brand img {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-copy strong {
  font-size: 19px;
  letter-spacing: .16em;
}

.brand-copy small {
  display: none;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.nav-toggle-label {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  color: var(--navy);
  cursor: pointer;
}

.nav-toggle-label svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.nav-toggle-input:focus-visible~.sidebar-head .nav-toggle-label {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 168, 150, .12);
}

.sidebar-nav {
  display: none;
  gap: 7px;
  margin-top: 12px;
}

.nav-toggle-input:checked~.sidebar-nav {
  display: grid;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 9px;
  color: #47627f;
  font-weight: 600;
  text-decoration: none;
  transition: .18s ease;
}

.sidebar-nav a:hover {
  color: var(--navy);
  background: rgba(0, 28, 68, .06);
}

.sidebar-nav a.active {
  color: white;
  background: var(--teal);
  box-shadow: 0 7px 18px rgba(0, 168, 150, .24);
}

.sidebar-nav svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-footer {
  display: none;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 13px;
  border-top: 1px solid #d7e3ec;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(0, 168, 150, .15);
}

.shell {
  min-height: 100vh;
  margin-left: 0;
}

.topbar {
  display: flex;
  min-height: 60px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
}

.topbar>div:first-child {
  display: flex;
  flex-direction: column;
}

.topbar strong {
  color: var(--navy);
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.operator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.operator-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: var(--navy);
  color: white;
  font-weight: 700;
}

.operator>span:last-child {
  display: none;
  flex-direction: column;
  line-height: 1.25;
}

.operator small {
  color: var(--muted);
  font-size: 10px;
}

.logout-link {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: none;
}

.logout-link:hover {
  background: var(--danger-bg);
  color: var(--danger);
  transform: none;
}

.logout-link svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 25px 18px 40px;
}

.page-heading {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.page-heading h1 {
  margin: 0;
  color: var(--navy);
  font-size: 27px;
  line-height: 1.25;
  letter-spacing: -.025em;
}

.page-heading p {
  margin: 7px 0 0;
  color: var(--muted);
}

.section-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.metric {
  min-width: 0;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  box-shadow: var(--shadow);
}

.metric small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.metric strong {
  display: block;
  margin-top: 2px;
  color: var(--navy);
  font-size: 23px;
}

.metric-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.plans {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.detail-grid,
.actions-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 22px;
}

.card,
.toolbar {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card {
  padding: 22px;
}

.card.new {
  border-style: dashed;
  border-color: #b7c6d7;
}

.card-header {
  margin: -22px -22px 20px;
  padding: 17px 22px;
  border-bottom: 1px solid var(--line);
}

.card h2,
.card h3 {
  margin: 0;
  color: var(--navy);
}

.card h2 {
  font-size: 16px;
}

.card p {
  margin: 7px 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.definition-list {
  display: grid;
  gap: 13px;
  margin: 0;
}

.definition-list div {
  display: grid;
  gap: 4px;
}

.definition-list dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.definition-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.action-panel {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.action-panel summary {
  color: var(--navy);
  font-weight: 800;
  cursor: pointer;
}

.action-panel p {
  margin-bottom: 8px;
}

.danger-panel {
  border-color: #f1c7c7;
  background: #fffafa;
}

.danger-panel summary {
  color: var(--danger);
}

.history-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.backline {
  margin: -8px 0 18px;
}

.payload-details summary {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.payload-details pre {
  max-width: 520px;
  max-height: 280px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #243b53;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 11px;
  white-space: pre-wrap;
}

.json-block {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #243b53;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 11px;
  white-space: pre-wrap;
}

.plain-list {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  padding-left: 18px;
}

.titleline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar {
  margin-bottom: 22px;
  padding: 18px 20px;
}

.toolbar form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
  gap: 12px;
}

.toolbar-field {
  min-width: 0;
}

.tenant-toolbar form,
.ticket-toolbar form {
  grid-template-columns: minmax(0, 1fr);
}

.tenant-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

label {
  display: block;
  margin: 13px 0 5px;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: 0;
  background: white;
  color: var(--ink);
  transition: .15s ease;
}

input::placeholder {
  color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 168, 150, .12);
}

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

.checks {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 22px;
  margin-top: 16px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
}

.checks input {
  width: 16px;
  min-height: auto;
  accent-color: var(--teal);
}

.feature-editor {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.feature-heading {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.feature-heading label {
  margin: 0 0 2px;
}

.feature-heading .hint {
  display: block;
}

.feature-list {
  display: grid;
  gap: 8px;
}

.feature-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.feature-row input {
  min-width: 0;
}

.feature-row input:first-child {
  grid-column: 1 / -1;
}

.secondary-button,
.remove-feature {
  margin: 0;
  background: transparent;
  box-shadow: none;
}

.secondary-button {
  border: 1px solid var(--teal);
  color: var(--teal-dark);
  white-space: nowrap;
}

.secondary-button:hover {
  background: var(--success-bg);
}

.remove-feature {
  padding: 8px 10px;
  color: var(--danger);
  font-size: 11px;
}

.remove-feature:hover {
  background: var(--danger-bg);
}

.feature-empty {
  padding: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

button {
  margin-top: 18px;
  padding: 10px 15px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: .16s ease;
}

button:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.full-button {
  width: 100%;
}

.toolbar button {
  width: 100%;
  margin: 0;
}

.small-button {
  margin: 6px 0 0;
  padding: 6px 9px;
  font-size: 11px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 13px;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.button-link:hover {
  background: var(--teal-dark);
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #a93131;
}

.form-card {
  max-width: 680px;
}

.inline-form {
  margin: 0;
}

.inline-form select,
.priority-select {
  min-height: 34px;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
  padding: 0;
}

.table-wrap .card-header {
  margin: 0;
}

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

th {
  background: #fbfcfe;
  color: var(--navy);
  font-size: 10px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .08em;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #f7fcfb;
}

code,
.mono {
  color: #32506f;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 11px;
}

.qr-code {
  display: inline-flex;
  max-width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.qr-code svg {
  display: block;
  width: min(260px, 100%);
  height: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
}

.badge.off {
  background: #eef2f6;
  color: var(--muted);
}

.badge.status-past_due {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge.status-canceled {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.ticket-status-open {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge.ticket-status-in_progress {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge.ticket-status-waiting {
  background: #f5f3ff;
  color: #6d28d9;
}

.badge.ticket-status-resolved {
  background: var(--success-bg);
  color: var(--success);
}

.badge.ticket-status-closed {
  background: #eef2f6;
  color: var(--muted);
}

.priority-badge.priority-urgent,
.priority-select.priority-urgent {
  background: var(--danger-bg);
  color: var(--danger);
}

.priority-badge.priority-high,
.priority-select.priority-high {
  background: #fff4e5;
  color: #c05621;
}

.priority-badge.priority-normal,
.priority-select.priority-normal {
  background: #eff6ff;
  color: #1d4ed8;
}

.priority-badge.priority-low,
.priority-select.priority-low {
  background: #eef2f6;
  color: var(--muted);
}

.stacked-actions {
  display: grid;
  gap: 14px;
}

.danger-callout {
  display: grid;
  gap: 4px;
  margin-bottom: 22px;
  padding: 15px 18px;
  border: 1px solid #f1c7c7;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
}

.note-list {
  display: grid;
  gap: 12px;
}

.ticket-note {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.ticket-note.internal {
  border-color: #c7d2fe;
  background: #eef2ff;
}

.ticket-note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ticket-note p {
  margin: 0;
  color: var(--ink);
  white-space: pre-wrap;
}

.note-internal {
  background: #dbeafe;
  color: #1d4ed8;
}

.note-public {
  background: var(--success-bg);
  color: var(--success);
}

.note-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.toggle-line input {
  width: 16px;
  min-height: auto;
  accent-color: var(--teal);
}

.muted-notice {
  background: #f8fafc;
  color: var(--muted);
}

.table-link {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.table-link:hover {
  color: var(--navy);
  text-decoration: underline;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
}

.pagination a,
.pagination span,
.pagination strong {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.pagination a {
  background: var(--surface);
  color: var(--teal-dark);
  text-decoration: none;
  border: 1px solid var(--line);
}

.pagination span {
  color: #94a3b8;
  border: 1px solid transparent;
}

.pagination strong {
  color: var(--navy);
}

.token {
  margin-bottom: 18px;
  padding: 15px 17px;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: var(--navy);
  color: white;
  overflow-wrap: anywhere;
}

.token code {
  color: #b8fff3;
}

.muted,
.hint {
  color: var(--muted);
  font-size: 11px;
}

.notice,
.error {
  margin-bottom: 18px;
  padding: 11px 13px;
  border-radius: 8px;
  font-weight: 600;
}

.notice {
  background: var(--success-bg);
  color: var(--success);
}

.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.empty {
  padding: 44px 20px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 640px) {
  .metric-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .toolbar form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .toolbar button {
    width: auto;
    white-space: nowrap;
  }

  .tenant-toolbar form,
  .ticket-toolbar form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tenant-toolbar .search-field,
  .tenant-toolbar button,
  .ticket-toolbar .search-field,
  .ticket-toolbar button {
    grid-column: 1 / -1;
  }

  .tenant-toolbar button,
  .ticket-toolbar button {
    width: 100%;
  }

  .row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
  }

  .checks,
  .feature-heading {
    align-items: end;
    flex-direction: row;
  }

  .feature-row {
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr) auto;
  }

  .feature-row input:first-child {
    grid-column: auto;
  }

  .actions-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 761px) {
  .topbar {
    min-height: 76px;
    padding: 12px 36px;
  }

  .operator>span:last-child {
    display: flex;
  }

  main {
    padding: 34px 36px 54px;
  }

  .page-heading {
    align-items: end;
    flex-direction: row;
  }

  .metric {
    min-width: 180px;
  }

  .ticket-toolbar form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1051px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    padding: 24px 18px;
    border-right: 1px solid #d7e3ec;
    border-bottom: 0;
  }

  .sidebar-head {
    display: block;
  }

  .brand {
    padding: 0 7px 28px;
  }

  .brand img {
    width: 58px;
    height: 58px;
  }

  .brand-copy small {
    display: block;
  }

  .nav-toggle-label {
    display: none;
  }

  .sidebar-nav {
    display: grid;
    margin-top: 0;
  }

  .sidebar-footer {
    display: flex;
  }

  .shell {
    margin-left: 248px;
  }

  .grid {
    grid-template-columns: 330px minmax(0, 1fr);
  }

  .plans {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tenant-toolbar form {
    grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(130px, 1fr)) auto;
  }

  .tenant-toolbar .search-field,
  .tenant-toolbar button {
    grid-column: auto;
  }

  .tenant-toolbar button {
    width: auto;
    white-space: nowrap;
  }
}
