:root {
  color: #1c2733;
  background: #f2f5f8;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(34, 144, 255, 0.12), transparent 34rem),
    #f2f5f8;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: white;
  background: #1684e8;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(22, 132, 232, 0.25);
}

.brand h1,
.brand p,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
}

.brand p {
  margin-top: 2px;
  color: #708090;
  font-size: 13px;
}

.card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #dfe6ed;
  border-radius: 18px;
  box-shadow: 0 18px 55px rgba(45, 66, 86, 0.08);
}

.compact {
  width: min(440px, 100%);
  margin: 8vh auto 0;
  padding: 32px;
}

.card-header,
.topbar,
.toolbar,
.toolbar-actions,
.topbar-actions,
.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.eyebrow {
  margin-bottom: 6px;
  color: #1684e8;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -0.025em;
}

h3 {
  font-size: 22px;
}

.form-stack,
.dialog-form {
  display: grid;
  gap: 18px;
}

.form-stack {
  margin-top: 28px;
}

label {
  display: grid;
  gap: 8px;
  color: #465564;
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  padding: 11px 13px;
  color: #1c2733;
  background: white;
  border: 1px solid #cfd9e2;
  border-radius: 10px;
  outline: none;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

input:focus,
select:focus {
  border-color: #1684e8;
  box-shadow: 0 0 0 3px rgba(22, 132, 232, 0.13);
}

button {
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  font-weight: 720;
}

.primary {
  color: white;
  background: #1684e8;
}

.primary:hover {
  background: #0874d3;
}

.ghost {
  color: #405162;
  background: #eaf0f5;
}

.danger {
  color: #b42318;
  background: #feeceb;
}

.dashboard {
  display: grid;
  gap: 24px;
}

.panel {
  display: grid;
  gap: 24px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: #e7edf3;
  border-radius: 12px;
  width: fit-content;
}

.tab {
  min-width: 86px;
  color: #526373;
  background: transparent;
}

.tab.active {
  color: #125f9f;
  background: white;
  box-shadow: 0 3px 10px rgba(42, 62, 80, 0.1);
}

.topbar {
  padding: 4px 2px;
}

.current-user {
  color: #607080;
  font-size: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.stats article {
  padding: 20px 22px;
  background: white;
  border: 1px solid #dfe6ed;
  border-radius: 15px;
}

.stats span {
  display: block;
  color: #718191;
  font-size: 13px;
}

.stats strong {
  display: block;
  margin-top: 9px;
  font-size: 28px;
}

.table-card {
  overflow: hidden;
}

.toolbar {
  padding: 18px 20px;
  border-bottom: 1px solid #e5ebf0;
}

.search {
  display: flex;
  align-items: center;
}

.search input {
  width: min(280px, 50vw);
}

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

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

th,
td {
  padding: 15px 20px;
  text-align: left;
  border-bottom: 1px solid #edf1f4;
  white-space: nowrap;
}

th {
  color: #718191;
  background: #fafbfc;
  font-size: 12px;
  letter-spacing: 0.03em;
}

td {
  font-size: 14px;
}

.status {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status.normal {
  color: #067647;
  background: #e8f7ef;
}

.status.disabled {
  color: #b42318;
  background: #feeceb;
}

.status.online {
  color: #067647;
  background: #e8f7ef;
}

.status.offline {
  color: #607080;
  background: #edf1f4;
}

.device-name {
  display: grid;
  gap: 3px;
}

.device-name small {
  font-size: 11px;
}

.readonly-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 16px;
  padding: 14px;
  background: #f4f7f9;
  border-radius: 10px;
  font-size: 12px;
}

.readonly-grid span {
  color: #718191;
}

.readonly-grid strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-result {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #fff8e8;
  border: 1px solid #f2d58b;
  border-radius: 10px;
}

.token-result span {
  color: #8a5b00;
  font-size: 12px;
  font-weight: 700;
}

.token-result code {
  overflow-wrap: anywhere;
  color: #3d4650;
  font-size: 12px;
  line-height: 1.6;
  user-select: all;
}

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

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.row-actions button {
  padding: 7px 10px;
  font-size: 12px;
}

.empty {
  padding: 44px;
  color: #718191;
  text-align: center;
}

dialog {
  width: min(480px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(17, 35, 52, 0.28);
}

dialog::backdrop {
  background: rgba(24, 38, 51, 0.45);
  backdrop-filter: blur(3px);
}

.dialog-form {
  padding: 26px;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  color: #536474;
  background: #edf2f6;
  font-size: 23px;
}

.check-row {
  display: flex;
  align-items: center;
}

.check-row input {
  width: 17px;
  height: 17px;
}

small {
  color: #7b8997;
  font-weight: 450;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 4px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100% - 48px));
  padding: 13px 16px;
  color: white;
  background: #243746;
  border-radius: 10px;
  box-shadow: 0 12px 35px rgba(17, 35, 52, 0.25);
  font-size: 14px;
}

.toast.error {
  background: #b42318;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  .compact {
    margin-top: 4vh;
    padding: 24px;
  }

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

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

  .topbar-actions {
    justify-content: space-between;
  }

  .search {
    width: 100%;
  }

  .search input {
    width: 100%;
  }
}
