@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.css");

:root {
  font-family: "Inter", "Pretendard Variable", Pretendard, ui-sans-serif, system-ui, sans-serif;
  color: #17212b;
  background: #edf2f5;
}

* { box-sizing: border-box; }

body {
  min-width: 0;
  margin: 0;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgb(48 135 161 / 22%);
  outline-offset: 2px;
}

.shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 42px 24px calc(42px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
.eyebrow {
  margin: 0 0 6px;
  color: #5b7280;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}
h1 { margin: 0; font-size: 28px; }
h2 { margin: 0 0 16px; font-size: 18px; }

.login-card {
  width: min(100%, 400px);
  margin: 80px auto;
  border: 1px solid #d3dfe5;
  background: #fff;
  padding: 26px;
  box-shadow: 0 15px 32px rgb(21 41 58 / 8%);
}
.form-stack {
  display: grid;
  gap: 13px;
  margin-top: 24px;
}
.form-stack label, .inline-form {
  display: grid;
  gap: 6px;
  color: #566c79;
  font-size: 12px;
  font-weight: 700;
}
.compact { margin-top: 0; }

input, select {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid #bdcbd5;
  border-radius: 5px;
  background: #fff;
  padding: 0 10px;
  color: #1e2c36;
}
input:focus, select:focus { border-color: #2f849f; }
button {
  min-height: 42px;
  border: 1px solid #176b84;
  border-radius: 5px;
  background: #1c7d98;
  padding: 0 15px;
  color: #fff;
  font-weight: 700;
}
button:hover { background: #176b84; }
.secondary { border-color: #bdcbd5; background: #fff; color: #355363; }
.error { min-height: 18px; margin: 0; color: #b23c35; font-size: 13px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.admin-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: #4f6674;
  font-size: 14px;
}
#adminEmail { overflow-wrap: anywhere; }
.grid {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  gap: 18px;
}
.panel {
  min-width: 0;
  border: 1px solid #d3dfe5;
  background: #fff;
  padding: 21px;
}
.inline-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.list { display: grid; gap: 6px; margin-top: 17px; }
.tenant {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  border-top: 1px solid #e3eaee;
  padding: 10px 2px;
  color: #30434f;
  font-size: 14px;
}
.tenant strong { overflow-wrap: anywhere; }
.tenant span { color: #72818d; font-size: 12px; }
.new-key {
  margin-top: 16px;
  border: 1px solid #9acfb0;
  background: #e8f7ee;
  padding: 13px;
  color: #24543a;
  font-size: 13px;
  line-height: 1.5;
}
.new-key code {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 8px;
  border: 1px solid #bbdec9;
  background: #fff;
  padding: 8px;
  color: #183a28;
}
.keys-panel { margin-top: 18px; }
.table-wrap { min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  border-top: 1px solid #e1e8ec;
  padding: 11px 8px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
th { color: #657784; font-size: 11px; letter-spacing: .04em; }
td.origins { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.status { font-weight: 700; }
.status.active { color: #25814e; }
.status.revoked, .status.closed { color: #a74741; }
.status.open { color: #25814e; }
.status.waiting { color: #a26914; }
td button { min-height: 38px; padding: 0 10px; font-size: 12px; }

.admin-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid #d3dfe5;
}
.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #60717e;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}
.nav-item:hover { background: #e7f1f4; color: #215c71; }
.nav-item.active { border-bottom-color: #1c7d98; color: #175e76; }
.dashboard-view {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.status-card {
  min-width: 0;
  min-height: 144px;
  border: 1px solid #d3dfe5;
  background: #fff;
  padding: 20px;
}
.status-card strong, .status-card span { display: block; }
.status-card strong { overflow-wrap: anywhere; font-size: 17px; }
.status-card span, .muted {
  margin: 10px 0 0;
  color: #61737f;
  font-size: 13px;
  line-height: 1.5;
}

.table-link {
  width: auto;
  height: auto;
  min-height: 40px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  padding: 4px 6px;
  color: #155f77;
  text-align: left;
  font-size: inherit;
  font-weight: 600;
}
.table-link:hover, .table-link:active { background: #176b84; color: #fff; }
.table-link:focus-visible { outline: 3px solid rgb(28 125 152 / 28%); outline-offset: 2px; }
.room-actions-heading, td.room-actions { width: 1%; text-align: right; }
.danger-badge {
  width: auto;
  min-height: 38px;
  border: 1px solid #e5bbb8;
  border-radius: 999px;
  background: #fff3f2;
  padding: 0 10px;
  color: #9b3732;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.danger-badge:hover, .danger-badge:active { border-color: #a3342d; background: #a3342d; color: #fff; }
.danger-badge:focus-visible { outline: 3px solid rgb(163 52 45 / 24%); outline-offset: 2px; }
.danger-badge:disabled { cursor: wait; opacity: .6; }

@media (max-width: 860px) {
  .shell { padding: 30px 20px calc(30px + env(safe-area-inset-bottom)); }
  .grid { grid-template-columns: 1fr; }
  .dashboard-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-card:last-child { grid-column: 1 / -1; }
}

@media (max-width: 780px) {
  .shell { padding: 22px 14px calc(26px + env(safe-area-inset-bottom)); }
  .topbar { align-items: flex-start; flex-direction: column; gap: 14px; }
  .admin-info { width: 100%; justify-content: space-between; }
  .panel { padding: 16px; }
  .admin-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    border-bottom: 0;
  }
  .nav-item {
    height: auto;
    min-height: 44px;
    border: 1px solid #d3dfe5;
    border-bottom: 2px solid #d3dfe5;
    border-radius: 4px;
    padding: 8px 6px;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    text-align: center;
  }
  .nav-item.active { border-color: #b9dbe5; border-bottom-color: #1c7d98; background: #e7f3f6; }
  .dashboard-view { grid-template-columns: 1fr; }
  .status-card:last-child { grid-column: auto; }
  .inline-form { grid-template-columns: 1fr; }

  .responsive-table, .responsive-table tbody { display: block; width: 100%; }
  .responsive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
  }
  .responsive-table tbody { display: grid; gap: 10px; }
  .responsive-table tbody tr {
    display: block;
    border: 1px solid #d3dfe5;
    background: #fff;
    padding: 7px 12px;
  }
  .responsive-table td {
    display: grid;
    grid-template-columns: minmax(92px, .7fr) minmax(0, 1.3fr);
    align-items: start;
    gap: 8px;
    min-width: 0;
    border: 0;
    border-bottom: 1px solid #e8eef1;
    padding: 10px 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .responsive-table td::before {
    content: attr(data-label);
    color: #657784;
    font-size: 11px;
    font-weight: 700;
  }
  .responsive-table td:first-child { color: #173d4c; font-weight: 700; }
  .responsive-table td.origins { max-width: none; overflow: visible; text-overflow: clip; }
  .responsive-table td:last-child { border-bottom: 0; }
  .responsive-table td.room-actions { width: auto; text-align: left; }
  .responsive-table td button { min-height: 42px; }
}

@media (max-width: 480px) {
  .shell { padding: 18px 12px calc(22px + env(safe-area-inset-bottom)); }
  h1 { font-size: 25px; }
  .login-card { margin: 30px auto; padding: 21px 18px; }
  .admin-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-item { justify-content: flex-start; padding-inline: 12px; text-align: left; }
  .panel { padding: 14px; }
  .status-card { min-height: 0; padding: 16px; }
  .responsive-table tbody tr { padding-inline: 10px; }
  .responsive-table td { grid-template-columns: minmax(76px, .62fr) minmax(0, 1.38fr); gap: 7px; }
  .responsive-table .room-actions button, .responsive-table .danger-badge { width: 100%; }
  .tenant { align-items: flex-start; flex-direction: column; gap: 4px; }
}
