/* ═══════════════════════════════════════════════════════════════════
   360 Tech Box — Application Styles
   Custom layout (wa-page is Pro-only) using CSS grid + wa-drawer.
   Org-specific colors are applied dynamically via CSS custom properties.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--wa-color-surface-lowered, #f1f5f9);
  color: var(--wa-color-text-normal, #1e293b);
}

/* ═══════════════════════════════════════════════════════════════════
   App Shell Layout — CSS Grid
   ┌─────────────────────────────────────┐
   │              HEADER                 │
   ├──────────┬──────────────────────────┤
   │          │   MAIN HEADER            │
   │ SIDEBAR  ├──────────────────────────┤
   │          │   MAIN CONTENT           │
   ├──────────┴──────────────────────────┤
   │              FOOTER                 │
   └─────────────────────────────────────┘
   ═══════════════════════════════════════════════════════════════════ */

#app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

#app-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────────── */
#app-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--app-header-bg, #1e293b);
  color: var(--app-header-text, #f8fafc);
  min-height: 56px;
  z-index: 10;
}

#nav-toggle {
  color: inherit;
  font-size: 1.25rem;
  /* Hidden on desktop — sidebar is always visible */
  display: none;
}

#profile-trigger {
  color: inherit;
}

#org-logo {
  height: 40px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}

#org-title {
  font-family: var(--app-title-font, 'Black Ops One'), cursive;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-spacer {
  flex: 1;
}

#login-btn {
  white-space: nowrap;
  color: var(--app-header-text, #f8fafc);
  --wa-color-border-default: var(--app-header-text, #f8fafc);
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
#app-sidebar {
  background: var(--app-nav-bg, #f8fafc);
  border-right: 1px solid var(--wa-color-surface-border, #e2e8f0);
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

/* Navigation tree styling (shared between sidebar and mobile drawer) */
#app-nav wa-tree,
#mobile-nav wa-tree {
  --indent-size: 1rem;
}

#app-nav wa-tree-item::part(item),
#mobile-nav wa-tree-item::part(item) {
  border-radius: var(--wa-border-radius-m, 0.375rem);
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  transition: background-color 0.15s;
}

#app-nav wa-tree-item::part(item):hover,
#mobile-nav wa-tree-item::part(item):hover {
  background: color-mix(in oklab, var(--wa-color-surface-default, #fff) 85%, var(--wa-color-brand-fill-quiet, #2563eb));
}

#app-nav wa-tree-item[selected]::part(item),
#mobile-nav wa-tree-item[selected]::part(item) {
  background: color-mix(in oklab, var(--wa-color-surface-default, #fff) 70%, var(--wa-color-brand-fill-quiet, #2563eb));
  font-weight: 600;
}

/* Category headers (parent tree items) */
wa-tree-item[data-category]::part(item) {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wa-color-text-subdued, #64748b);
}

/* ── Settings View ────────────────────────────────────────────────── */
.settings-view {
  max-width: 480px;
  padding: 2rem 1.5rem;
}

.settings-view h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1.5rem 0;
  color: var(--wa-color-text-default, #1e293b);
}

.settings-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--wa-color-surface-border, #e2e8f0);
}

.settings-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  font-size: 0.9rem;
  color: var(--wa-color-text-default, #1e293b);
}

.settings-select {
  padding: 0.35rem 0.65rem;
  font-size: 0.875rem;
  border: 1px solid var(--wa-color-surface-border, #e2e8f0);
  border-radius: var(--wa-border-radius-m, 0.375rem);
  background: var(--wa-color-surface-default, #fff);
  color: var(--wa-color-text-default, #1e293b);
  cursor: pointer;
}

/* ── Main Area ────────────────────────────────────────────────────── */
#app-main {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--wa-color-surface-raised, #fff);
}


#main-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

#view-container {
  max-width: 800px;
  margin: 0 auto;
}

/* ── Footer ───────────────────────────────────────────────────────── */
#app-footer {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 1.25rem 1rem;
  font-size: 0.85rem;
  background: var(--wa-color-surface-lowered, #f1f5f9);
  border-top: 1px solid var(--wa-color-surface-border, #e2e8f0);
}

#app-footer a {
  color: var(--wa-color-text-subdued, #64748b);
  text-decoration: none;
  transition: color 0.15s;
}

#app-footer a:hover {
  color: var(--wa-color-brand-fill-loud, #2563eb);
  text-decoration: underline;
}

/* ── Mobile Drawer ────────────────────────────────────────────────── */
#mobile-drawer {
  --size: 280px;
}

#mobile-drawer nav {
  padding: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════════
   Voice Report Styles
   ═══════════════════════════════════════════════════════════════════ */

.voice-report-container {
  text-align: center;
  padding: 1rem 0;
}

.tool-view-header {
  margin-bottom: 1rem;
}

.tool-view-header wa-icon {
  font-size: 2rem;
  color: var(--wa-color-brand-fill-loud, #2563eb);
  margin-bottom: 0.4rem;
}

.tool-view-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
  color: var(--wa-color-text-default, #1e293b);
}

.voice-report-desc {
  color: var(--wa-color-text-subdued, #64748b);
  max-width: 400px;
  margin: 0 auto 2rem;
  line-height: 1.6;
}

/* Record Button */
.record-btn-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.record-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--wa-color-danger-fill-loud, #dc2626);
  animation: pulse-ring 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  pointer-events: none;
  display: none;
}

.record-pulse.active {
  display: block;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.4; }
  100% { transform: scale(1.6); opacity: 0; }
}

.record-button {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 2rem;
  color: #fff;
  background: var(--wa-color-brand-fill-loud, #2563eb);
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.record-button:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.record-button:active:not(:disabled) {
  transform: scale(0.97);
}

.record-button.recording {
  background: var(--wa-color-danger-fill-loud, #dc2626);
}

.record-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.record-status {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--wa-color-text-subdued, #64748b);
  margin-top: 0.25rem;
}

/* Transcription Results */
.transcription-result {
  text-align: left;
  margin-top: 2rem;
}

.transcription-result wa-card {
  margin-bottom: 1rem;
}

.transcription-section {
  margin-bottom: 1rem;
}

.transcription-section:last-child {
  margin-bottom: 0;
}

.transcription-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--wa-color-text-subdued, #64748b);
  margin-bottom: 0.35rem;
  display: block;
}

.transcription-text {
  background: var(--wa-color-surface-lowered, #f1f5f9);
  border-radius: var(--wa-border-radius-m, 0.375rem);
  padding: 0.75rem 1rem;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.transcription-text.original {
  font-style: italic;
  color: var(--wa-color-text-subdued, #64748b);
}

.copy-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════
   AI Assistant Styles
   ═══════════════════════════════════════════════════════════════════ */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 400px;
}

/* Empty state */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--wa-color-text-subdued, #64748b);
}

.chat-empty-state wa-icon {
  font-size: 3rem;
  color: var(--wa-color-brand-fill-loud, #2563eb);
  margin-bottom: 1rem;
}

.chat-empty-state h2 {
  margin: 0 0 0.5rem;
  color: var(--wa-color-text-normal, #1e293b);
}

.chat-empty-state p {
  max-width: 360px;
  line-height: 1.5;
}

.chat-empty-state .epic-tagline {
  font-size: 0.8rem;
  font-style: italic;
  margin-top: 0.75rem;
  max-width: 400px;
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Chat Bubbles */
.chat-bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  animation: bubble-in 0.2s ease-out;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--wa-color-brand-fill-loud, #2563eb);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--wa-color-surface-lowered, #f1f5f9);
  color: var(--wa-color-text-normal, #1e293b);
  border-bottom-left-radius: 0.25rem;
}

/* Typing Indicator */
.typing-indicator {
  display: inline-flex;
  gap: 0.3rem;
  padding: 0.75rem 1.25rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--wa-color-brand-fill-loud, #2563eb);
  animation: typing-bounce 1.4s infinite both;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.32s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Input Bar */
.chat-input-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 0;
  border-top: 1px solid var(--wa-color-surface-border, #e2e8f0);
  flex-wrap: wrap;
}

.chat-input-bar wa-input {
  flex: 1;
  min-width: 0;  /* Allow shrinking below natural width */
}

/* Group the action buttons so they stay together */
.chat-input-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-shrink: 0;
}

.chat-input-bar .mic-btn {
  font-size: 1.1rem;
}

.chat-input-bar .mic-btn.recording {
  --wa-button-background: var(--wa-color-danger-fill-loud, #dc2626);
  --wa-button-background-hover: var(--wa-color-danger-fill-loud, #dc2626);
  --wa-button-foreground: #fff;
  border-radius: 50%;
  animation: mic-pulse 1s infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Camera button in input bar */
.chat-input-bar #ai-camera-btn {
  font-size: 1.1rem;
}

/* ── Image Preview (above input bar) ───────────────────────────── */
.chat-image-preview {
  padding: 0.5rem 0;
  border-top: 1px solid var(--wa-color-surface-border, #e2e8f0);
}

.image-preview-inner {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.25rem;
  position: relative;
}

.chat-image-preview img {
  max-height: 120px;
  max-width: 200px;
  border-radius: var(--wa-border-radius-m, 0.375rem);
  object-fit: cover;
  border: 1px solid var(--wa-color-surface-border, #e2e8f0);
}

.chat-image-preview #ai-remove-image {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.65rem;
}

/* ── Image in Chat Bubbles ─────────────────────────────────────── */
.chat-bubble-image {
  max-width: 100%;
  max-height: 240px;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  display: block;
  object-fit: contain;
}

/* ── Markdown in Assistant Bubbles ─────────────────────────────── */
.chat-bubble-text.markdown p { margin: 0 0 0.5em; }
.chat-bubble-text.markdown p:last-child { margin-bottom: 0; }
.chat-bubble-text.markdown ul,
.chat-bubble-text.markdown ol { margin: 0.25em 0 0.5em 1.25em; padding: 0; }
.chat-bubble-text.markdown li { margin-bottom: 0.2em; }
.chat-bubble-text.markdown h1,
.chat-bubble-text.markdown h2,
.chat-bubble-text.markdown h3 { font-size: 1em; font-weight: 600; margin: 0.5em 0 0.25em; }
.chat-bubble-text.markdown code {
  background: rgba(0,0,0,0.08);
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-size: 0.875em;
  font-family: monospace;
}
.chat-bubble-text.markdown pre {
  background: rgba(0,0,0,0.08);
  padding: 0.6em 0.75em;
  border-radius: 4px;
  overflow-x: auto;
  margin: 0.5em 0;
}
.chat-bubble-text.markdown pre code { background: none; padding: 0; }
.chat-bubble-text.markdown blockquote {
  border-left: 3px solid var(--wa-color-brand-fill-loud, #2563eb);
  margin: 0.5em 0;
  padding-left: 0.75em;
  color: var(--wa-color-text-subdued, #64748b);
}
.chat-bubble-text.markdown strong { font-weight: 600; }
.chat-bubble-text.markdown hr { border: none; border-top: 1px solid rgba(0,0,0,0.15); margin: 0.5em 0; }

/* ── AI Disclaimer ──────────────────────────────────────────────── */
.chat-disclaimer {
  font-size: 0.7rem;
  color: var(--wa-color-text-subdued, #64748b);
  font-style: italic;
  margin-top: 0.5rem;
  opacity: 0.8;
}

/* ── TTS Speaker Button (per assistant bubble) ─────────────────── */
.chat-tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--wa-color-text-subdued, #64748b);
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}

.chat-tts-btn:hover {
  opacity: 1;
  color: var(--wa-color-brand-fill-loud, #2563eb);
}

/* ── Audio Player Bar ──────────────────────────────────────────── */
.chat-audio-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--wa-color-surface-lowered, #f1f5f9);
  border-radius: var(--wa-border-radius-m, 0.375rem);
  margin-bottom: 0.25rem;
}

.audio-scrubber-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.audio-scrubber {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--wa-color-surface-border, #cbd5e1);
  outline: none;
  cursor: pointer;
}

.audio-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--wa-color-brand-fill-loud, #2563eb);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.audio-scrubber::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--wa-color-brand-fill-loud, #2563eb);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.audio-time-display {
  font-size: 0.7rem;
  color: var(--wa-color-text-subdued, #64748b);
  text-align: center;
  line-height: 1;
}

/* ── Speaking Highlight ────────────────────────────────────────── */
.chat-bubble.speaking {
  outline: 2px solid var(--wa-color-brand-fill-loud, #2563eb);
  outline-offset: 2px;
}

/* Spinner inside the play/pause button while loading */
.chat-audio-player wa-spinner {
  font-size: 1rem;
  --indicator-color: var(--wa-color-brand-fill-loud, #2563eb);
}

/* ═══════════════════════════════════════════════════════════════════
   Org Manager (Super Admin)
   ═══════════════════════════════════════════════════════════════════ */

.org-manager {
  padding: 0.5rem 0;
}

.org-manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.org-manager-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--wa-color-text-default, #1e293b);
}

.org-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.org-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--wa-color-text-subdued, #64748b);
  border-bottom: 2px solid var(--wa-color-surface-border, #e2e8f0);
}

.org-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--wa-color-surface-border, #e2e8f0);
  vertical-align: middle;
}

.org-table-id {
  font-family: monospace;
  color: var(--wa-color-text-subdued, #64748b);
  white-space: nowrap;
}

.org-table-actions {
  display: flex;
  gap: 0.5rem;
  white-space: nowrap;
}

.org-table-empty {
  text-align: center;
  color: var(--wa-color-text-subdued, #64748b);
  padding: 2rem 0;
}

.org-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--wa-color-text-subdued, #64748b);
  padding: 1rem 0;
}

.org-error {
  color: var(--wa-color-danger-600, #dc2626);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Org Form */
.org-form {
  max-width: 560px;
}

.org-field {
  margin-bottom: 1.25rem;
}

.org-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--wa-color-text-default, #1e293b);
}

.org-required {
  color: var(--wa-color-danger-600, #dc2626);
}

.org-input {
  width: 100%;
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
  border: 1px solid var(--wa-color-surface-border, #e2e8f0);
  border-radius: var(--wa-border-radius-m, 0.375rem);
  background: var(--wa-color-surface-default, #fff);
  color: var(--wa-color-text-default, #1e293b);
}

.org-input:focus {
  outline: 2px solid var(--wa-color-brand-fill-loud, #2563eb);
  outline-offset: 1px;
  border-color: transparent;
}

.org-input[readonly] {
  background: var(--wa-color-surface-lowered, #f1f5f9);
  color: var(--wa-color-text-subdued, #64748b);
  cursor: default;
}

.org-hint {
  font-size: 0.78rem;
  color: var(--wa-color-text-subdued, #64748b);
  margin: 0.25rem 0 0;
}

.org-fieldset {
  border: 1px solid var(--wa-color-surface-border, #e2e8f0);
  border-radius: var(--wa-border-radius-m, 0.375rem);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.org-legend {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--wa-color-text-subdued, #64748b);
  padding: 0 0.35rem;
}

.org-color-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.org-color-picker {
  width: 38px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--wa-color-surface-border, #e2e8f0);
  border-radius: var(--wa-border-radius-m, 0.375rem);
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

.org-color-text {
  flex: 1;
}

.org-form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.org-textarea {
  resize: vertical;
  min-height: 8rem;
  font-family: inherit;
  line-height: 1.5;
}

.org-manager-header-actions {
  display: flex;
  gap: 0.5rem;
}

.tool-section {
  margin-bottom: 2rem;
}

.tool-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.tool-section-header h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--wa-color-text-default, #1e293b);
}

.user-tools-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-top: 0.5rem;
}

.user-tool-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.invite-success {
  max-width: 520px;
  padding: 1.5rem;
  border: 1px solid var(--wa-color-surface-border, #e2e8f0);
  border-radius: var(--wa-border-radius-m, 0.375rem);
  background: var(--wa-color-surface-lowered, #f1f5f9);
}

.invite-success wa-icon {
  font-size: 2rem;
  color: var(--wa-color-success-600, #16a34a);
  display: block;
  margin-bottom: 0.75rem;
}

.invite-mailto-btn {
  text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════════
   Placeholder / Coming Soon
   ═══════════════════════════════════════════════════════════════════ */

.placeholder-view {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--wa-color-text-subdued, #64748b);
}

.placeholder-view wa-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════════════════
   Responsive — Mobile (< 768px)
   Sidebar hides, hamburger shows, wa-drawer used for nav.
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  #app-body {
    grid-template-columns: 1fr;
  }

  #app-sidebar {
    display: none;
  }

  #nav-toggle {
    display: inline-flex;
  }

  #app-header {
    padding: 0.4rem 0.75rem;
  }

  #org-logo {
    height: 32px;
  }

  #org-title {
    font-size: 0.95rem;
  }

  #main-content {
    padding: 1rem;
  }

  .chat-container {
    height: calc(100vh - 180px);
    min-height: 350px;
  }

  .record-button {
    width: 76px;
    height: 76px;
    font-size: 1.6rem;
  }

  .chat-image-preview img {
    max-height: 80px;
    max-width: 150px;
  }

  .chat-bubble-image {
    max-height: 180px;
  }

  .chat-audio-player {
    padding: 0.4rem 0.5rem;
    gap: 0.35rem;
  }

  .audio-scrubber::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
  }

  .audio-scrubber::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }

  #app-footer {
    gap: 1rem;
    font-size: 0.8rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   Login Overlay
   Full-screen gate shown when the user is not authenticated.
   Visible by default; hidden by Auth after successful sign-in.
   ═══════════════════════════════════════════════════════════════════ */

#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 1rem;
}

#login-card {
  background: #fff;
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

#login-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

#login-title {
  font-family: 'Black Ops One', cursive;
  font-size: 1.5rem;
  margin: 0;
  color: #1e293b;
}

#login-subtitle {
  margin: 0;
  color: var(--wa-color-text-subdued, #64748b);
  font-size: 0.9rem;
}

#login-google-btn {
  width: 100%;
}

.login-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--wa-color-text-subdued, #64748b);
  font-size: 0.8rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--wa-color-surface-border, #e2e8f0);
}

#login-email-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#login-email-input {
  width: 100%;
}

#login-email-btn {
  width: 100%;
}

.login-status {
  font-size: 0.85rem;
  text-align: center;
  color: var(--wa-color-success-600, #16a34a);
  line-height: 1.5;
  margin: 0;
  max-width: 100%;
}

.login-status.error {
  color: var(--wa-color-danger-600, #dc2626);
}

/* ═══ Time Reporting ════════════════════════════════════════════════ */

.time-reporting-container {
  max-width: 900px;
}

/* ── Clock Card ──────────────────────────────────────────────────── */

.tr-clock-card {
  background: var(--wa-color-surface-raised, #fff);
  border: 2px solid var(--wa-color-border-default, #e2e8f0);
  border-radius: 12px;
  padding: 2rem 2rem 1.75rem;
  text-align: center;
  margin-bottom: 2rem;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.tr-clock-card.tr-clocked-in {
  background: var(--wa-color-success-50, #f0fdf4);
  border-color: var(--wa-color-success-500, #22c55e);
}

.tr-clock-status {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--wa-color-text-subdued, #64748b);
  margin-bottom: 0.75rem;
}

.tr-clock-card.tr-clocked-in .tr-clock-status {
  color: var(--wa-color-success-700, #15803d);
}

/* ── Elapsed time (hidden when clocked out) ──────────────────────── */

.tr-elapsed-area {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin 0.3s ease;
  margin-bottom: 0;
}

.tr-elapsed-area.tr-elapsed-visible {
  max-height: 120px;
  opacity: 1;
  margin-bottom: 1.5rem;
}

.tr-elapsed-label {
  font-size: 0.8rem;
  color: var(--wa-color-text-subdued, #64748b);
  margin-bottom: 0.2rem;
}

.tr-elapsed-time {
  font-size: 3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--wa-color-success-700, #15803d);
  letter-spacing: 0.02em;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.tr-location-status {
  font-size: 0.78rem;
  color: var(--wa-color-text-subdued, #64748b);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
}

/* ── Clock In/Out button ─────────────────────────────────────────── */

.tr-clock-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
  color: #fff;
}

.tr-clock-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.tr-clock-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.tr-clock-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tr-btn-in {
  background: var(--app-brand-primary, var(--wa-color-brand-600, #2563eb));
}

.tr-btn-out {
  background: var(--wa-color-danger-600, #dc2626);
}

.tr-btn-loading {
  background: var(--wa-color-neutral-400, #94a3b8);
}

/* ── Section titles ──────────────────────────────────────────────── */

.tr-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--wa-color-text-subdued, #64748b);
  margin: 0 0 0.75rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--wa-color-border-default, #e2e8f0);
}

.tr-today-section {
  margin-bottom: 2rem;
}

.tr-admin-section {
  margin-top: 0.5rem;
}

/* ── Admin report filters ────────────────────────────────────────── */

.tr-report-filters {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.tr-filter-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--wa-color-text-normal, #1e293b);
}

.tr-date-input {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--wa-color-border-default, #cbd5e1);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--wa-color-surface-raised, #fff);
  color: var(--wa-color-text-normal, #1e293b);
  height: 2.25rem;
}

/* ── Tables ──────────────────────────────────────────────────────── */

.tr-empty {
  color: var(--wa-color-text-subdued, #64748b);
  font-style: italic;
  margin: 0.25rem 0;
}

.tr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.tr-table th {
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-bottom: 2px solid var(--wa-color-border-default, #e2e8f0);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wa-color-text-subdued, #64748b);
}

.tr-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--wa-color-border-default, #f1f5f9);
  color: var(--wa-color-text-normal, #1e293b);
}

.tr-table tfoot td {
  padding: 0.55rem 0.75rem;
  border-top: 2px solid var(--wa-color-border-default, #e2e8f0);
  border-bottom: none;
}

.tr-report-table .tr-subtotal-row td {
  background: var(--wa-color-surface-sunken, #f8fafc);
  border-top: 1px solid var(--wa-color-border-default, #e2e8f0);
  border-bottom: 2px solid var(--wa-color-border-default, #e2e8f0);
  font-size: 0.82rem;
  color: var(--wa-color-text-subdued, #64748b);
}

.tr-report-table .tr-last-row td {
  border-bottom: none;
}

.tr-location-link {
  font-size: 0.78rem;
  white-space: nowrap;
}

.tr-no-location {
  color: var(--wa-color-text-subdued, #94a3b8);
}

/* ── Platform Settings ──────────────────────────────────────────────── */

.platform-settings-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.platform-settings-container h2 {
  margin: 0 0 0.25rem 0;
}

.ps-section {
  background: var(--wa-color-surface-raised, #fff);
  border: 1px solid var(--wa-color-border-default, #e2e8f0);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.ps-section-title {
  margin: 0 0 0.4rem 0;
  font-size: 1rem;
  font-weight: 600;
}

.ps-section-desc {
  margin: 0 0 1rem 0;
  font-size: 0.85rem;
  color: var(--wa-color-text-subdued, #64748b);
  line-height: 1.5;
}

.ps-loading {
  color: var(--wa-color-text-subdued, #64748b);
  font-size: 0.875rem;
  margin: 0;
}

.ps-error {
  color: var(--wa-color-danger-600, #dc2626);
  font-size: 0.875rem;
  margin: 0;
}

.ps-key-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.3rem 0;
}

.ps-key-label {
  font-weight: 500;
  flex: 1;
}

.ps-key-status-text {
  color: var(--wa-color-text-subdued, #64748b);
}

.ps-key-missing {
  color: var(--wa-color-danger-600, #dc2626);
  font-style: italic;
}

.ps-icon-ok {
  color: var(--wa-color-success-600, #16a34a);
}

.ps-icon-missing {
  color: var(--wa-color-danger-600, #dc2626);
}

.ps-model-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ps-model-card {
  border: 2px solid var(--wa-color-border-default, #e2e8f0);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.ps-model-card:hover {
  border-color: var(--wa-color-brand-600, #2563eb);
}

.ps-model-selected {
  border-color: var(--wa-color-brand-600, #2563eb);
  background: var(--wa-color-brand-50, #eff6ff);
}

.ps-model-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.ps-model-name {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
}

.ps-model-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.ps-model-col-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wa-color-text-subdued, #64748b);
  margin-bottom: 0.25rem;
}

.ps-model-col-text {
  font-size: 0.82rem;
  line-height: 1.45;
}

.ps-model-cost {
  display: flex;
  gap: 2rem;
  font-size: 0.8rem;
  color: var(--wa-color-text-subdued, #64748b);
  border-top: 1px solid var(--wa-color-border-default, #e2e8f0);
  padding-top: 0.6rem;
}

.ps-token-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ps-token-input {
  width: 120px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--wa-color-border-default, #e2e8f0);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

.ps-token-label {
  font-size: 0.875rem;
  color: var(--wa-color-text-subdued, #64748b);
}

.ps-save-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.ps-save-status {
  font-size: 0.875rem;
}

.ps-save-ok {
  color: var(--wa-color-success-600, #16a34a);
}

.ps-save-error {
  color: var(--wa-color-danger-600, #dc2626);
}

@media (max-width: 600px) {
  .ps-model-body {
    grid-template-columns: 1fr;
  }
  .ps-model-cost {
    flex-direction: column;
    gap: 0.25rem;
  }
}

@media (max-width: 400px) {
  #login-card {
    padding: 2rem 1.25rem;
  }
}

/* ── Billing Manager & Plan View ────────────────────────────────────── */

.bm-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Status badges */
.billing-status-badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.billing-status-trial     { background: #fef3c7; color: #92400e; }
.billing-status-active    { background: #d1fae5; color: #065f46; }
.billing-status-suspended { background: #fee2e2; color: #991b1b; }
.billing-status-cancelled { background: #f1f5f9; color: #475569; }
.billing-status-none      { background: #f1f5f9; color: #94a3b8; }

/* Billing list table */
.bm-list-table td,
.bm-list-table th { vertical-align: middle; }

/* Edit form field rows */
.bm-field-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.bm-field-row label {
  min-width: 120px;
  font-weight: 500;
  color: var(--wa-color-text-subdued, #64748b);
}

/* Tools table in edit form */
.bm-tools-table td,
.bm-tools-table th { vertical-align: middle; padding: 0.5rem 0.6rem; }
.bm-toggle-label  { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.bm-seat-hint     { font-size: 0.78rem; color: var(--wa-color-text-subdued, #94a3b8); }
.bm-seats-warning { color: #dc2626; font-weight: 600; }

/* Plan view */
.bm-plan-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.bm-plan-status-label {
  font-weight: 500;
  color: var(--wa-color-text-subdued, #64748b);
}
.bm-plan-alert {
  color: #dc2626;
  font-weight: 500;
  margin: 0.5rem 0;
}
.bm-plan-note {
  font-size: 0.85rem;
  color: var(--wa-color-text-subdued, #64748b);
  margin-top: 0.75rem;
}
.bm-plan-table tfoot td { border-top: 2px solid var(--wa-color-border, #e2e8f0); }
.bm-plan-total td { padding-top: 0.6rem; }
