/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:        #1E2860;
  --navy-dark:   #16204d;
  --navy-light:  #253071;
  --lime:        #9DC53D;
  --lime-dark:   #7da82f;
  --lime-light:  #b8d96a;
  --white:       #ffffff;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-400:    #9ca3af;
  --gray-600:    #4b5563;
  --gray-800:    #1f2937;
  --red-100:     #fee2e2;
  --red-700:     #b91c1c;
  --green-100:   #dcfce7;
  --green-700:   #15803d;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-lg:   0 4px 16px rgba(0,0,0,.12);
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Site header ─────────────────────────────────────────────────────────── */
.site-header {
  background: var(--navy);
  color: var(--white);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: .5rem; color: var(--white); }
.brand:hover { text-decoration: none; }
.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--white);
}

.site-nav a {
  color: rgba(255,255,255,.8);
  font-size: .875rem;
  margin-left: 1.5rem;
}
.site-nav a:hover { color: var(--white); text-decoration: none; }

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-header h1 {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}
.subtitle {
  color: var(--gray-600);
  font-size: .875rem;
  margin-top: .25rem;
}
.breadcrumb {
  font-size: .8125rem;
  color: var(--gray-600);
  display: block;
  margin-bottom: .25rem;
}
.breadcrumb:hover { color: var(--navy); text-decoration: none; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem 1.125rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--lime);
  color: var(--navy-dark);
}
.btn-primary:hover:not(:disabled) { background: var(--lime-dark); text-decoration: none; }
.btn-secondary {
  background: var(--white);
  color: var(--navy);
  border: 1.5px solid var(--gray-200);
}
.btn-secondary:hover:not(:disabled) { background: var(--gray-100); text-decoration: none; }
.btn-sm { padding: .3125rem .75rem; font-size: .8125rem; }
.btn-full { width: 100%; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.card-wide { width: 100%; }
.card-narrow { max-width: 560px; }
.card h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 1.125rem;
  padding-bottom: .625rem;
  border-bottom: 2px solid var(--lime);
}

/* ── Client grid ─────────────────────────────────────────────────────────── */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.client-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: box-shadow .15s, transform .1s;
  border-left: 4px solid var(--lime);
}
.client-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
  text-decoration: none;
}
.client-card-name {
  font-weight: 700;
  color: var(--navy);
  font-size: .9375rem;
}
.client-card-meta { display: flex; gap: .375rem; flex-wrap: wrap; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  font-size: .6875rem;
  font-weight: 600;
  padding: .125rem .5rem;
  border-radius: 9999px;
  background: var(--navy-light);
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-secondary {
  background: var(--gray-200);
  color: var(--gray-600);
}

/* ── Two-col layout ──────────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.run-form, .settings-form, .modal-form {
  display: flex;
  flex-direction: column;
  gap: .875rem;
}
label {
  display: flex;
  flex-direction: column;
  gap: .3125rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--gray-600);
}
label small {
  font-weight: 400;
  color: var(--gray-400);
  font-size: .75rem;
}
.required { color: var(--red-700); }

input[type="text"],
input[type="number"],
input[type="month"],
select {
  width: 100%;
  padding: .5rem .75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--white);
  transition: border-color .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--navy-light);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

/* ── Drop zone ───────────────────────────────────────────────────────────── */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  min-height: 80px;
  text-align: center;
  gap: .375rem;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--lime);
  background: rgba(157, 197, 61, .06);
}
.drop-zone.has-file {
  border-color: var(--lime);
  background: rgba(157, 197, 61, .08);
}
.drop-label {
  font-size: .8125rem;
  color: var(--gray-400);
}
.file-name {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--navy);
}

/* ── Run log ─────────────────────────────────────────────────────────────── */
.run-log {
  margin-top: 1rem;
  background: var(--gray-800);
  color: #d4ffd4;
  border-radius: var(--radius);
  padding: .875rem 1rem;
  font-family: "Cascadia Code", "Fira Mono", Consolas, monospace;
  font-size: .75rem;
  line-height: 1.6;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.run-log .log-error { color: #fca5a5; }
.run-log .log-success { color: #86efac; }

/* ── Run results ─────────────────────────────────────────────────────────── */
.run-results {
  margin-top: .875rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.result-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .75rem;
  background: var(--green-100);
  border-radius: var(--radius);
  font-size: .8125rem;
  gap: .5rem;
}
.result-file-name { font-weight: 600; color: var(--green-700); flex: 1; min-width: 0; }
.result-file-link {
  color: var(--green-700);
  font-weight: 600;
  font-size: .75rem;
  white-space: nowrap;
}

.error-box {
  margin-top: .875rem;
  padding: .75rem 1rem;
  background: var(--red-100);
  border-radius: var(--radius);
  font-size: .8125rem;
  color: var(--red-700);
  font-weight: 600;
}

/* ── Report table ────────────────────────────────────────────────────────── */
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.report-table th {
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .5rem .75rem;
  border-bottom: 2px solid var(--gray-200);
}
.report-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.report-table tr:last-child td { border-bottom: none; }
.report-name { font-weight: 600; color: var(--navy); }
.report-date { color: var(--gray-400); font-size: .8125rem; }
.report-actions { text-align: right; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  margin: 1rem;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem .875rem;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--navy);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.375rem;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
  padding: .125rem .375rem;
  border-radius: 4px;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-800); }
.modal-form { padding: 1.25rem 1.5rem; }
.modal-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: .5rem;
}

/* ── Form actions ────────────────────────────────────────────────────────── */
.form-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: .5rem;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
  font-size: .9375rem;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-lg { margin-top: 1.25rem; }

/* ── Folder Picker ───────────────────────────────────────────────────────── */
.fp-row {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.fp-display {
  flex: 1;
  padding: .5rem .75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--gray-600);
  background: var(--gray-50);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  font-style: italic;
}
.fp-display.fp-selected {
  color: var(--gray-800);
  font-style: normal;
  font-weight: 600;
}
.fp-body { padding: 1rem 1.5rem 1.25rem; }
.fp-breadcrumb {
  font-size: .8125rem;
  margin-bottom: .75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .125rem;
  min-height: 1.5rem;
}
.fp-crumb {
  cursor: pointer;
  color: var(--navy);
  padding: .125rem .3rem;
  border-radius: 4px;
}
.fp-crumb:hover { background: var(--gray-100); }
.fp-crumb-current { cursor: default; color: var(--gray-800); font-weight: 600; }
.fp-crumb-current:hover { background: none; }
.fp-sep { color: var(--gray-400); }
.fp-list {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  min-height: 100px;
  max-height: 260px;
  overflow-y: auto;
}
.fp-empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--gray-400);
  font-size: .875rem;
}
.fp-error { color: var(--red-700); }
.fp-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  width: 100%;
  padding: .625rem .875rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--gray-100);
  font-size: .875rem;
  text-align: left;
  cursor: pointer;
  transition: background .1s;
  font-family: var(--font);
  color: var(--gray-800);
}
.fp-item:last-child { border-bottom: none; }
.fp-item:hover { background: var(--gray-50); }
.fp-name { flex: 1; }
.fp-arrow { color: var(--gray-400); font-size: 1rem; }
.fp-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
.fp-required-msg {
  font-size: .75rem;
  color: var(--red-700);
  font-weight: 600;
  display: none;
  margin-top: .25rem;
}
