:root {
  /* Colors - Neutral / Warm Gray Palette */
  --bg-app: #F5F5F4; /* Warm gray background */
  --bg-surface: #FFFFFF;
  --bg-subtle: #F9FAFB; /* Inset background */
  --bg-sidebar: #111111;
  
  --text-primary: #111827; /* Gray 900 */
  --text-secondary: #4B5563; /* Gray 600 */
  --text-tertiary: #9CA3AF; /* Gray 400 */
  --text-on-dark: #FFFFFF;
  
  --brand-primary: #111827;
  --brand-accent: #10B981;
  --brand-accent-light: #D1FAE5;
  --brand-accent-dark: #059669;
  
  --border-subtle: #E5E7EB; /* Gray 200 */
  --border-focus: #111827;
  
  --status-success: #10B981;
  --status-success-bg: #ECFDF5;
  --status-warning: #F59E0B;
  --status-warning-bg: #FFFBEB;
  --status-error: #EF4444;
  --status-error-bg: #FEF2F2;
  --status-info: #3B82F6;
  --status-info-bg: #EFF6FF;

  /* Urgency Colors */
  --urgency-emergency: #EF4444;
  --urgency-urgent: #F59E0B;
  --urgency-routine: #10B981;
  --urgency-unknown: #9CA3AF;

  /* Shadows - Layered Depth System */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
  
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

button {
  font-family: inherit;
}

/* Utility */
.hidden { display: none !important; }
.icon { display: inline-block; vertical-align: middle; }

/* Login Screen */
#login-screen {
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
}

.login-split {
  display: flex;
  width: 100%;
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  background: var(--bg-surface);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.login-brand {
  flex: 1;
  background: var(--brand-primary);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px;
  padding-top: calc(64px + env(safe-area-inset-top, 0px));
  position: relative;
}

.brand-content {
  position: relative;
  z-index: 10;
}

.brand-logo-simple {
  color: var(--text-on-dark);
  margin-bottom: 24px;
}

.login-brand h1 {
  font-size: 3.5rem;
  line-height: 1.1;
  margin-bottom: 16px;
  font-weight: 800;
  color: var(--text-on-dark);
  letter-spacing: -0.04em;
}

.login-brand p {
  font-size: 1.25rem;
  color: rgba(255, 255, 255, 0.7);
  max-width: 400px;
  font-weight: 500;
}

.brand-footer {
  position: absolute;
  bottom: 32px;
  left: 64px;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.4);
}

.login-form-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--bg-surface);
}

.login-container {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.login-header {
  margin-bottom: 40px;
}

.login-header h2 {
  font-size: 2rem;
  margin-bottom: 8px;
  font-weight: 700;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 1.125rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.input-group {
  margin-bottom: 32px;
}

.input-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pin-inputs {
  display: flex;
  gap: 16px;
}

.pin-box {
  width: 64px;
  height: 72px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: var(--transition-fast);
  text-align: center;
  caret-color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
  -webkit-text-security: disc;
  text-security: disc;
}

.pin-box::-webkit-outer-spin-button,
.pin-box::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pin-box[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.pin-box:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.1);
  transform: translateY(-2px);
}

.pin-box.filled {
  border-color: var(--text-primary);
  background: var(--bg-subtle);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 32px;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  width: 304px;
  box-shadow: var(--shadow-md);
}

.btn-primary {
  background: var(--brand-primary);
  color: white;
}

.btn-primary:hover {
  background: #000000;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Dashboard */
#dashboard-screen {
  height: 100vh;
  height: 100dvh;
  display: none;
  flex-direction: column;
  background: var(--bg-app);
}

.dashboard-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.dashboard-header {
  background: var(--brand-primary);
  padding: 0;
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 10;
  position: relative;
}

.header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 56px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  padding: 0 24px;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-brand {
  display: flex;
  flex-direction: column;
}

.header-logo {
  font-size: 1.125rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.header-powered {
  font-size: 0.625rem;
  font-weight: 500;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.02em;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.forwarding-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 5px 5px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
}

.forwarding-chip:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.25);
}

.chip-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
}

.chip-value {
  font-weight: 600;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  color: white;
}

.chip-copy-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--status-info);
  color: white;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.chip-copy-btn:hover {
  background: #2563EB;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.status-indicator {
  display: none;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: rgba(255,255,255,0.1);
  color: white;
  border-color: rgba(255,255,255,0.15);
}

.active-call-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(16, 185, 129, 0.15);
  color: #6EE7B7;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pulsing-dot {
  width: 7px;
  height: 7px;
  background: #6EE7B7;
  border-radius: 50%;
  animation: blink 1.5s infinite;
  box-shadow: 0 0 0 2px rgba(110, 231, 183, 0.3);
}

.tab-bar {
  position: absolute;
  top: calc(56px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  pointer-events: none;
}

.tab-bar > * {
  pointer-events: auto;
}

.tab-bar-right {
  position: absolute;
  right: 24px;
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.warmup-btn {
  background: var(--brand-primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.warmup-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Call Feed */
.call-feed {
  flex: 1;
  overflow-y: auto;
  padding: 52px 24px calc(48px + env(safe-area-inset-bottom, 0px));
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.call-feed::-webkit-scrollbar {
  width: 0;
}

.sort-group {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  box-shadow: var(--shadow-sm);
}

.sort-btn {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  padding: 7px 20px;
  border-radius: calc(var(--radius-md) - 3px);
  cursor: pointer;
  transition: var(--transition-fast);
  line-height: 1;
}

.sort-btn:hover:not(.active) {
  color: var(--text-secondary);
}

.sort-btn.active {
  background: var(--brand-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

/* Call Card - Surface Style */
.call-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: all var(--transition-normal);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.03);
  position: relative;
}

/* Hover State */
.call-card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(0,0,0,0.06);
}

/* Expanded State */
.call-card.expanded {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border-color: rgba(0,0,0,0.08);
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Collapsed Header */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.caller-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.urgency-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.8);
}

.urgency-emergency .urgency-dot { background: var(--urgency-emergency); }
.urgency-urgent .urgency-dot { background: var(--urgency-urgent); }
.urgency-routine .urgency-dot { background: var(--urgency-routine); }
.urgency-unknown .urgency-dot { background: var(--urgency-unknown); }

.caller-name {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
}

.call-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.time-ago {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.expand-chevron {
  color: var(--text-tertiary);
  transition: transform var(--transition-fast);
  opacity: 0.5;
  background: var(--bg-subtle);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-card:hover .expand-chevron {
  opacity: 1;
  background: var(--bg-app);
  color: var(--text-primary);
}

.call-card.expanded .expand-chevron {
  opacity: 1;
  transform: rotate(180deg);
  background: var(--brand-primary);
  color: white;
}

.card-sub-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 22px; /* Align with text */
}

.issue-text {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.duration-text {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.summary-preview {
  font-size: 0.9375rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 22px;
  margin-top: 4px;
}

/* Expanded Content */
.expanded-content {
  display: none; /* Toggled via JS */
  flex-direction: column;
  gap: 32px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  animation: fade-in 0.15s ease-out;
}

.call-card.expanded .expanded-content {
  display: flex;
}

.call-card.expanded .summary-preview {
  white-space: normal;
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 1rem;
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  background: var(--bg-subtle);
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(0,0,0,0.03);
}

.detail-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-group span {
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 600;
}

.status-value {
  text-transform: capitalize;
}

/* Transcript */
.transcript-section {
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid rgba(0,0,0,0.03);
  box-shadow: var(--shadow-inner);
}

.transcript-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.transcript-body {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Audio Player */
.audio-player {
  display: flex;
  align-items: center;
  gap: 16px;
  background: white;
  border: 1px solid var(--border-subtle);
  padding: 12px 16px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  margin-top: 8px;
}

.play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: not-allowed;
  transition: var(--transition-fast);
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.play-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

.waveform-line {
  flex: 1;
  height: 4px;
  background: var(--bg-subtle);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.waveform-line::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 30%;
  background: var(--border-subtle);
  border-radius: 2px;
}

.audio-duration {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

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

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  text-align: center;
  background: white;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-subtle);
  margin-top: 24px;
}

.empty-illustration {
  color: var(--border-subtle);
  margin-bottom: 24px;
  background: var(--bg-subtle);
  padding: 24px;
  border-radius: 50%;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.toast {
  background: white;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 320px;
  border-left: 4px solid transparent;
  animation: slide-in-right 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  border: 1px solid rgba(0,0,0,0.05);
}

.toast-error { border-left-color: var(--status-error); }
.toast-success { border-left-color: var(--status-success); }
.toast-info { border-left-color: var(--status-info); }

.toast span {
  flex: 1;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.toast-dismiss {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.toast-dismiss:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* Responsive */
@media (max-width: 768px) {
  html,
  body {
    height: 100%;
    overscroll-behavior: none;
  }

  #login-screen {
    position: fixed;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: stretch;
    justify-content: flex-start;
    height: 100svh;
    min-height: 100svh;
  }
  .login-split { flex-direction: column; height: auto; min-height: 100vh; min-height: 100dvh; }
  .login-brand { padding: 48px 32px; flex: 0 0 auto; }
  .login-brand h1 { font-size: 2.8rem; line-height: 1.08; }
  .brand-footer { left: 32px; right: 32px; text-align: left; }
  .login-form-container { padding: 48px 32px; }
  .login-container { align-items: center; }
  .login-header { text-align: center; }
  #login-form { align-items: center; }
  .input-group label { text-align: center; }
  .header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    height: auto;
    padding: 12px 16px;
    gap: 10px;
  }
  .header-left { order: 1; flex: 1 1 auto; min-width: 0; }
  .header-right { order: 2; margin-left: auto; justify-content: flex-end; gap: 8px; }
  .header-center { order: 3; flex-basis: 100%; justify-content: center; padding-bottom: 4px; }
  .chip-label { display: none; }
  .call-feed { padding: 52px 16px 48px; }
  .tab-bar { padding: 10px 16px; }
  .details-grid { grid-template-columns: 1fr; }
  .call-card { padding: 16px; }
}
