/* ───────────────────────────────────────────────────────────────
   Meridian Workspace design system
   Palette / fonts matched to mymeridianworkspace.com
   ─────────────────────────────────────────────────────────────── */
:root {
  --bg:       #f0ede8;
  --surface:  #ffffff;
  --surface2: #f7f5f2;
  --border:   #e0dbd3;
  --accent:   #2c5282;
  --accent-d: #1e3a5f;   /* darker hover for accent */
  --red:      #c0392b;
  --green:    #1D9E75;
  --muted:    #7a8090;
  --text:     #1a2332;
  --header:   #1e3a5f;
  --serif:    'DM Serif Display', Georgia, serif;
  --sans:     'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono:     'DM Mono', ui-monospace, "SF Mono", Menlo, monospace;
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Meridian workspace chrome (matches mymeridianworkspace.com) ─── */
.mi-header {
  background: #fbfaf7;
  border-bottom: 1px solid #cfc8bb;
  padding: 0 40px;
  height: 72px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.mi-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: #1e3a5f;
}
.mi-brand { display: flex; flex-direction: column; justify-content: center; text-decoration: none; }
.mi-brand-name {
  font-family: 'EB Garamond', Garamond, 'Adobe Garamond Pro', Georgia, serif;
  font-size: 24px; font-weight: 500; color: #1e3a5f; line-height: 1.05; letter-spacing: 0.005em;
}
.mi-brand-sub {
  font-family: var(--mono); font-size: 10px; color: #7a7466;
  text-transform: uppercase; letter-spacing: 0.22em; margin-top: 5px;
}
.mi-header-center {
  position: absolute; left: 50%; transform: translateX(-50%);
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.mi-header-date {
  font-family: var(--mono); font-size: 11px; color: #7a7466;
  text-transform: uppercase; letter-spacing: 0.22em;
}
.mi-header-time {
  font-family: var(--mono); font-size: 10px; color: #a8a194;
  text-transform: uppercase; letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums; transition: opacity 0.6s ease-out;
}
.mi-header-time.fade { opacity: 0; }
.mi-header-right { display: flex; align-items: center; gap: 24px; }
.mi-header-link {
  color: #7a7466; font-family: var(--mono); font-size: 10px; text-decoration: none;
  text-transform: uppercase; letter-spacing: 0.16em; transition: color 0.15s;
}
.mi-header-link:hover { color: #1e3a5f; }
@media (max-width: 700px) {
  .mi-header { padding: 0 20px; }
  .mi-header-center { display: none; }
}

/* ─── Header ─────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 22px 32px;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}
header h1 {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--header);
  letter-spacing: 0;
}
.subtitle {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}
.header-period {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 4px;
}
.header-period__label {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.header-period__value {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}
.header-period__value.error { color: var(--red); font-family: var(--sans); font-size: 0.9rem; }

/* ─── Main layout (2-column tile grid) ───────────────────────── */
main {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
/* The accruals preview card should span both columns so the table breathes */
#accruals-preview-card { grid-column: 1 / -1; }

@media (max-width: 880px) {
  main { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .header-period { align-items: flex-start; text-align: left; }
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06);
}
.card h2 {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--header);
  margin-bottom: 4px;
  letter-spacing: 0;
  text-transform: none;
}
.help-text {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.55;
}

.loading-text { color: var(--muted); font-weight: 400; font-size: 0.92rem; }

/* ─── Form rows ──────────────────────────────────────────────── */
.override-section { margin-top: 4px; }
.override-section summary {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.override-section summary:hover { color: var(--accent-d); }
.date-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin: 16px 0;
  flex-wrap: wrap;
}
.date-row label {
  display: flex;
  flex-direction: column;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  gap: 6px;
}
.date-row input[type="date"],
.date-row select {
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-family: var(--sans);
  color: var(--text);
  outline: none;
  text-transform: none;
  letter-spacing: 0;
}
.date-row input[type="date"]:focus,
.date-row select:focus { border-color: var(--accent); }

/* ─── Action row ─────────────────────────────────────────────── */
.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 4px;
}

/* The "Download Part N" buttons sit inside an inline-flex span so they
   inherit the same gap rules as the main action-row buttons. */
#download-accruals-parts {
  display: inline-flex;
  gap: 12px;
  flex-wrap: wrap;
}
#download-accruals-parts.hidden { display: none; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  padding: 10px 22px;
  border: none;
  border-radius: 7px;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, color 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-d); }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-success { background: var(--accent); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--accent-d); }

/* ─── Status banners ─────────────────────────────────────────── */
.status {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 0.82rem;
  line-height: 1.5;
  border: 1px solid transparent;
}
.status.info    { background: var(--surface2); color: var(--header); border-color: var(--border); }
.status.success { background: #eaf6f0; color: var(--green); border-color: #c9e4d6; }
.status.error   { background: #faf0ef; color: var(--red);  border-color: #e8c9c5; }
.status.loading { background: var(--surface2); color: var(--muted); border-color: var(--border); }

/* ─── Badge ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  background: var(--surface2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  vertical-align: middle;
  border: 1px solid var(--border);
}

/* ─── Multi-row layout (label + picker) ──────────────────────── */
.multi-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
  flex-wrap: wrap;
}
.multi-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ─── Checkbox-dropdown picker ───────────────────────────────── */
.company-picker {
  position: relative;
  flex: 1 1 360px;
  min-width: 280px;
  max-width: 720px;
}
.company-picker__trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-family: var(--sans);
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}
.company-picker__trigger:hover { border-color: var(--accent); }
.company-picker__trigger:focus { outline: 2px solid var(--accent); }
.company-picker__caret { color: var(--muted); font-size: 0.7rem; margin-left: 8px; }

.company-picker__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: max(100%, 680px);
  max-height: 460px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.10);
  z-index: 50;
}
.company-picker__panel.hidden { display: none; }
.company-picker__search {
  padding: 9px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 0.88rem;
  background: var(--surface2);
  color: var(--text);
  outline: none;
}
.company-picker__list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  column-count: 3;
  column-gap: 8px;
  column-rule: 1px solid var(--border);
}
.company-picker__item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 0.83rem;
  cursor: pointer;
  break-inside: avoid;
}
.company-picker__item:hover { background: var(--surface2); }
.company-picker__item input { margin: 0; cursor: pointer; accent-color: var(--accent); }
.company-picker__item--all {
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  background: var(--surface2);
  column-span: all;
  -webkit-column-span: all;
}

@media (max-width: 720px) {
  .company-picker__list { column-count: 2; }
  .company-picker__panel { width: 100%; }
}

/* ─── Preview table ──────────────────────────────────────────── */
.table-wrap {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 600px;
}
thead {
  background: var(--header);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1;
}
th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
tbody tr:nth-child(odd)  { background: var(--surface2); }
tbody tr:nth-child(even) { background: var(--surface); }
td {
  padding: 7px 10px;
  white-space: nowrap;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.hidden { display: none !important; }

/* ─── Form-control hygiene (strip number spinners, etc.) ─────── */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
html body select:not([multiple]) {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3e%3cpath fill='none' stroke='%237a7466' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  padding-right: 30px;
}
select::-ms-expand { display: none; }
