:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Fresh, Modern Light Theme Palette */
  --bg-app: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-surface: #F1F5F9;
  --bg-modal: #FFFFFF;

  --border-subtle: #E2E8F0;
  --border-card: #E2E8F0;
  --border-hover: #CBD5E1;

  --text-main: #0F172A;
  --text-body: #334155;
  --text-muted: #64748B;
  --text-dim: #94A3B8;

  /* Accent Colors */
  --accent-primary: #4F46E5; /* Indigo */
  --accent-primary-hover: #4338CA;
  --accent-light: #EEF2FF;
  --accent-glow: rgba(79, 70, 229, 0.2);

  --emerald: #059669;
  --emerald-bg: #ECFDF5;
  --emerald-border: #A7F3D0;
  --emerald-text: #065F46;

  --rose: #E11D48;
  --rose-bg: #FFF1F2;
  --rose-border: #FECDD3;
  --rose-text: #9F1239;

  --amber: #D97706;
  --amber-bg: #FFFBEB;
  --amber-border: #FDE68A;
  --amber-text: #92400E;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.03);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* =========================================================================
   HEADER (CLEAN & MOBILE-PERFECT)
   ========================================================================= */
.app-header {
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 0.75rem 1.25rem;
}

.header-content {
  max-width: 1050px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #4F46E5, #6366F1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
  flex-shrink: 0;
}

.brand-titles {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.12rem 0.38rem;
  background: var(--accent-light);
  color: var(--accent-primary);
  border-radius: var(--radius-full);
  letter-spacing: 0.04em;
}

.security-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #F1F5F9;
  border: 1px solid var(--border-subtle);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-body);
  white-space: nowrap;
  flex-shrink: 0;
}

.secure-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 6px var(--emerald);
}

/* =========================================================================
   MAIN BODY & HERO
   ========================================================================= */
.main-body {
  max-width: 960px;
  width: 100%;
  margin: 2.25rem auto;
  padding: 0 1.25rem;
  flex: 1;
}

.hero-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.5rem;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.8rem;
  background: #FEF3C7;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: #B45309;
  margin-bottom: 0.65rem;
}

.hero-title {
  font-size: clamp(1.75rem, 5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.hero-subtitle {
  font-size: clamp(0.88rem, 2vw, 0.95rem);
  color: var(--text-muted);
  max-width: 580px;
  line-height: 1.6;
}

/* =========================================================================
   UPLOAD DROPZONE (CLEAN WHITE CARD)
   ========================================================================= */
.upload-dropzone {
  position: relative;
  width: 100%;
  max-width: 680px;
  background: var(--bg-card);
  border: 2px dashed #CBD5E1;
  border-radius: var(--radius-lg);
  padding: 3rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--accent-primary);
  background: #F5F7FF;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.upload-icon-circle {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
  transition: transform 0.2s;
}

.upload-dropzone:hover .upload-icon-circle {
  transform: scale(1.08);
}

.dropzone-title {
  font-size: clamp(1.05rem, 3vw, 1.2rem);
  font-weight: 700;
  color: var(--text-main);
}

.dropzone-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn-browse {
  margin-top: 0.4rem;
  pointer-events: none;
}

/* Feature Pills */
.feature-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-body);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* =========================================================================
   FUNNY LOADING / PROCESSING STATE
   ========================================================================= */
.processing-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
  text-align: center;
}

.funny-loading-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2rem;
  max-width: 520px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.02);
  animation: popIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid #E2E8F0;
  border-radius: 50%;
  border-top-color: var(--accent-primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.funny-punchline-card {
  background: linear-gradient(135deg, #FFF1F2 0%, #FFF5F5 100%);
  border: 1px solid #FECDD3;
  border-radius: var(--radius-md);
  padding: 1.15rem 1.45rem;
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.2s;
}

.funny-punchline-card:hover {
  transform: translateY(-1px);
}

.punchline-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--rose-text);
  background: rgba(225, 29, 72, 0.08);
  padding: 0.18rem 0.6rem;
  border-radius: var(--radius-full);
}

.funny-punchline {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--rose-text);
  line-height: 1.55;
  letter-spacing: -0.01em;
}

/* =========================================================================
   RESULTS SECTION & CARDS
   ========================================================================= */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: fadeIn 0.25s ease;
}

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

/* Session Timer Bar */
.session-timer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1rem;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--amber-text);
  gap: 0.5rem;
}

.timer-info {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.timer-countdown {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: #78350F;
}

/* Results Header */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.results-title { font-size: 1.15rem; font-weight: 700; color: var(--text-main); }
.results-subtitle { font-size: 0.8rem; color: var(--text-muted); }

.results-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Result Card */
.results-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.result-card:hover {
  border-color: #CBD5E1;
  box-shadow: var(--shadow-md);
}

.card-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 200px;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-file-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-all;
}

.card-period {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-stats {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.stat-group {
  display: flex;
  flex-direction: column;
}

.stat-group .label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-group .val {
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.val-dr { color: var(--rose); }
.val-cr { color: var(--emerald); }

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
}
.badge-success { background: var(--emerald-bg); color: var(--emerald-text); border: 1px solid var(--emerald-border); }
.badge-warning { background: var(--amber-bg); color: var(--amber-text); border: 1px solid var(--amber-border); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.52rem 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3);
}
.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-body);
  border-color: var(--border-card);
}
.btn-secondary:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.btn-danger {
  background: var(--rose-bg);
  color: var(--rose-text);
  border-color: var(--rose-border);
}
.btn-danger:hover {
  background: #FFE4E6;
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
}

/* =========================================================================
   MODAL (LIGHT & CLEAN)
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.modal-dialog {
  background: var(--bg-modal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 1050px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border-subtle);
  background: #FFFFFF;
  gap: 0.75rem;
}

.modal-title { font-size: 1.05rem; font-weight: 700; color: var(--text-main); word-break: break-all; }
.modal-subtitle { font-size: 0.78rem; color: var(--text-muted); }

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
}
.btn-close:hover { color: var(--text-main); }

.modal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.35rem;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-subtle);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  width: 280px;
}
.search-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.82rem;
  width: 100%;
}
.search-box input:focus { outline: none; }

.filter-pills { display: flex; gap: 0.35rem; }

.pill-btn {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  color: var(--text-body);
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-weight: 500;
}
.pill-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.modal-table-container {
  flex: 1;
  overflow: auto;
  background: #FFFFFF;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #F1F5F9;
  color: var(--text-body);
  font-weight: 600;
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #F1F5F9;
  color: var(--text-body);
}

.data-table tbody tr:hover {
  background: #F8FAFC;
}

.cell-amount {
  font-family: var(--font-mono);
  text-align: right;
}

.badge-dr { color: var(--rose); font-weight: 600; }
.badge-cr { color: var(--emerald); font-weight: 600; }
.badge-ref {
  background: #EEF2FF;
  color: #4F46E5;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.35rem;
  border-top: 1px solid var(--border-subtle);
  background: #F8FAFC;
}

/* =========================================================================
   FOOTER (KAMCHOR ZENITSU)
   ========================================================================= */
.app-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 1.25rem 1.5rem;
  text-align: center;
  background: #FFFFFF;
}

.zenitsu-tag {
  display: inline-block;
  font-size: 0.8rem;
  color: #64748B;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.2s;
  cursor: pointer;
}

.zenitsu-tag:hover {
  color: #D97706;
  transform: translateY(-1px);
}

/* Helpers */
.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #0F172A;
  color: #fff;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  font-weight: 500;
  z-index: 200;
}

/* =========================================================================
   MOBILE RESPONSIVENESS (< 768px & < 480px)
   ========================================================================= */
@media (max-width: 768px) {
  .app-header {
    padding: 0.65rem 0.85rem;
  }

  .header-content {
    justify-content: space-between;
  }

  .brand-name {
    font-size: 0.95rem;
  }

  .security-badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.68rem;
  }

  .main-body {
    margin: 1.25rem auto;
    padding: 0 0.85rem;
  }

  .upload-dropzone {
    padding: 2.25rem 0.85rem;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .results-actions {
    width: 100%;
  }

  .results-actions .btn {
    flex: 1;
  }

  .result-card {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    gap: 0.85rem;
  }

  .card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 0.65rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
  }

  .card-actions {
    width: 100%;
  }

  .card-actions .btn {
    flex: 1;
  }

  .session-timer-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .timer-actions {
    width: 100%;
  }

  .timer-actions .btn {
    width: 100%;
  }

  /* Full Screen Modal on Mobile */
  .modal-backdrop {
    padding: 0;
  }

  .modal-dialog {
    height: 100vh;
    max-width: 100vw;
    border-radius: 0;
    border: none;
  }

  .modal-header {
    padding: 0.75rem 0.85rem;
  }

  .modal-toolbar {
    padding: 0.65rem 0.85rem;
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    width: 100%;
  }

  .filter-pills {
    width: 100%;
  }

  .filter-pills .pill-btn {
    flex: 1;
    text-align: center;
  }
}
