/* === NOTION-STYLE DESIGN SYSTEM === */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f5;
  --bg-hover: #efefed;
  --bg-active: #e8e8e5;
  --text-primary: #37352f;
  --text-secondary: #6b6b6b;
  --text-tertiary: #9b9b9b;
  --border-color: #e8e8e5;
  --border-light: #f1f1ef;
  --accent: #2383e2;
  --accent-light: #e8f0fe;
  --success: #0f7b0f;
  --success-bg: #e6f4e6;
  --warning: #cf8600;
  --warning-bg: #fef3cd;
  --danger: #e03e3e;
  --danger-bg: #fce4e4;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: 150ms ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
}

/* === LOGIN === */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  transition: opacity 0.4s, transform 0.4s;
}

.login-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 32px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.login-card .logo {
  height: 28px;
  margin-bottom: 24px;
}

.login-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.login-card .subtitle {
  color: var(--text-tertiary);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-card input[type="email"],
.login-card input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--bg-primary);
  transition: border var(--transition), box-shadow var(--transition);
  margin-bottom: 16px;
}

.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.15);
}

.login-error {
  display: none;
  padding: 8px 12px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-weight: 500;
}

.login-error.show {
  display: block;
}

.btn-primary {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform 80ms;
}

.btn-primary:hover {
  background: #1b6ec2;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* === LAYOUT === */
.app-container {
  display: none;
  min-height: 100vh;
}

.app-container.visible {
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-left img {
  height: 22px;
}

.topbar-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(15, 123, 15, 0.4);
}

.status-dot.offline {
  background: var(--text-tertiary);
}

.topbar-btn {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-btn:hover {
  background: var(--bg-hover);
  color: var(--danger);
}

/* === TAB NAV === */
.tab-bar {
  display: flex;
  gap: 0;
  padding: 0 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  transition: color var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--text-primary);
}

/* === MAIN CONTENT === */
.main-content {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 20px;
}

.section-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* === CARDS === */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-sm);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-value.accent {
  color: var(--accent);
}

.stat-value.success {
  color: var(--success);
}

/* === FORM CONTROLS === */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.form-group {
  flex: 1;
  min-width: 200px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--bg-primary);
  transition: border var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.15);
}

.btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-dark {
  background: var(--text-primary);
  color: #fff;
}

.btn-dark:hover {
  background: #1a1a1a;
}

.btn-outline {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  background: var(--bg-hover);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: #1b6ec2;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* === DROP ZONE === */
.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.drop-zone:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(35, 131, 226, 0.08);
  transform: scale(1.01);
}

.drop-zone .icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  background: var(--accent-light);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.drop-zone h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.drop-zone p {
  font-size: 13px;
  color: var(--text-tertiary);
}

.processing-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-md);
  z-index: 10;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.processing-overlay.show {
  display: flex;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === SKELETON === */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, #e0e0de 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text.w60 {
  width: 60%;
}

.skeleton-text.w80 {
  width: 80%;
}

.skeleton-text.w40 {
  width: 40%;
}

.skeleton-heading {
  height: 24px;
  width: 50%;
  margin-bottom: 16px;
}

.skeleton-row {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.skeleton-cell {
  height: 14px;
}

.skeleton-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* === TABLE === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
  cursor: default;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
}

.data-table .mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

.data-table .amount {
  font-weight: 600;
  text-align: right;
}

.data-table .amount.positive {
  color: var(--success);
}

/* === CLIENT LIST === */
.client-row {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}

.client-row:hover {
  background: var(--bg-hover);
}

.client-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.client-info {
  flex: 1;
  min-width: 0;
}

.client-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-meta {
  font-size: 12px;
  color: var(--text-tertiary);
}

.client-stats {
  text-align: right;
  flex-shrink: 0;
}

.client-revenue {
  font-size: 14px;
  font-weight: 700;
}

.client-count {
  font-size: 11px;
  color: var(--text-tertiary);
}

.badge {
  display: inline-flex;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

/* === CLIENT DETAIL (Slide-over / Panel) === */
.detail-panel {
  display: none;
}

.detail-panel.active {
  display: block;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-header .back-btn {
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all var(--transition);
}

.detail-header .back-btn:hover {
  background: var(--bg-hover);
}

.detail-avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

.detail-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.detail-sub {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* === LOG PANEL === */
.log-panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 16px;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
}

.log-header .dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.log-header .dot-pulse.active {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

.log-body {
  max-height: 200px;
  overflow-y: auto;
  padding: 12px 16px;
  font-size: 13px;
}

.log-body::-webkit-scrollbar {
  width: 4px;
}

.log-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.log-entry {
  padding: 6px 0;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.log-entry .log-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
}

.log-entry .log-icon.info {
  background: var(--bg-hover);
  color: var(--text-tertiary);
}

.log-entry .log-icon.success {
  background: var(--success-bg);
  color: var(--success);
}

.log-entry .log-icon.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.log-entry .log-icon.process {
  background: var(--accent-light);
  color: var(--accent);
}

.log-entry .log-text {
  flex: 1;
}

.log-entry .log-time {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* === ALERTS === */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid #f0d78c;
}

.alert-info {
  background: var(--accent-light);
  border: 1px solid #b8d4f0;
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.show {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-content {
  position: relative;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-content .modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

.modal-actions .btn {
  flex: 1;
  justify-content: center;
}

/* === SEARCH === */
.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--bg-primary);
  transition: border var(--transition), box-shadow var(--transition);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.15);
}

.search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
}

/* === PAGINATION === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination-btns {
  display: flex;
  gap: 4px;
}

.pagination-btns button {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all var(--transition);
}

.pagination-btns button:hover {
  background: var(--bg-hover);
}

.pagination-btns button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === GENERATED FILES LIST === */
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}

.file-item:last-child {
  border-bottom: none;
}

.file-name {
  font-size: 13px;
  font-weight: 600;
}

.file-actions {
  display: flex;
  gap: 4px;
}

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .main-content {
    padding: 16px 12px;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    flex-direction: column;
  }

  .section-title {
    font-size: 22px;
  }

  .client-row {
    padding: 8px;
  }
}

/* === UTILITY === */
.hidden {
  display: none !important;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-right {
  text-align: right;
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mb-0 {
  margin-bottom: 0;
}

.gap-8 {
  gap: 8px;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.flex-1 {
  flex: 1;
}