/* GrayLabs hub — grey on white */

:root {
  --white: #ffffff;
  --gray-25: #fcfcfc;
  --gray-50: #f7f7f8;
  --gray-100: #f0f0f2;
  --gray-150: #e8e8eb;
  --gray-200: #dfdfe3;
  --gray-300: #c9c9cf;
  --gray-400: #a1a1aa;
  --gray-500: #74747d;
  --gray-600: #55555d;
  --gray-700: #3f3f46;
  --gray-800: #2a2a2f;
  --gray-900: #18181b;

  --bg: var(--white);
  --bg-subtle: var(--gray-50);
  --surface: var(--white);
  --border: var(--gray-150);
  --border-strong: var(--gray-200);
  --text: var(--gray-800);
  --text-strong: var(--gray-900);
  --text-muted: var(--gray-500);
  --accent: var(--gray-800);
  --accent-hover: var(--gray-900);

  --danger-bg: #fbf1f1;
  --danger-border: #f0d4d4;
  --danger-text: #9b2c2c;
  --success-bg: #f1f8f3;
  --success-border: #d3e8da;
  --success-text: #23663b;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgb(24 24 27 / 0.04);
  --shadow: 0 1px 2px rgb(24 24 27 / 0.04), 0 4px 12px rgb(24 24 27 / 0.04);
  --shadow-lg: 0 2px 4px rgb(24 24 27 / 0.04), 0 12px 32px rgb(24 24 27 / 0.08);
  --ring: 0 0 0 3px rgb(63 63 70 / 0.14);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 1120px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3 { color: var(--text-strong); margin: 0; letter-spacing: -0.015em; line-height: 1.25; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); }

.icon { width: 18px; height: 18px; flex: none; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgb(255 255 255 / 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; color: var(--text-strong); letter-spacing: -0.01em; }
.logo-mark { width: 28px; height: 28px; color: var(--gray-800); }

.nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--gray-50); color: var(--text-strong); }
.nav-link.is-active { background: var(--gray-100); color: var(--text-strong); }
.nav-link .icon { width: 16px; height: 16px; }

/* account menu (pure CSS via <details>) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-trigger {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.menu-trigger:hover, .menu[open] .menu-trigger { background: var(--gray-50); border-color: var(--border); }
.menu-trigger .icon { width: 16px; height: 16px; color: var(--text-muted); transition: transform .15s; }
.menu[open] .menu-trigger .icon { transform: rotate(180deg); }
.menu-name { font-size: 14px; font-weight: 500; color: var(--text-strong); }
.avatar {
  width: 30px; height: 30px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--gray-700); color: var(--white);
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
}
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 232px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px;
  animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-head-name { font-weight: 600; color: var(--text-strong); font-size: 14px; }
.menu-head-sub { font-size: 13px; color: var(--text-muted); }
.menu-panel form { margin: 0; }
.menu-item {
  display: flex; width: 100%; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: none; border: 0; cursor: pointer; text-align: left;
  color: var(--text); text-decoration: none; font-size: 14px;
}
.menu-item:hover { background: var(--gray-50); color: var(--text-strong); }
.menu-item .icon { width: 16px; height: 16px; color: var(--text-muted); }

/* ---------- page ---------- */

main.container { flex: 1; padding-top: 40px; padding-bottom: 56px; }
.page-head { margin-bottom: 36px; }
.page-head h1 { font-size: 30px; font-weight: 650; }
.eyebrow { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }

.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.section-head h2 { font-size: 16px; font-weight: 600; }
.count {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: var(--gray-100); border-radius: 999px; padding: 1px 8px;
}

/* apps */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.app-card {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.app-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.app-icon {
  width: 44px; height: 44px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--gray-100); color: var(--gray-700); font-weight: 650; font-size: 16px;
}
.app-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.app-name { font-weight: 600; color: var(--text-strong); }
.app-desc { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-go { color: var(--gray-300); transition: color .15s; }
.app-card:hover .app-go { color: var(--gray-600); }
.app-go .icon { width: 16px; height: 16px; }

.empty {
  text-align: center; padding: 56px 24px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--gray-25);
}
.empty-icon {
  width: 48px; height: 48px; margin: 0 auto 16px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--white); border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--gray-500);
}
.empty h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty p { color: var(--text-muted); font-size: 14px; }

/* settings */
.settings { display: grid; gap: 20px; max-width: 640px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); }
.panel-head { margin-bottom: 20px; }
.panel-head h2 { font-size: 16px; font-weight: 600; }
.panel-head p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.meta { margin: 0; display: grid; gap: 0; }
.meta > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-top: 1px solid var(--border); }
.meta > div:first-child { border-top: 0; padding-top: 0; }
.meta dt { color: var(--text-muted); font-size: 14px; }
.meta dd { margin: 0; font-weight: 500; color: var(--text-strong); font-size: 14px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--gray-100); color: var(--gray-700); }

/* ---------- forms ---------- */

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.label { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.input {
  width: 100%; height: 42px; padding: 0 12px;
  font: inherit; font-size: 15px; color: var(--text-strong);
  background: var(--white); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input:hover { border-color: var(--gray-300); }
.input:focus { outline: none; border-color: var(--gray-500); box-shadow: var(--ring); }
.form-actions { display: flex; justify-content: flex-end; padding-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--white); box-shadow: var(--shadow-sm), inset 0 1px 0 rgb(255 255 255 / 0.08); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--white); color: var(--text-strong); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-block { width: 100%; margin-top: 4px; }

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid;
  font-size: 14px; margin-bottom: 18px;
}
.alert .icon { margin-top: 1px; }
.alert-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.settings + .alert, .page-head + .alert { max-width: 640px; }

/* ---------- auth ---------- */

.auth-body {
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--gray-100), transparent 70%),
    var(--bg-subtle);
}
.auth { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 36px 32px 32px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text-strong); margin-bottom: 28px; }
.auth-brand .logo-mark { width: 32px; height: 32px; }
.auth-title { font-size: 22px; font-weight: 650; }
.auth-sub { color: var(--text-muted); font-size: 14px; margin: 6px 0 24px; }
.auth-foot { display: flex; align-items: center; gap: 6px; margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.auth-foot .icon { width: 14px; height: 14px; }

.error-page { text-align: center; max-width: 420px; margin: 40px auto; display: grid; gap: 10px; justify-items: center; }
.error-code { font-size: 13px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.08em; }
.error-page h1 { font-size: 24px; }
.error-page p:not(.error-code) { color: var(--text-muted); margin-bottom: 12px; }

.footer { padding-top: 20px; padding-bottom: 28px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .container, .topbar-inner { padding-left: 16px; padding-right: 16px; }
  .topbar-inner { gap: 12px; }
  .brand span, .menu-name, .nav-link span { display: none; }
  main.container { padding-top: 28px; }
  .page-head h1 { font-size: 24px; }
  .auth-card { padding: 28px 22px 24px; }
  .panel { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- admin ---------- */

.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-sub { color: var(--text-muted); margin-top: 6px; }
.profile-head .page-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-sub strong { color: var(--text-strong); font-weight: 600; }
.page-head + .alert { max-width: 640px; }
.section-spaced { margin-top: 40px; }
.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.95em; }
.hint { font-size: 13px; color: var(--text-muted); }

.back-link {
  display: inline-flex; align-items: center; gap: 4px; margin: -12px 0 20px -6px;
  padding: 4px 8px 4px 4px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 14px; font-weight: 500; text-decoration: none;
}
.back-link:hover { color: var(--text-strong); background: var(--gray-50); }
.back-link .icon { width: 16px; height: 16px; }

.btn .icon { width: 16px; height: 16px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--gray-100); color: var(--text-strong); }
.btn-danger { background: var(--white); color: var(--danger-text); border-color: var(--danger-border); box-shadow: var(--shadow-sm); }
.btn-danger:hover { background: var(--danger-bg); }
.form .btn-danger[type=submit] { background: #b42318; color: var(--white); border-color: #b42318; }
.form .btn-danger[type=submit]:hover { background: #912018; }
.btn.is-done { color: var(--success-text); border-color: var(--success-border); background: var(--success-bg); }
.form-actions { gap: 10px; }

.badge-ok { background: var(--success-bg); color: var(--success-text); }
.badge-warn { background: #fdf6e7; color: #8a5a00; }
.badge-muted { background: var(--gray-100); color: var(--gray-500); }
.you { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text-muted); vertical-align: middle; letter-spacing: 0; }

.avatar-sm { width: 34px; height: 34px; font-size: 12px; flex: none; background: var(--gray-150); color: var(--gray-700); }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; flex: none; }
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head h1 { font-size: 26px; }

/* table */
.panel-flush { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 12px 16px; background: var(--gray-25); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--gray-25); }
.table tr.is-disabled .user-cell { opacity: 0.6; }
.table .num { text-align: right; }
.row-action { text-align: right; width: 1%; }
.user-cell { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.user-cell-text { display: flex; flex-direction: column; line-height: 1.35; }
.user-cell-name { font-weight: 600; color: var(--text-strong); }
.user-cell-sub { font-size: 13px; color: var(--text-muted); }

/* activity */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: baseline; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.activity li:first-child { border-top: 0; padding-top: 0; }
.activity li:last-child { padding-bottom: 0; }
.activity-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--gray-300); flex: none; transform: translateY(-2px); }
.activity-text { flex: 1; min-width: 0; }
.activity-text strong { font-weight: 600; color: var(--text-strong); }
.activity-time { color: var(--text-muted); font-size: 13px; white-space: nowrap; }

/* role chooser */
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset legend { padding: 0; margin-bottom: 6px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { position: relative; display: flex; gap: 10px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.choice:hover { border-color: var(--gray-300); }
.choice:has(input:checked) { border-color: var(--gray-700); background: var(--gray-25); box-shadow: 0 0 0 1px var(--gray-700); }
.choice:has(input:disabled) { cursor: not-allowed; opacity: 0.65; }
.choice input { margin: 3px 0 0; accent-color: var(--gray-800); }
.choice-body { display: flex; flex-direction: column; }
.choice-title { font-weight: 600; font-size: 14px; color: var(--text-strong); }
.choice-desc { font-size: 13px; color: var(--text-muted); }
.input:disabled { background: var(--gray-50); color: var(--text-muted); box-shadow: none; }

/* actions */
.actions { display: grid; }
.action-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.actions .action-row:first-child { border-top: 0; padding-top: 0; }
.actions .action-row:last-child { padding-bottom: 0; }
.panel-danger .action-row { border: 0; padding: 0; }
.action-row form { margin: 0; flex: none; }
.action-row > .btn { flex: none; }
.action-title { font-weight: 600; font-size: 14px; color: var(--text-strong); }
.action-note { font-size: 13px; color: var(--text-muted); }
.panel-danger { border-color: var(--danger-border); }

/* one-time secret */
.secret { margin: 20px 0 16px; display: grid; gap: 6px; }
.secret-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; background: var(--gray-50); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.secret-value { flex: 1; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 16px; color: var(--text-strong); letter-spacing: 0.02em; word-break: break-all; user-select: all; }
.alert-warn { background: #fdf6e7; border-color: #f3e2b8; color: #7a4f00; }

@media (max-width: 640px) {
  .choices { grid-template-columns: 1fr; }
  .action-row { flex-direction: column; align-items: stretch; }
  .action-row .btn { width: 100%; }
  .table th:nth-child(2), .table td:nth-child(2), .table th:nth-child(4), .table td:nth-child(4),
  .table th:nth-child(5), .table td:nth-child(5), .table th:nth-child(6), .table td:nth-child(6) { display: none; }
  .table td:nth-child(3) { text-align: right; } .table th:nth-child(3) { text-align: right; }
  .page-head-row .btn { height: 38px; padding: 0 14px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}
