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

:root {
  --primary: #01261E;
  --primary-hover: #0B3A2C;
  --primary-tint: #EAF2EE;
  --primary-border: #C3D9CD;
  --danger: #CF2E2E;
  --success: #2E7D32;
  --warning: #D97706;
  --review: #92400E;
  --review-bg: #FFFBEB;
  --review-border: #FCD34D;
  --bg: #F6F8F7;
  --surface: #ffffff;
  --border: #E2E8E5;
  --text: #2C2C2C;
  --text-dark: #1A1A1A;
  --text-muted: #6B7280;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
}

body {
  font-family: 'Assistant', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* Nav */
.nav {
  background: var(--surface);
  border-bottom: 2px solid var(--primary);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-logo {
  height: 28px;
  width: auto;
  display: block;
}
.nav-brand-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}
.nav-links { display: flex; align-items: center; gap: 20px; }
.nav-link { color: var(--primary); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-link:hover { color: var(--primary-hover); }
.nav-user { color: var(--text-muted); }

/* Container */
.container { max-width: 900px; margin: 0 auto; padding: 32px 16px; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--primary-tint) 0%, var(--bg) 60%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(1,38,30,0.10);
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-logo {
  height: 56px;
  width: auto;
  display: block;
}
.login-brand-divider { width: 40px; height: 2px; background: var(--primary); border-radius: 2px; opacity: 0.3; }
.login-brand-sub { font-size: 14px; font-weight: 500; color: var(--text-muted); }

/* Fields */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1,38,30,0.08);
}
.field-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
  resize: vertical;
  min-height: 72px;
}
.field-hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Password toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-left: 38px; }
.pw-toggle {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; color: var(--text-muted);
  padding: 2px; display: flex; align-items: center;
}
.pw-toggle:hover { color: var(--primary); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s;
  gap: 4px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-full { width: 100%; margin-top: 8px; }
.btn-sm { font-size: 13px; padding: 6px 14px; }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:hover { opacity: .88; }

/* Alerts */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-error { background: #FFEBEE; border: 1px solid #FFCDD2; color: var(--danger); }
.alert-success { background: #E8F5E9; border: 1px solid #C8E6C9; color: var(--success); }
.alert-info { background: var(--primary-tint); border: 1px solid var(--primary-border); color: var(--primary); }
.alert-review { background: var(--review-bg); border: 1px solid var(--review-border); color: var(--review); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* Page heading */
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 24px; }

/* File drop */
.file-drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 28px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
  color: var(--text-muted);
  font-size: 14px;
}
.file-drop:hover { border-color: var(--primary); background: var(--primary-tint); color: var(--primary); }
.file-drop-selected { border-color: var(--success); background: #F0FBF0; color: var(--success); }
.file-drop-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Filter bar */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filter-search {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.filter-search svg {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.filter-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: var(--bg);
  direction: rtl;
}
.filter-search input:focus { outline: none; border-color: var(--primary); }
.filter-row select, .filter-row input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
.filter-row select:focus, .filter-row input[type="date"]:focus { outline: none; border-color: var(--primary); }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: right;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-row-link { cursor: pointer; }
.table-row-link:hover td { background: var(--bg); }
.td-muted { color: var(--text-muted); font-size: 13px; }

.call-name-cell { font-weight: 500; }
.call-goal-pill {
  display: inline-block;
  font-size: 11px;
  background: #F3F4F6;
  color: var(--text-muted);
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-pending    { background: #FFF3CD; color: #856404; }
.badge-processing { background: var(--primary-tint); color: var(--primary); }
.badge-review     { background: var(--review-bg); color: var(--review); border: 1px solid var(--review-border); }
.badge-done       { background: #E8F5E9; color: var(--success); }
.badge-failed     { background: #FFEBEE; color: var(--danger); }

/* Department badge */
.dept-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  background: #EFF6FF;
  color: #1D4ED8;
  white-space: nowrap;
}
.goal-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  background: #F0FDF4;
  color: #15803D;
  white-space: nowrap;
}

/* Label chips on call detail */
.label-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.chip-label {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.7;
  margin-left: 2px;
}
.chip-contact { background: #F3E8FF; color: #6B21A8; }
.chip-dept    { background: #EFF6FF; color: #1D4ED8; }
.chip-goal    { background: #F0FDF4; color: #15803D; }
.chip-project { background: #FFF7ED; color: #C2410C; }
.chip-edit {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-decoration: none;
  cursor: pointer;
}
.chip-edit:hover { border-color: var(--primary); color: var(--primary); }

/* Review grid */
.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

/* Call title row */
.call-title-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px; flex-wrap: wrap;
}
.btn-rename {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 4px; display: flex; align-items: center; flex-shrink: 0;
}
.btn-rename:hover { color: var(--primary); }
.rename-input {
  width: 100%; padding: 7px 12px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  font-family: inherit; font-size: 18px; font-weight: 700;
  color: var(--text); background: var(--surface);
}
.rename-input:focus { outline: none; }

/* Call meta */
.call-meta { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }

/* Summary & transcript */
.section-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px; margin-bottom: 12px;
}
.section-title { font-size: 16px; font-weight: 600; margin: 0; }
.btn-copy {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit; font-size: 12px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; padding: 3px 10px;
  transition: color .15s, border-color .15s; flex-shrink: 0;
}
.btn-copy:hover { color: var(--primary); border-color: var(--primary); }
.summary-box {
  background: var(--primary-tint);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius);
  padding: 16px; font-size: 14px; line-height: 1.8;
  direction: rtl; margin-bottom: 28px;
}
.summary-box-md { white-space: normal; }
.summary-box-md p { margin-bottom: 10px; }
.summary-box-md p:last-child { margin-bottom: 0; }
.summary-box-md strong { font-weight: 700; }
.summary-box-md ul { padding-right: 20px; padding-left: 0; margin-bottom: 10px; }
.summary-box-md li { margin-bottom: 4px; }
.transcript-box {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  font-size: 14px; line-height: 1.8;
  white-space: pre-wrap; direction: rtl;
  margin-bottom: 28px; max-height: 400px; overflow-y: auto;
}
.transcript-section { margin-bottom: 0; }
.transcript-details {
  margin-top: 16px;
}
.transcript-details summary {
  cursor: pointer; font-size: 14px; font-weight: 500;
  color: var(--text-muted); user-select: none;
  padding: 8px 0;
}
.transcript-details summary:hover { color: var(--primary); }

/* Processing */
.processing-msg { text-align: center; padding: 40px; color: var(--text-muted); }
.processing-msg .spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-note { margin-top: 16px; font-size: 14px; color: var(--text-muted); line-height: 1.6; }
.processing-note strong { color: var(--text); }

/* Export bar */
.export-bar { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.btn-export { font-size: 13px; }

/* Delete button */
.btn-delete-link {
  background: none; border: none; color: var(--danger);
  font-family: inherit; font-size: 13px; cursor: pointer;
  padding: 10px 4px; margin: -10px -4px; text-decoration: underline; text-underline-offset: 2px;
  display: inline-flex; align-items: center; min-height: 44px;
}
.btn-delete-link:hover { opacity: .75; }

/* Progress bar */
.progress-bar-track {
  width: 100%; height: 6px; background: var(--border);
  border-radius: 999px; overflow: hidden; margin-bottom: 6px;
}
.progress-bar-fill {
  height: 100%; width: 0%;
  background: var(--primary); border-radius: 999px;
  transition: width .2s ease;
}
.progress-label { font-size: 13px; color: var(--text-muted); text-align: center; }

/* Row actions */
.row-actions { white-space: nowrap; }

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 56px 24px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.empty-state-title { font-size: 17px; font-weight: 700; color: var(--text-dark); margin-bottom: 6px; }
.empty-state-sub { font-size: 14px; color: var(--text-muted); max-width: 320px; line-height: 1.6; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 16px;
  text-align: center; box-shadow: var(--shadow);
  border-top: 3px solid transparent;
}
.stat-card-success { border-top-color: var(--success); }
.stat-card-danger  { border-top-color: var(--danger); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-dark); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Bar chart */
.bar-chart {
  display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px;
  overflow-x: auto;
}
.bar-col {
  flex: 1 0 28px; min-width: 28px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; height: 100%; justify-content: flex-end;
}
.bar-track { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.bar-fill {
  width: 100%; background: var(--primary); border-radius: 3px 3px 0 0;
  min-height: 2px; opacity: 0.75;
}
.bar-count { font-size: 10px; font-weight: 700; color: var(--text-muted); min-height: 14px; }
.bar-label { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

/* Stats table */
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats-table th {
  text-align: right; padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  font-weight: 600; color: var(--text-muted); font-size: 12px;
}
.stats-table td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.stats-table tr:last-child td { border-bottom: none; }
.td-success { color: var(--success); font-weight: 600; }
.td-danger  { color: var(--danger); font-weight: 600; }

/* Admin manage items */
.manage-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.manage-item:last-child { border-bottom: none; }

/* Print */
@media print {
  .nav, .export-bar, .btn-copy, .label-chips,
  p:has(> .btn-secondary), .transcript-section { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .container { max-width: 100%; padding: 16px 0; }
  .summary-box { border: none; background: none; padding: 0; }
  .section-header { border-bottom: 1px solid #ccc; }
}

/* Mobile */
@media (max-width: 640px) {
  .nav { padding: 0 12px; }
  .nav-brand-sub { display: none; }
  .nav-links { gap: 12px; }
  .nav-link { font-size: 13px; }
  .container { padding: 16px 12px; }
  .card { padding: 16px; }
  .page-title { font-size: 17px; margin-bottom: 16px; }
  .login-card { padding: 28px 20px; }
  .filter-row { gap: 8px; }
  .filter-search { min-width: 100%; }
  .filter-row select { flex: 1 1 100%; }
  .filter-row input[type="date"] { flex: 1 1 calc(50% - 4px); }
  .filter-row .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
  .review-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .export-bar { flex-direction: column; }
  .export-bar .btn { width: 100%; justify-content: center; }
  .call-title-row { gap: 6px; }
  .rename-input { font-size: 15px; }
  .label-chips { gap: 6px; }
  .chip { font-size: 12px; padding: 4px 10px; }
}
