/* Workspace surfaces share the public-site theme tokens. */

.app-body {
  --app-header: rgba(13, 10, 8, 0.92);
  --app-title-surface: rgba(13, 10, 8, 0.6);
  --app-panel: rgba(13, 10, 8, 0.88);
  --app-card: rgba(11, 9, 7, 0.94);
  --app-table: rgba(11, 9, 7, 0.7);
  --app-table-head: rgba(20, 16, 12, 0.95);
  --app-hairline: rgba(255, 255, 255, 0.04);
  --app-control: rgba(11, 9, 7, 0.85);
  --app-footer: rgba(8, 6, 4, 0.8);
  --app-hover: rgba(255, 255, 255, 0.03);
  --app-shadow: rgba(0, 0, 0, 0.35);
  background:
    radial-gradient(900px 540px at 90% -10%, rgba(255, 77, 0, 0.10), transparent 65%),
    radial-gradient(700px 480px at 0% 110%, rgba(85, 215, 255, 0.06), transparent 65%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-site-top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--app-header);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) auto;
  align-items: center;
}

.app-nav {
  display: flex;
  gap: 0;
  padding: 0;
  border: 0;
}

.app-nav-link {
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  min-height: 74px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-right: 1px solid var(--line);
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.app-nav-link:hover {
  color: var(--text);
  background: var(--app-hover);
}

.app-nav-link.is-active {
  color: var(--orange);
  background:
    linear-gradient(180deg, rgba(255, 77, 0, 0.12), transparent 80%);
  box-shadow: inset 0 -2px 0 var(--orange);
}

.app-logout {
  margin: 0;
  padding: 0;
}

.app-logout button {
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--sans);
}

.app-logout button:hover {
  color: var(--red, #ff7a7a);
  background: rgba(255, 122, 122, 0.06);
}

.app-titlebar {
  padding: 32px 0 6px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(700px 280px at 0% 0%, rgba(255, 77, 0, 0.10), transparent 70%),
    var(--app-title-surface);
}

.app-titlebar h1 {
  margin: 6px 0 10px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, #ffd178 60%, #ff4d00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.app-eyebrow {
  margin: 0;
  color: var(--orange);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: 720px;
}

.app-main {
  padding: 24px 0 48px;
}

.app-main .container {
  display: grid;
  gap: 18px;
}

.app-section {
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--app-panel);
}

.app-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.app-section-head h2 {
  margin: 4px 0 6px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.app-section-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  max-width: 640px;
}

.app-section-sub strong {
  color: var(--text);
}

.app-notice {
  padding: 12px 14px;
  border: 1px solid rgba(189, 255, 99, 0.45);
  border-radius: 10px;
  background: rgba(189, 255, 99, 0.06);
  color: var(--green);
  font-family: var(--mono);
  font-size: 12px;
}

.app-notice.is-warning {
  border-color: rgba(255, 138, 0, 0.55);
  background: rgba(255, 77, 0, 0.08);
  color: var(--orange-2);
}

.app-notice code {
  color: var(--text);
  font-family: var(--mono);
}

/* KPI cards, clickable when href is set. */
.app-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.app-kpi-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--app-card);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.app-kpi-card.is-link:hover {
  border-color: var(--orange);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px var(--app-shadow);
}

.app-kpi-card.is-orange {
  border-color: rgba(255, 138, 0, 0.45);
  background:
    linear-gradient(135deg, rgba(255, 77, 0, 0.10), transparent 70%),
    var(--app-card);
}

.app-kpi-card.is-cyan {
  border-color: rgba(85, 215, 255, 0.35);
  background:
    linear-gradient(135deg, rgba(68, 233, 255, 0.10), transparent 70%),
    var(--app-card);
}

.app-kpi-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.app-kpi-card.is-orange .app-kpi-label { color: var(--orange); }
.app-kpi-card.is-cyan .app-kpi-label { color: var(--cyan); }

.app-kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--text);
  word-break: break-word;
}

.app-kpi-detail {
  color: var(--dim);
  font-size: 12px;
  line-height: 1.45;
}

.app-kpi-cta {
  margin-top: auto;
  color: var(--orange);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-kpi-card.is-cyan .app-kpi-cta { color: var(--cyan); }

/* Table */
.app-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--app-table);
}

.app-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.app-table th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--app-table-head);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
}

.app-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--app-hairline);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.app-empty {
  text-align: center;
  color: var(--dim);
  padding: 22px;
  font-style: italic;
}

/* CTA row (Need help section) */
.app-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-inline-form {
  margin: 0;
  display: inline-flex;
}

.app-cta,
.app-inline-form .app-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--app-control);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
}

.app-cta:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: rgba(255, 77, 0, 0.08);
}

.app-cta.is-primary {
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  border-color: var(--orange);
  color: var(--bg);
}

.app-cta.is-primary:hover {
  filter: brightness(1.08);
  color: var(--bg);
}

.app-footer {
  padding: 24px 0 32px;
  border-top: 1px solid var(--line);
  background: var(--app-footer);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
}

.app-footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 1100px) {
  .app-site-top { grid-template-columns: 1fr; }
  .app-nav { overflow-x: auto; }
  .app-nav-link { min-height: 52px; }
  .app-kpi-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .app-kpi-grid { grid-template-columns: 1fr; }
}

/* Keep workspace controls together even when the Admin link is present. */
.app-header-actions {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}
.app-header-actions .top-action { white-space: nowrap; }
.app-header-actions .app-logout { display: flex; }
.app-theme-toggle { align-self: center; margin: 10px 12px; white-space: nowrap; }
.app-main .container > *, .app-kpi-grid > * { min-width: 0; }
.app-body :is(a, button, input):focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}

:root[data-theme="light"] .app-body {
  --app-header: rgba(255, 255, 255, 0.96);
  --app-title-surface: #f4f7fb;
  --app-panel: #ffffff;
  --app-card: #ffffff;
  --app-table: #ffffff;
  --app-table-head: #f4f7fb;
  --app-hairline: #e0e6ef;
  --app-control: #ffffff;
  --app-footer: #f4f7fb;
  --app-hover: rgba(13, 23, 36, 0.04);
  --app-shadow: rgba(13, 23, 36, 0.10);
  background: var(--bg);
}
:root[data-theme="light"] .app-titlebar h1 {
  background: none;
  color: var(--text);
}
:root[data-theme="light"] .app-cta.is-primary {
  background: var(--orange);
  color: #0d1724;
}
:root[data-theme="light"] .app-cta.is-primary:hover {
  color: #0d1724;
}

@media (max-width: 1100px) {
  .app-header-actions { flex-wrap: wrap; border-top: 1px solid var(--line); }
  .app-header-actions .top-action { min-height: 44px; border-top: 0; }
}
@media (max-width: 600px) {
  .app-header-actions { justify-content: center; }
  .app-header-actions > * { flex: 1 1 auto; }
  .app-theme-toggle { flex: 0 0 auto; }
  .app-header-actions .app-logout button { width: 100%; }
  .app-section { padding: 18px 14px; }
}

/* Public header breakpoints must not place workspace items in implicit columns. */
.app-site-top > .brand-cell { grid-column: 1; grid-row: 1; }
.app-site-top > .app-nav { grid-column: 2; grid-row: 1; }
.app-site-top > .app-header-actions { grid-column: 3; grid-row: 1; }
.app-site-top .app-theme-toggle {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  font-size: 11px;
  white-space: nowrap;
}
.app-site-top .app-nav-link { min-height: 74px; }
@media (max-width: 1100px) {
  .app-site-top > .brand-cell { grid-column: 1 / -1; grid-row: 1; }
  .app-site-top > .app-nav { grid-column: 1 / -1; grid-row: 2; }
  .app-site-top > .app-header-actions { grid-column: 1 / -1; grid-row: 3; }
  .app-site-top .app-nav-link { min-height: 44px; }
}
