/* GRAV STAGE SaaS Admin
   Dense operational console for platform and tenant administration. */

:root {
  color-scheme: light;
  --font-body: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Jost", "Pretendard", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, monospace;

  --bg: #f5f6f8;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-muted: rgba(239, 242, 247, 0.78);
  --ink: #1d1d1f;
  --ink-2: #3f4248;
  --ink-3: #747984;
  --line: rgba(28, 33, 44, 0.1);
  --line-strong: rgba(28, 33, 44, 0.16);
  --signal: #0071e3;
  --signal-2: #5eb4ff;
  --success: #22a45a;
  --warning: #b27400;
  --danger: #e5484d;
  --violet: #8175ff;

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --shadow-soft: 0 10px 24px rgba(38, 47, 67, 0.08);
  --shadow-raised: 0 18px 44px rgba(38, 47, 67, 0.12);
  --inset-soft: inset 6px 6px 16px rgba(83, 96, 124, 0.12), inset -8px -8px 18px rgba(255, 255, 255, 0.9);
  --focus: 0 0 0 4px rgba(0, 113, 227, 0.18);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 420px),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0;
  word-break: keep-all;
  overflow-wrap: normal;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

a {
  color: inherit;
  text-decoration: none;
}

a.primary-button,
a.ghost-button,
a.danger-button,
a.success-button,
.admin-brand,
.detail-review-actions a,
.share-ready-actions a {
  text-decoration: none;
}

.gateway-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gateway-card {
  width: min(860px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-raised);
  backdrop-filter: blur(24px) saturate(1.35);
}

.gateway-head {
  margin-top: 28px;
}

.gateway-head h1 {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 420;
  line-height: 1.08;
}

.gateway-head p {
  max-width: 560px;
  margin: 10px 0 0;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.5;
}

.gateway-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: 22px;
}

.gateway-link {
  display: grid;
  min-height: 156px;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 17px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow-soft);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.gateway-link:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 113, 227, 0.22);
  background: rgba(255, 255, 255, 0.9);
}

.gateway-link.muted-link {
  background: rgba(247, 249, 252, 0.52);
}

.gateway-link.muted-link strong,
.gateway-link.muted-link small {
  color: var(--ink-3);
}

.gateway-link strong {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 430;
}

.gateway-link small {
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
}

.gateway-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: 18px;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

body[data-mode="customer"] .admin-shell {
  grid-template-columns: 232px minmax(0, 1fr);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--space-4);
  border-right: 1px solid rgba(255, 255, 255, 0.78);
  padding: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(24px) saturate(1.35);
}

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #111319, var(--signal) 58%, var(--signal-2));
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(0, 113, 227, 0.24);
}

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

.admin-brand strong {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
}

.admin-brand small {
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 12px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(234, 238, 245, 0.72);
  box-shadow: var(--inset-soft);
}

.mode-switch button,
.admin-nav button {
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-3);
  text-align: left;
}

.mode-switch button {
  min-height: 34px;
  padding: 0 11px;
  font-weight: 700;
}

.mode-switch button.active,
.admin-nav button.active {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(38, 47, 67, 0.08);
}

.admin-nav {
  display: grid;
  gap: 4px;
  min-height: 0;
  align-content: start;
  overflow: auto;
  padding-right: 2px;
}

.nav-group-label {
  margin: 10px 8px 2px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.nav-group-label:first-child {
  margin-top: 0;
}

.admin-nav button {
  min-height: 36px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 650;
}

body[data-mode="customer"] .admin-nav {
  gap: 6px;
}

body[data-mode="customer"] .admin-nav button {
  min-height: 40px;
}

body[data-mode="grav"] [data-customer-only],
body[data-mode="customer"] [data-grav-only] {
  display: none !important;
}

.session-card {
  display: grid;
  align-self: end;
  gap: 10px;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(246, 248, 252, 0.66));
  box-shadow: 0 12px 26px rgba(38, 47, 67, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.session-person {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.session-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(0, 113, 227, 0.14);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(225, 236, 251, 0.86));
  color: var(--signal);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88), 0 8px 16px rgba(0, 113, 227, 0.1);
}

.session-label {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 750;
}

.session-card strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card small {
  display: block;
  overflow: hidden;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.session-meta span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid rgba(33, 40, 54, 0.08);
  border-radius: 999px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.session-meta span:last-child {
  border-color: rgba(48, 176, 95, 0.18);
  background: rgba(48, 176, 95, 0.08);
  color: #1a7b3b;
}

.session-actions,
.topbar-actions,
.table-actions,
.modal-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

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

.session-actions .small-button {
  min-width: 0;
  padding-inline: 8px;
}

.admin-main {
  min-width: 0;
  padding: 18px 22px 32px;
}

.admin-topbar {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(24px) saturate(1.35);
}

.admin-topbar h1 {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 420;
  line-height: 1.08;
}

.admin-topbar p {
  margin: 7px 0 0;
  color: var(--ink-3);
  font-size: 13px;
}

.eyebrow {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.prototype-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 113, 227, 0.16);
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(0, 113, 227, 0.08);
  color: var(--signal);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.ghost-button,
.primary-button,
.danger-button,
.success-button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font-weight: 650;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(38, 47, 67, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

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

.primary-button,
.success-button {
  border-color: rgba(0, 113, 227, 0.16);
  background: linear-gradient(180deg, #3aa0ff, var(--signal));
  color: #fff;
  box-shadow: 0 12px 24px rgba(0, 113, 227, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.success-button {
  background: linear-gradient(180deg, #46d77a, var(--success));
}

.danger-button {
  border-color: rgba(229, 72, 77, 0.18);
  color: var(--danger);
}

.auth-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: 16px;
  border: 1px solid rgba(229, 72, 77, 0.16);
  border-radius: var(--radius-lg);
  padding: 15px 16px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

.auth-banner strong {
  display: block;
  margin-top: 4px;
}

.auth-banner p {
  margin: 4px 0 0;
  color: var(--ink-3);
}

body[data-auth="signed-out"] .auth-banner {
  display: flex;
}

body[data-auth="signed-out"] .metric-grid,
body[data-auth="signed-out"] .admin-grid,
body[data-auth="signed-out"] .table-panel {
  opacity: 0.35;
  pointer-events: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: 16px;
}

.metric-card,
.panel {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  backdrop-filter: blur(20px) saturate(1.25);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 116px;
  padding: 15px;
}

.metric-card strong {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 420;
  line-height: 1;
}

.metric-card small {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.35;
}

.metric-trend {
  display: inline-flex;
  width: max-content;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: rgba(34, 164, 90, 0.1);
  color: #18884a;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.85fr);
  gap: var(--space-4);
  margin-top: 16px;
}

body[data-mode="customer"] .admin-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.9fr);
}

.panel {
  min-width: 0;
  padding: var(--space-4);
}

.panel-heading,
.panel-heading.row,
.record-row,
.security-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading.row,
.record-row,
.security-row {
  align-items: center;
}

.panel-heading strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.compact-dashboard {
  margin-top: var(--space-3);
}

.review-entry-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-4);
  align-items: end;
  min-width: 0;
  border: 1px solid rgba(0, 113, 227, 0.14);
  border-radius: var(--radius-lg);
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(0, 113, 227, 0.12), rgba(0, 113, 227, 0)),
    rgba(255, 255, 255, 0.72);
}

.review-entry-card strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.2;
}

.review-entry-card p {
  max-width: 560px;
  margin: 8px 0 0;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
}

.record-list,
.security-list,
.mini-list,
.detail-list,
.detail-note-list,
.form-grid,
.status-stack {
  display: grid;
  gap: var(--space-2);
}

.price-card,
.record-row,
.detail-row,
.security-row,
.mini-item,
.role-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.56);
}

.link-record-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) max-content minmax(420px, max-content);
  align-items: center;
}

.project-record-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(120px, 0.35fr) minmax(280px, max-content);
  align-items: center;
}

.link-record-main {
  min-width: 0;
}

.link-status {
  justify-self: end;
}

.link-row-actions,
.review-actions,
.detail-review-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.link-row-actions,
.review-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.detail-review-actions {
  grid-column: 1 / -1;
  flex-wrap: wrap;
}

.pin-chip {
  display: inline-flex;
  width: 104px;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(0, 113, 227, 0.14);
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(0, 113, 227, 0.07);
  color: var(--signal);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.pin-chip span {
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 700;
}

.pin-chip strong {
  color: var(--signal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.topbar-pin {
  flex: 0 0 auto;
}

.table-pin {
  width: 96px;
  min-height: 28px;
}

.muted-value {
  color: var(--ink-3);
}

.data-table a,
.detail-row a {
  color: var(--signal);
  font-weight: 700;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.share-ready-panel {
  display: grid;
  gap: var(--space-4);
}

.share-ready-hero,
.share-link-card,
.share-note-card,
.share-info-grid > div {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.share-ready-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  border-radius: var(--radius-md);
  padding: 16px;
}

.share-ready-hero h3 {
  margin: 6px 0 0;
  font-size: 24px;
  line-height: 1.15;
}

.share-ready-hero p {
  margin: 8px 0 0;
  color: var(--ink-3);
  line-height: 1.55;
}

.share-link-card,
.share-note-card {
  display: grid;
  gap: 7px;
  border-radius: var(--radius-md);
  padding: 13px 14px;
}

.share-link-card span,
.share-note-card span,
.share-info-grid span {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
}

.share-link-card a {
  color: var(--signal);
  font-weight: 800;
  line-height: 1.45;
  text-decoration: none;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.share-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.share-info-grid > div {
  display: grid;
  gap: 6px;
  min-width: 0;
  border-radius: var(--radius-sm);
  padding: 11px 12px;
}

.share-info-grid strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-note-card strong {
  color: var(--ink);
  font-size: 13px;
}

.share-ready-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.share-ready-actions .primary-button {
  grid-column: 1 / -1;
}

.price-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.price-card strong,
.price-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 430;
  line-height: 1;
}

.price-card strong small,
.price-summary strong small {
  color: var(--ink-3);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 650;
}

.price-card p,
.price-summary p {
  margin: 8px 0 0;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.45;
}

.price-card > div > small {
  display: block;
  margin-top: 8px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
}

.compact-heading {
  margin-top: var(--space-4);
}

.price-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px;
  background: rgba(247, 249, 252, 0.74);
}

.price-summary > small {
  display: block;
  margin-top: 8px;
  color: var(--ink-3);
  font-size: 12px;
}

.share-copy-box {
  min-height: 170px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px;
  background: rgba(247, 249, 252, 0.84);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

.record-row div,
.detail-row div,
.mini-item div,
.security-row div {
  min-width: 0;
}

.record-row strong,
.detail-row strong,
.mini-item strong,
.security-row strong,
.role-row strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-row small,
.detail-row span,
.mini-item small,
.security-row small,
.role-row small {
  display: block;
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 12px;
}

.detail-panel {
  display: grid;
  gap: var(--space-4);
}

.detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(246, 248, 252, 0.78));
}

.detail-hero h3 {
  margin: 5px 0 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 450;
  line-height: 1.05;
}

.detail-hero p {
  margin: 8px 0 0;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.45;
}

.detail-section {
  display: grid;
  gap: var(--space-2);
}

.detail-label {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(88px, 0.42fr) minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
}

.detail-row span {
  margin: 0;
  text-transform: none;
}

.detail-row strong {
  white-space: normal;
}

.detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.detail-actions .detail-action:first-child:nth-last-child(1),
.detail-actions .detail-action:first-child:nth-last-child(3) {
  grid-column: 1 / -1;
}

.detail-progress {
  position: relative;
  display: inline-flex;
  overflow: hidden;
  width: 100%;
  max-width: 140px;
  height: 8px;
  border-radius: 999px;
  background: #e7ebf1;
  vertical-align: middle;
  box-shadow: var(--inset-soft);
}

.detail-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--signal), var(--success));
}

.detail-row em {
  margin-left: 8px;
  color: var(--ink-3);
  font-style: normal;
  font-size: 12px;
}

.compact-payment {
  margin-bottom: var(--space-4);
}

.status-pill,
.plan-pill,
.risk-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: rgba(0, 113, 227, 0.08);
  color: var(--signal);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.active,
.status-pill.paid,
.status-pill.sent,
.status-pill.ok,
.risk-pill.low {
  background: rgba(34, 164, 90, 0.12);
  color: #18884a;
}

.status-pill.pending,
.status-pill.warning,
.status-pill.queued,
.status-pill.processing,
.risk-pill.medium {
  background: rgba(255, 214, 10, 0.18);
  color: #8a5a00;
}

.status-pill.suspended,
.status-pill.failed,
.status-pill.revoked,
.status-pill.high,
.status-pill.provider,
.risk-pill.high {
  background: rgba(229, 72, 77, 0.1);
  color: var(--danger);
}

.status-pill.working,
.status-pill.local,
.status-pill.saved,
.status-pill.created {
  background: rgba(34, 164, 90, 0.12);
  color: #18884a;
}

.status-pill.self-serve {
  background: rgba(129, 117, 255, 0.1);
  color: #5f52d7;
}

.status-pill.medium {
  background: rgba(255, 214, 10, 0.18);
  color: #8a5a00;
}

.status-pill.low {
  background: rgba(0, 113, 227, 0.08);
  color: var(--signal);
}

.plan-pill.enterprise {
  background: rgba(129, 117, 255, 0.1);
  color: #5f52d7;
}

.table-panel {
  margin-top: 16px;
}

.data-table {
  overflow: auto;
}

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

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 9px;
  color: var(--ink-2);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.data-table td strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.data-table td small {
  display: block;
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 12px;
}

.data-table tr.selectable-row {
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease;
}

.data-table tr.selectable-row:hover {
  background: rgba(0, 113, 227, 0.045);
}

.data-table tr.selected-row {
  background: rgba(0, 113, 227, 0.07);
  box-shadow: inset 3px 0 0 var(--signal);
}

.data-table tr.selected-row td:first-child {
  color: var(--ink);
}

.pin-code {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.usage-meter {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #e7ebf1;
  box-shadow: var(--inset-soft);
}

.usage-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--signal), var(--signal-2));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 60;
  max-width: min(520px, calc(100vw - 32px));
  transform: translate(-50%, 18px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: rgba(29, 29, 31, 0.84);
  color: #fff;
  box-shadow: 0 20px 54px rgba(29, 29, 31, 0.28);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(20px) saturate(1.4);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(245, 246, 248, 0.64);
  backdrop-filter: blur(18px) saturate(1.2);
}

.modal-layer.show {
  display: flex;
}

.modal-card {
  width: min(640px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 30px 80px rgba(38, 47, 67, 0.18);
  padding: var(--space-5);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.modal-head h2 {
  margin: 5px 0 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 450;
}

.form-grid label,
.modal-form label {
  display: grid;
  gap: 7px;
}

.form-grid span,
.modal-form span {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.form-grid input,
.form-grid select,
.modal-form input,
.modal-form select,
.modal-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 11px 12px;
  box-shadow: var(--inset-soft);
}

.modal-form textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.5;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink-2);
  font-size: 12px;
}

.check-line {
  display: flex !important;
  grid-auto-flow: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px !important;
  width: max-content;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink-2);
  font-size: 12px;
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--signal);
}

@media (max-width: 1180px) {
  .admin-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  body[data-mode="customer"] .admin-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

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

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

  .link-record-row,
  .project-record-row {
    grid-template-columns: 1fr;
  }

  .link-status,
  .link-row-actions {
    justify-self: start;
  }

  .link-row-actions,
  .review-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  body[data-mode="customer"] .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto;
  }

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

  .admin-topbar,
  .topbar-actions,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions a,
  .topbar-actions button,
  .topbar-actions .pin-chip,
  .modal-actions button {
    width: 100%;
  }

  .section-grid,
  .metric-grid,
  .review-entry-card,
  .checkbox-grid,
  .gateway-grid,
  .share-info-grid,
  .share-ready-actions,
  .detail-actions,
  .detail-row {
    grid-template-columns: 1fr;
  }

  .gateway-head h1 {
    font-size: 28px;
  }

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

  .gateway-actions a {
    width: 100%;
  }
}

/* ── GRAV STAGE 모바일 보강(≤640px) · 2026-06-22 ── */
@media (max-width: 640px){
  /* 헤더가 sticky라 모바일에서 371px로 화면을 덮던 문제 → 일반 흐름으로 */
  .admin-topbar{ position: static !important; top: auto !important; height: auto !important; margin-bottom: 14px; }
  /* 데이터 표: 부드러운 가로 스크롤 + 밀도 축소(컬럼 더 보이게) */
  .data-table{ overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }
  .data-table table{ font-size: 12px; }
  .data-table th, .data-table td{ padding: 8px 10px; white-space: nowrap; }
}

/* ── 토픽바 액션 버튼 글자 깨짐 방지(전역: 모바일·태블릿) · 2026-06-22 ── */
.topbar-actions{ flex-wrap: wrap; align-items: center; }
.topbar-actions .ghost-button,
.topbar-actions .primary-button,
.topbar-actions button,
.topbar-actions a{ white-space: nowrap; }

/* ── 모바일 마스터-디테일/레코드 행 짓눌림 해결(≤640px) · 2026-06-22 ── */
@media (max-width: 640px){
  /* admin-grid가 "0px 340px"로 리스트 칸을 0으로 만들던 문제 → 1열 스택 */
  .admin-grid{ grid-template-columns: 1fr !important; }
  .admin-grid > *{ min-width: 0; }
  /* 레코드 행: 제목/상태/액션을 세로로 */
  .record-row{ grid-template-columns: 1fr !important; }
  .record-row > *{ min-width: 0; width: auto; }
  .status-stack{ flex-wrap: wrap; align-items: center; }
  .inline-actions, .review-actions{ flex-wrap: wrap; }
  .usage-meter{ width: 100%; }
}
