:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #151d32;
  --panel-raised: #192440;
  --border: #283451;
  --border-soft: rgba(146, 174, 232, .18);
  --text: #edf2ff;
  --muted: #9badcc;
  --accent: #7aa7ff;
  --accent-strong: #9ebdff;
  --danger: #ff7c93;
  --good: #65d9a5;
  --warn: #f5c96a;
  --shadow: 0 24px 64px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, #18264a 0, transparent 32rem),
    radial-gradient(circle at 96% 16%, rgba(102, 120, 255, .12), transparent 25rem),
    var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.loading-bar {
  position: fixed;
  z-index: 50;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  transition: opacity .16s ease;
}
.loading-bar.is-active { opacity: 1; }
.loading-bar::after {
  content: "";
  display: block;
  width: 36%;
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-strong));
  transform: translateX(-110%);
}
.loading-bar.is-active::after { animation: progress-sweep 1.05s ease-in-out infinite; }

.shell { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 64px; }
.card {
  position: relative;
  overflow: hidden;
  background: rgba(21, 29, 50, .94);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.card:hover { border-color: rgba(122, 167, 255, .55); box-shadow: 0 28px 72px rgba(0, 0, 0, .28); transform: translateY(-1px); }
.card[aria-busy="true"]::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 16px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(122, 167, 255, .24);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spinner-rotate .68s linear infinite;
}
.auth-card { width: min(430px, 100%); margin: 9vh auto; animation: panel-in .45s both; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #b4cbff, #6c74ff 55%, #7f5aff);
  color: #071127;
  box-shadow: 0 8px 20px rgba(103, 118, 255, .28);
  font-weight: 900;
  font-size: 21px;
  letter-spacing: -.05em;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; letter-spacing: -.02em; }
h2 { font-size: 17px; letter-spacing: -.01em; }
h3 { font-size: 14px; }
.brand p, .muted { color: var(--muted); font-size: 13px; margin-top: 3px; }

form { display: grid; gap: 14px; margin-top: 22px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: #0d1427;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 11px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 167, 255, .16); background: #101a30; }
textarea { min-height: 90px; resize: vertical; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 9px;
  min-height: 40px;
  padding: 9px 13px;
  color: #071127;
  font-weight: 750;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  box-shadow: 0 8px 18px rgba(91, 129, 255, .14);
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease, opacity .15s ease, background .15s ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 11px 22px rgba(91, 129, 255, .22); }
button:active:not(:disabled) { transform: translateY(0) scale(.985); box-shadow: 0 4px 12px rgba(91, 129, 255, .15); }
button.secondary { color: var(--text); background: #273653; box-shadow: none; }
button.secondary:hover:not(:disabled) { background: #304363; }
button.danger { color: #2b0711; background: linear-gradient(135deg, #ffa2b0, var(--danger)); }
button:disabled { opacity: .48; cursor: not-allowed; box-shadow: none; }
button.is-loading { pointer-events: none; }
.button-spinner, .spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner-rotate .66s linear infinite;
}

.topbar, .section-title { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.topbar { margin-bottom: 20px; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.activity { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; animation: activity-in .18s both; }
.activity .spinner { width: 13px; height: 13px; border-color: rgba(158, 189, 255, .4); border-top-color: var(--accent-strong); }

.grid { display: grid; grid-template-columns: minmax(250px, .75fr) minmax(340px, 1.2fr) minmax(380px, 1.25fr); gap: 16px; align-items: start; }
#appView:not([hidden]) .grid > .card { animation: panel-in .38s both; }
#appView:not([hidden]) .grid > .card:nth-child(2) { animation-delay: 35ms; }
#appView:not([hidden]) .grid > .card:nth-child(3) { animation-delay: 70ms; }
#appView:not([hidden]) .grid > .card:nth-child(4) { animation-delay: 105ms; }
.assets-panel, .licenses-panel, .events-panel { min-height: 500px; }

.list { display: grid; gap: 9px; margin-top: 15px; }
.item {
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: linear-gradient(145deg, #111b31, #0f172a);
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  animation: item-in .26s both;
  animation-delay: calc(var(--item-index, 0) * 24ms);
}
.item:hover { border-color: rgba(122, 167, 255, .45); background: #131e36; transform: translateY(-1px); }
.item > button:first-child { width: 100%; min-height: 0; text-align: left; justify-content: flex-start; color: var(--text); background: transparent; box-shadow: none; padding: 0; }
.item > button:first-child:hover h3 { color: var(--accent-strong); }
.item h3 { font-size: 14px; }
.meta { color: var(--muted); font-size: 12px; margin-top: 5px; overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; margin: 7px 4px 0 0; border: 1px solid var(--border); border-radius: 999px; padding: 3px 7px; color: var(--muted); font-size: 11px; background: rgba(10, 17, 34, .5); }
.status-ACTIVE { color: var(--good); border-color: rgba(101, 217, 165, .3); }
.status-SUSPENDED, .status-REVOKED { color: var(--danger); border-color: rgba(255, 124, 147, .28); }
.event { border-left: 3px solid var(--border); padding: 10px 12px; background: #10182b; border-radius: 0 8px 8px 0; animation: item-in .24s both; animation-delay: calc(var(--item-index, 0) * 18ms); }
.event.ERROR, .event.SECURITY { border-left-color: var(--danger); }
.event.WARN { border-left-color: var(--warn); }
.event.INFO { border-left-color: var(--good); }
.event time { color: var(--muted); display: block; font-size: 11px; margin-top: 4px; }
.event pre { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font-size: 11px; margin: 7px 0 0; }
.empty { margin-top: 18px; color: var(--muted); font-size: 14px; }
.error { color: var(--danger); min-height: 18px; }
.notice { border: 1px solid var(--border); padding: 12px; margin-bottom: 16px; border-radius: 10px; background: #111c34; white-space: pre-wrap; animation: notice-in .24s both; }
.notice.good { border-color: rgba(101, 217, 165, .6); }
.notice.bad { border-color: rgba(255, 124, 147, .7); }

.skeleton-list { display: grid; gap: 10px; margin-top: 16px; }
.skeleton { height: 72px; overflow: hidden; border: 1px solid var(--border-soft); border-radius: 11px; background: #111a2f; position: relative; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(158, 189, 255, .08), transparent); animation: shimmer 1.35s ease-in-out infinite; }

.dialog-placeholder { color: var(--muted); }
dialog { color: var(--text); width: min(560px, calc(100% - 26px)); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 0; box-shadow: 0 32px 100px rgba(0, 0, 0, .55); }
dialog::backdrop { background: rgba(3, 6, 15, .75); backdrop-filter: blur(2px); }
dialog[open] #modalContent { animation: modal-in .2s both; }
#modalContent { padding: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

@keyframes spinner-rotate { to { transform: rotate(360deg); } }
@keyframes progress-sweep { 0% { transform: translateX(-115%); } 65%, 100% { transform: translateX(300%); } }
@keyframes panel-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes item-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes activity-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: translateY(0); } }
@keyframes notice-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes shimmer { 100% { transform: translateX(100%); } }

@media (max-width: 1050px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .events-panel { grid-column: 1 / -1; }
  .assets-panel { min-height: auto; }
}
@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 1440px); padding-top: 16px; }
  .grid { grid-template-columns: 1fr; }
  .events-panel { grid-column: auto; }
  .topbar { align-items: flex-start; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; }
  .two { grid-template-columns: 1fr; }
  .activity { min-height: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Account profile and hardware security-key controls */
.nav-button.is-current { border-color: var(--accent); color: var(--accent-strong); box-shadow: 0 0 0 1px rgba(122, 167, 255, .14) inset; }
.profile-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.profile-summary { grid-column: 1 / -1; }
.profile-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 0; }
.profile-details div { border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px; background: rgba(11, 16, 32, .28); }
.profile-details dt { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.profile-details dd { margin: 0; overflow-wrap: anywhere; }
.form-stack { display: grid; gap: 12px; }
.login-help { margin: -2px 0 0; font-size: 12px; line-height: 1.45; }
.security-key { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.security-key h3 { margin-bottom: 4px; }
@media (max-width: 760px) { .profile-layout { grid-template-columns: 1fr; } .profile-details { grid-template-columns: 1fr; } .security-key { align-items: flex-start; flex-direction: column; } }

/* Client portal and staff upgrade-request inbox */
.button-link, .portal-link { text-decoration: none; }
.button-link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 13px; border: 1px solid transparent; border-radius: 9px; color: #071127; font-weight: 750; line-height: 1.1; background: linear-gradient(135deg, var(--accent-strong), var(--accent)); box-shadow: 0 8px 18px rgba(91, 129, 255, .14); transition: transform .15s ease, filter .15s ease, box-shadow .15s ease, opacity .15s ease, background .15s ease; }
.button-link:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 11px 22px rgba(91, 129, 255, .22); }
.button-link:active { transform: translateY(0) scale(.985); box-shadow: 0 4px 12px rgba(91, 129, 255, .15); }
.button-link.secondary { color: var(--text); background: #273653; box-shadow: none; }
.button-link.secondary:hover { background: #304363; }
.auth-switch-button { display: inline-flex; width: 100%; margin-top: 0; }
.portal-link { display: inline-block; margin-top: 14px; color: var(--accent-strong); font-size: 13px; }
.portal-link:hover { text-decoration: underline; }
.client-login-actions { display: grid; gap: 10px; margin-top: 22px; }
.asset-action-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.module-download { white-space: nowrap; }
.module-source { min-height: 260px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.45; }
@media (max-width: 860px) { .asset-action-row { width: 100%; justify-content: flex-start; } .module-download { width: 100%; } }
.client-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.client-summary-grid .card { min-height: 126px; }
.client-stat { font-size: 34px; font-weight: 800; letter-spacing: -.04em; margin-top: 13px; color: var(--accent-strong); }
.client-sections { display: grid; gap: 16px; }
.client-license-list { display: grid; gap: 12px; margin-top: 16px; }
.client-license { padding: 15px; }
.client-license-header, .asset-usage-title, .server-usage-heading, .access-entry { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.asset-usage-list { display: grid; gap: 14px; margin-top: 14px; }
.asset-usage { border-top: 1px solid var(--border-soft); padding-top: 13px; }
.asset-usage:first-child { border-top: 0; padding-top: 0; }
.asset-usage-title { align-items: center; }
.server-usage-list { display: grid; gap: 9px; margin-top: 10px; }
.server-usage { border: 1px solid var(--border-soft); border-radius: 9px; padding: 10px; background: rgba(5, 11, 25, .26); }
.server-usage-heading { align-items: baseline; font-size: 13px; }
.usage-track { height: 7px; margin: 9px 0 7px; overflow: hidden; border-radius: 999px; background: rgba(158, 189, 255, .14); }
.usage-track span { display: block; height: 100%; min-width: 3px; border-radius: inherit; transition: width .35s ease; }
.util-good { background: var(--good); }
.util-warn { background: var(--warn); }
.util-critical { background: var(--danger); }
.usage-empty { margin: 11px 0 0; }
.request-message { margin: 12px 0; line-height: 1.5; white-space: pre-wrap; }
.staff-note { border-left: 3px solid var(--accent); margin: 12px 0; padding: 9px 11px; border-radius: 0 8px 8px 0; background: rgba(122, 167, 255, .08); }
.staff-note p { margin-top: 5px; line-height: 1.45; white-space: pre-wrap; }
.inbox-tabs { display: flex; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; }
.inbox-tabs .is-current { border-color: var(--accent); color: var(--accent-strong); box-shadow: 0 0 0 1px rgba(122, 167, 255, .14) inset; }
.inbox-request-meta { display: grid; gap: 5px; margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.access-form { grid-template-columns: minmax(220px, 1fr) minmax(200px, .8fr) auto; align-items: end; margin: 16px 0; }
.access-form button { margin-bottom: 0; }
.access-entry { align-items: center; }
@media (max-width: 860px) { .client-summary-grid { grid-template-columns: 1fr; } .access-form { grid-template-columns: 1fr; } .client-license-header, .asset-usage-title, .access-entry { flex-direction: column; } }


/* Client portal copy polish and stable empty Owner Events state */
.client-login-actions { margin-bottom: 18px; }
.client-login-actions + .login-help { margin-top: 0; }
.auth-card .client-login-actions > button,
.auth-card .client-login-actions > .auth-switch-button,
.auth-card > form > .auth-switch-button {
  width: 100%;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 9px;
}
.no-logs {
  display: grid;
  gap: 6px;
  min-height: 92px;
  align-content: center;
  padding: 14px;
  border: 1px dashed var(--border-soft);
  border-radius: 11px;
  background: rgba(13, 20, 39, .45);
}
.no-logs strong { color: var(--text); font-size: 14px; }
.no-logs span { color: var(--muted); font-size: 13px; }


/* Clawcadia Build Hardening */
.hardening-shell { max-width: 1100px; }
.hardening-card { margin-top: 18px; }
.hardening-top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hardening-nav-link { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.hardening-notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  margin: 14px 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(251, 191, 36, .38);
  border-radius: 10px;
  background: rgba(251, 191, 36, .08);
  color: var(--text);
}
.hardening-form { display: grid; gap: 14px; }
.hardening-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.hardening-options {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}
.hardening-options label { display: flex; gap: 9px; align-items: flex-start; color: var(--muted); }
.hardening-options input { width: auto; margin-top: 3px; }
.hardening-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hardening-actions button { min-width: 160px; }
#source, #output { min-height: 300px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 13px; line-height: 1.45; tab-size: 2; }
.hardening-warnings {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(251, 146, 60, .45);
  border-radius: 10px;
  background: rgba(251, 146, 60, .09);
}
.hardening-warnings ul { margin: 8px 0 0 18px; color: var(--muted); }
.hardening-checklist { display: grid; gap: 9px; margin: 0; padding-left: 22px; color: var(--muted); }
.hardening-checklist code { color: var(--text); }
@media (max-width: 640px) {
  .hardening-grid { grid-template-columns: 1fr; }
  .hardening-notice { grid-template-columns: 1fr; }
  .hardening-actions button { width: 100%; }
}


/* Clawcadia Build Hardening Button Consistency */
.dashboard-tool-link,
.hardening-nav-link {
  text-decoration: none;
  white-space: nowrap;
}
.hardening-top-actions .button-link {
  min-height: 40px;
}
.hardening-top-actions .button-link.secondary {
  color: var(--text);
  background: #273653;
  box-shadow: none;
}
.hardening-top-actions .button-link.secondary:hover {
  background: #304363;
}


/* Clawcadia Build Hardening Idle Spinner Fix */
/* Navigation must never look busy until a real form action begins. */
#hardeningNav,
.dashboard-tool-link,
.hardening-nav-link {
  animation: none !important;
}
#hardeningNav.is-loading,
.dashboard-tool-link.is-loading,
.hardening-nav-link.is-loading {
  pointer-events: auto;
  opacity: 1;
}
#hardeningNav .button-spinner,
.dashboard-tool-link .button-spinner,
.hardening-nav-link .button-spinner,
#hardeningNav .spinner,
.dashboard-tool-link .spinner,
.hardening-nav-link .spinner,
#hardeningNav .loading-spinner,
.dashboard-tool-link .loading-spinner,
.hardening-nav-link .loading-spinner {
  display: none !important;
  animation: none !important;
}
#hardeningNav::after,
.dashboard-tool-link::after,
.hardening-nav-link::after {
  content: none !important;
  display: none !important;
  animation: none !important;
}


/* Clawcadia Manager Capabilities */
.manager-capability-summary { margin-top: 8px; }
.manager-capability-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.capability-grid { display: grid; gap: 10px; margin: 14px 0; padding: 0; border: 0; }
.capability-option { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 11px 12px; border: 1px solid var(--border-soft); border-radius: 10px; background: rgba(255,255,255,.015); }
.capability-option input { width: auto; margin-top: 3px; }
.capability-option strong, .capability-option span { display: block; }
.capability-option span { margin-top: 3px; color: var(--muted); font-size: .9rem; }
