:root {
  --navy: #102a43;
  --navy-dark: #081b2b;
  --blue: #1769aa;
  --blue-light: #eaf4fc;
  --green: #117a56;
  --green-light: #e7f7f0;
  --red: #b42318;
  --red-light: #fff0ee;
  --orange: #ef8f22;
  --surface: #ffffff;
  --background: #f4f7fb;
  --border: #dce5ee;
  --text: #172b3a;
  --muted: #617487;
  --shadow: 0 12px 32px rgba(16, 42, 67, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

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

.topbar {
  min-height: 68px;
  padding: 10px clamp(16px, 4vw, 54px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: white;
  background: var(--navy-dark);
  border-bottom: 3px solid var(--orange);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: white;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  background: linear-gradient(145deg, var(--orange), #ffb24e);
  border-radius: 11px;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(239, 143, 34, 0.24);
}

.brand-mark-large {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 17px;
  font-size: 30px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 2px;
  color: #a9bdcf;
  font-size: 11px;
}

.topbar-actions,
.heading-actions,
.card-actions,
.form-actions,
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.topbar-actions form,
.card-actions form,
.row-actions form {
  margin: 0;
}

.signed-user {
  color: #c9d7e4;
  font-size: 13px;
}

.page-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 50px;
}

.page-heading {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
}

.page-heading h1 {
  margin: 2px 0 6px;
  color: var(--navy);
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.1;
}

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

.eyebrow {
  color: var(--orange) !important;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.button {
  min-height: 38px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

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

.button-primary {
  color: white;
  background: var(--blue);
  box-shadow: 0 7px 16px rgba(23, 105, 170, 0.18);
}

.button-secondary {
  color: var(--blue);
  background: var(--blue-light);
  border-color: #c9e0f2;
}

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

.button-danger {
  color: var(--red);
  background: var(--red-light);
  border-color: #ffd2cc;
}

.button-small {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 12px;
}

.button-full {
  width: 100%;
}

.alert {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 650;
}

.alert-success {
  color: var(--green);
  background: var(--green-light);
  border-color: #bae9d6;
}

.alert-error {
  color: var(--red);
  background: var(--red-light);
  border-color: #ffd1cb;
}

.building-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 410px), 1fr));
  gap: 18px;
}

.building-card,
.form-card,
.table-card,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.building-card {
  padding: 20px;
}

.building-card-head {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
}

.building-logo,
.table-logo {
  object-fit: contain;
  background: white;
  border: 1px solid var(--border);
}

.building-logo {
  width: 56px;
  height: 56px;
  padding: 5px;
  border-radius: 14px;
}

.building-logo-placeholder,
.table-logo-placeholder {
  display: inline-grid;
  place-items: center;
  color: white;
  background: var(--navy);
  font-weight: 900;
}

.building-card-title {
  min-width: 0;
}

.building-card-title h2 {
  margin: 0 0 5px;
  color: var(--navy);
  font-size: 18px;
  overflow-wrap: anywhere;
}

.building-card-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.status {
  padding: 6px 9px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 800;
}

.status-active {
  color: var(--green);
  background: var(--green-light);
}

.status-inactive {
  color: var(--red);
  background: var(--red-light);
}

.building-details {
  margin: 18px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.building-details div {
  min-width: 0;
  padding: 11px;
  background: #f7f9fc;
  border-radius: 10px;
}

.building-details dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.building-details dd {
  margin: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.display-link-box {
  margin-bottom: 15px;
  padding: 10px 12px;
  color: var(--muted);
  background: #f7f9fc;
  border: 1px dashed #cfdbe7;
  border-radius: 10px;
  font-size: 11px;
}

.display-link-box span,
.display-link-box code {
  display: block;
}

.display-link-box code {
  margin-top: 4px;
  color: var(--navy);
  font-size: 12px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.empty-state {
  min-height: 300px;
  padding: 45px 20px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.empty-state h2 {
  margin: 12px 0 5px;
  color: var(--navy);
}

.empty-state p {
  margin: 0 0 18px;
  color: var(--muted);
}

.empty-icon {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--navy);
  border-radius: 18px;
  font-size: 28px;
  font-weight: 900;
}

.form-card {
  padding: clamp(18px, 3vw, 28px);
}

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

.form-grid label {
  display: block;
}

.form-grid label > span,
.current-logo > span {
  margin-bottom: 7px;
  display: block;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}

.form-grid label b {
  color: var(--red);
}

.form-grid input:not([type="checkbox"]),
.form-grid select,
.form-grid textarea,
.stack-form input {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  color: var(--text);
  background: white;
  border: 1px solid #cfdbe7;
  border-radius: 10px;
  outline: none;
}

.form-grid textarea {
  resize: vertical;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.stack-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}

.form-grid small {
  margin-top: 5px;
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.form-span-2 {
  grid-column: span 2;
}

.checkbox-label {
  min-height: 43px;
  padding: 10px 12px;
  display: flex !important;
  align-items: center;
  gap: 9px;
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.checkbox-label span {
  margin: 0 !important;
}

.current-logo {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.current-logo img {
  width: 110px;
  height: 70px;
  object-fit: contain;
  display: block;
}

.form-actions {
  margin-top: 24px;
  padding-top: 18px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

.breadcrumb {
  margin: -8px 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.breadcrumb a {
  color: var(--blue);
  text-decoration: none;
}

.table-card {
  overflow: hidden;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  padding: 11px 12px;
  color: #52697e;
  background: #edf3f8;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #e7edf3;
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fafcff;
}

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

.table-logo {
  width: 38px;
  height: 38px;
  padding: 3px;
  border-radius: 9px;
}

.actions-column {
  text-align: right;
}

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

.login-body {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(23, 105, 170, 0.19), transparent 33%),
    radial-gradient(circle at 88% 88%, rgba(239, 143, 34, 0.16), transparent 27%),
    var(--navy-dark);
}

.login-card {
  width: min(100%, 410px);
  padding: 34px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.22);
}

.login-brand {
  margin-bottom: 24px;
  text-align: center;
}

.login-brand h1 {
  margin: 0 0 7px;
  color: var(--navy);
  font-size: 27px;
}

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

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

.stack-form label > span {
  margin-bottom: 7px;
  display: block;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 17px;
  }

  .topbar {
    padding-inline: 12px;
  }

  .brand small,
  .signed-user {
    display: none;
  }

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

  .heading-actions {
    width: 100%;
  }

  .heading-actions .button {
    flex: 1 1 auto;
  }

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

  .form-span-2 {
    grid-column: auto;
  }

  .building-card-head {
    grid-template-columns: 50px minmax(0, 1fr);
  }

  .building-card-head .status {
    grid-column: 1 / -1;
    width: max-content;
  }

  .building-details {
    grid-template-columns: 1fr;
  }

  .card-actions .button,
  .card-actions form {
    flex: 1 1 calc(50% - 9px);
  }

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