:root {
  --ink: #132535;
  --ink-soft: #536674;
  --paper: #f5f1e8;
  --surface: #fffdf8;
  --line: #ded8cc;
  --navy: #14243a;
  --navy-raised: #203650;
  --orange: #ee8d1c;
  --orange-deep: #ce6812;
  --green: #168664;
  --green-pale: #dff3e9;
  --blue: #187da0;
  --blue-pale: #dceef3;
  --red: #b53b38;
  --red-pale: #f8e3df;
  --amber: #b26909;
  --amber-pale: #f7ead0;
  --shadow: 0 18px 50px rgb(32 47 58 / 10%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Bahnschrift", "Segoe UI Variable", sans-serif;
  background:
    radial-gradient(circle at 12% 4%, rgb(238 141 28 / 12%), transparent 26rem),
    linear-gradient(145deg, #f8f4eb 0%, #f1f3ed 55%, #edf2ef 100%);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

[hidden] {
  display: none !important;
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}

.ambient-one {
  top: -14rem;
  right: -8rem;
  width: 36rem;
  height: 36rem;
  border: 1px solid rgb(20 36 58 / 7%);
  background: rgb(255 255 255 / 24%);
}

.ambient-two {
  bottom: -20rem;
  left: -14rem;
  width: 42rem;
  height: 42rem;
  border: 6rem solid rgb(22 134 100 / 4%);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem;
}

.login-card {
  width: min(100%, 28rem);
  padding: 2.4rem;
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 1.75rem;
  background: rgb(255 253 248 / 92%);
  box-shadow: var(--shadow);
}

.login-card .brand-mark {
  margin-bottom: 1.3rem;
}

.login-card h1 {
  margin: 0.35rem 0 0.65rem;
  font-size: clamp(1.8rem, 5vw, 2.55rem);
  line-height: 1.05;
}

.app-shell {
  width: min(100% - 2rem, 104rem);
  margin: 0 auto;
  padding: 1.2rem 0 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0 1.2rem;
  gap: 1rem;
}

.brand,
.topbar-actions,
.hero-actions,
.filters,
.modal-actions,
.activation-code-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  display: grid;
  width: 3.35rem;
  height: 3.35rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 1.05rem;
  color: white;
  font-size: 1.55rem;
  font-weight: 800;
  background:
    linear-gradient(135deg, var(--orange) 0 48%, var(--navy) 49% 100%);
  box-shadow: 0 8px 22px rgb(20 36 58 / 18%);
}

.brand h1 {
  margin: 0.1rem 0 0;
  font-size: 1.65rem;
}

.eyebrow {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow.accent {
  color: var(--orange-deep);
}

.user-badge {
  max-width: 15rem;
  overflow: hidden;
  padding: 0.55rem 0.8rem;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 13.5rem;
  padding: clamp(1.5rem, 4vw, 3rem);
  gap: 2rem;
  overflow: hidden;
  border-radius: 1.7rem;
  color: white;
  background:
    radial-gradient(circle at 80% 20%, rgb(238 141 28 / 24%), transparent 24rem),
    linear-gradient(120deg, #112238, #1c3a4b);
  box-shadow: var(--shadow);
}

.hero h2 {
  max-width: 44rem;
  margin: 0.55rem 0 0.75rem;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
}

.hero-copy {
  max-width: 43rem;
  margin: 0;
  color: rgb(255 255 255 / 72%);
  font-size: 1rem;
  line-height: 1.5;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(9rem, 1fr));
  gap: 0.8rem;
  margin: 0.9rem 0;
}

.metric-card {
  min-height: 7.7rem;
  padding: 1.2rem;
  border: 1px solid rgb(222 216 204 / 80%);
  border-radius: 1.2rem;
  background: rgb(255 253 248 / 90%);
}

.metric-card span {
  display: block;
  min-height: 2.3em;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.3;
}

.metric-card strong {
  display: block;
  margin-top: 0.45rem;
  font-size: 2.15rem;
  line-height: 1;
}

.metric-good strong {
  color: var(--green);
}

.metric-live strong {
  color: var(--blue);
}

.metric-warn strong {
  color: var(--amber);
}

.metric-danger strong {
  color: var(--red);
}

.tabs {
  display: flex;
  margin: 1.4rem 0 0.75rem;
  gap: 0.45rem;
  overflow-x: auto;
}

.tab {
  padding: 0.72rem 1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--ink-soft);
  background: transparent;
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink);
  background: rgb(255 255 255 / 48%);
}

.tab.is-active {
  color: white;
  background: var(--navy);
}

.panel {
  min-height: 24rem;
  padding: clamp(1rem, 2.5vw, 1.7rem);
  border: 1px solid var(--line);
  border-radius: 1.45rem;
  background: rgb(255 253 248 / 94%);
  box-shadow: 0 12px 35px rgb(32 47 58 / 6%);
}

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  gap: 1rem;
}

.panel h3,
.modal h3 {
  margin: 0.25rem 0 0;
  font-size: 1.45rem;
}

.button {
  min-height: 2.65rem;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  font-weight: 700;
  transition: transform 120ms ease, background 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button-primary {
  color: #172332;
  background: var(--orange);
}

.button-primary:hover:not(:disabled) {
  background: #f49b30;
}

.button-dark {
  color: white;
  background: var(--navy);
}

.button-dark:hover:not(:disabled) {
  background: var(--navy-raised);
}

.button-light {
  color: var(--ink);
  background: white;
}

.button-quiet {
  border-color: var(--line);
  color: var(--ink);
  background: rgb(255 255 255 / 64%);
}

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

.button-wide {
  width: 100%;
}

.button-small {
  min-height: 2.1rem;
  padding: 0.42rem 0.7rem;
  border-radius: 0.55rem;
  font-size: 0.78rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.62rem 0.75rem;
  border: 1px solid #cfc8bb;
  border-radius: 0.65rem;
  color: var(--ink);
  outline: none;
  background: white;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgb(24 125 160 / 12%);
}

label {
  display: grid;
  gap: 0.38rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 600;
}

.search-field {
  width: min(23rem, 44vw);
}

.filters select {
  width: 12rem;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th {
  padding: 0.7rem 0.65rem;
  color: var(--ink-soft);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 0.85rem 0.65rem;
  border-top: 1px solid #ebe5d9;
  vertical-align: middle;
}

td strong,
td small {
  display: block;
}

td small {
  margin-top: 0.2rem;
  color: var(--ink-soft);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 1.85rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-active,
.status-online {
  color: #12644d;
  background: var(--green-pale);
}

.status-offline,
.status-scheduled,
.status-used {
  color: #52636e;
  background: #e8ecee;
}

.status-attention,
.status-pending {
  color: #7f4d04;
  background: var(--amber-pale);
}

.status-blocked,
.status-expired,
.status-revoked {
  color: #8d2c2a;
  background: var(--red-pale);
}

.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}

.customer-card {
  min-height: 8rem;
  padding: 1.1rem;
  border: 1px solid #e5ded1;
  border-radius: 1rem;
  background: white;
}

.customer-card h4 {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
}

.customer-card p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.45;
}

.timeline {
  display: grid;
}

.timeline-item {
  display: grid;
  grid-template-columns: 10.5rem 1fr;
  padding: 0.85rem 0;
  border-top: 1px solid #e9e2d6;
  gap: 1rem;
}

.timeline-item:first-child {
  border-top: 0;
}

.timeline-time {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.timeline-item strong,
.timeline-item small {
  display: block;
}

.timeline-item small {
  margin-top: 0.25rem;
  color: var(--ink-soft);
}

.empty-state {
  margin: 4rem auto;
  color: var(--ink-soft);
  text-align: center;
}

.modal {
  width: min(94vw, 35rem);
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 1.35rem;
  background: transparent;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgb(13 26 38 / 58%);
  backdrop-filter: blur(3px);
}

.modal-card {
  display: grid;
  padding: 1.5rem;
  gap: 1rem;
  border-radius: 1.35rem;
  background: var(--surface);
}

.modal-wide {
  width: min(94vw, 48rem);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.icon-button {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 50%;
  place-items: center;
  color: var(--ink-soft);
  font-size: 1.45rem;
  background: #eee9de;
}

.form-stack {
  display: grid;
  margin-top: 1.5rem;
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

fieldset {
  display: flex;
  margin: 0;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  gap: 1rem;
}

legend {
  padding: 0 0.4rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

label.check {
  display: flex;
  align-items: center;
  color: var(--ink);
}

.check input {
  width: 1rem;
  min-height: 1rem;
  margin: 0;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 0.3rem;
}

.form-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--red);
  font-size: 0.82rem;
}

.activation-code-row {
  align-items: stretch;
}

.activation-code-row code {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  padding: 0.8rem;
  overflow-x: auto;
  border: 1px dashed var(--orange-deep);
  border-radius: 0.75rem;
  color: var(--navy);
  font-size: 1rem;
  font-weight: 700;
  background: #fff6df;
  white-space: nowrap;
}

.muted {
  color: var(--ink-soft);
  line-height: 1.5;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 1rem;
  bottom: 1rem;
  max-width: min(90vw, 28rem);
  padding: 0.85rem 1rem;
  border-radius: 0.8rem;
  color: white;
  background: var(--navy);
  box-shadow: var(--shadow);
}

.toast.is-error {
  background: var(--red);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 70rem) {
  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 48rem) {
  .app-shell {
    width: min(100% - 1rem, 104rem);
    padding-top: 0.5rem;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 0.4rem;
  }

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

  .topbar-actions .user-badge {
    grid-column: 1 / -1;
  }

  .hero {
    min-height: auto;
    padding: 1.4rem;
  }

  .hero-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

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

  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .search-field,
  .filters select {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  fieldset {
    align-items: flex-start;
    flex-direction: column;
  }

  .activation-code-row {
    flex-direction: column;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }
}
