/* Whitman Independent Advisors — same tokens as the other Whitman apps. */
:root {
  --brand: #172b63;
  --brand-dark: #0f1c45;
  --accent: #1c9bd7;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a2332;
  --text-muted: #5b6b7d;
  --border: #dfe4ea;
  --chip: #eef2f8;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --ok: #1f7a44;
  --warn-bg: #fff6e8;
  --warn-border: #f5c58a;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.5; }

.site-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 24px; display: flex; align-items: center; gap: 14px;
}
.site-header img { height: 40px; width: auto; }
.site-header h1 { font-size: 18px; margin: 0; color: var(--brand); }
.site-header .sub { font-size: 13px; color: var(--text-muted); }
.site-header .spacer { flex: 1; }
.badge { font-size: 12.5px; background: var(--chip); color: var(--brand); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; }

.layout { display: grid; grid-template-columns: 380px 1fr; gap: 20px; padding: 20px 24px; max-width: 1600px; margin: 0 auto; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; padding: 16px; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 10px; }
.section + .section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }

.pick-head { display: flex; justify-content: space-between; align-items: baseline; }
.counter { font-size: 12.5px; color: var(--text-muted); }
.counter.full { color: var(--danger); font-weight: 600; }
.search { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; margin-bottom: 8px; }
.groups { max-height: 320px; overflow-y: auto; padding: 0 10px 6px; }
.group-name { font-size: 12px; font-weight: 700; color: var(--brand); margin: 10px 0 2px; }
.opt { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 14px; cursor: pointer; }
.opt input { accent-color: var(--brand); width: 16px; height: 16px; }
.opt .tag { font-size: 11px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }
.opt.disabled { opacity: .45; cursor: not-allowed; }
.selected { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; min-height: 4px; }
.selected .chip { background: var(--chip); border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.selected .chip button { border: 0; background: none; cursor: pointer; color: var(--text-muted); font-size: 15px; line-height: 1; padding: 0 4px; }

.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.toggle input { accent-color: var(--brand); width: 16px; height: 16px; }

.periods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.periods button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px;
  padding: 7px 0; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.periods button.wide { grid-column: span 2; }
.periods button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.periods button:hover:not(.active) { border-color: var(--brand); }

.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.dates label { font-size: 12.5px; color: var(--text-muted); display: block; margin-bottom: 3px; }
.dates input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; }
.dates input:disabled { background: var(--bg); color: var(--text-muted); }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.primary {
  width: 100%; margin-top: 20px; padding: 12px; border: 0; border-radius: 10px; background: var(--brand);
  color: #fff; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
}
.primary:hover { background: var(--brand-dark); }
.primary:disabled { opacity: .6; cursor: progress; }

.result .empty { color: var(--text-muted); text-align: center; padding: 80px 20px; }
.result .empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.chart-img { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; display: block; }
.actions { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.actions button, .actions a {
  border: 1px solid var(--border); background: var(--surface); color: var(--brand); border-radius: 8px;
  padding: 7px 14px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.actions button:hover, .actions a:hover { border-color: var(--brand); }

.table-wrap { overflow-x: auto; margin-top: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--text-muted); font-weight: 600; background: var(--bg); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }

.notes { margin: 14px 0 0; padding: 12px 14px 12px 32px; background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 8px; font-size: 13.5px; }
.notes li + li { margin-top: 4px; }
.checks { margin-top: 10px; font-size: 13px; color: var(--ok); }
.error { background: var(--danger-bg); border: 1px solid #f3b8b3; color: var(--danger); border-radius: 8px; padding: 14px 16px; font-size: 14.5px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card img { height: 64px; margin-bottom: 8px; }
.login-card h1 { font-size: 18px; color: var(--brand); margin: 0 0 16px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.login-error { color: var(--danger); font-size: 13.5px; }

/* Top-ups & withdrawals */
.flows { display: flex; flex-direction: column; gap: 8px; }
.flow-row { display: grid; grid-template-columns: 92px 1fr 1fr 28px; gap: 6px; align-items: center; }
.flow-row .kind { font-size: 12.5px; font-weight: 700; padding: 4px 6px; border-radius: 6px; text-align: center; }
.flow-row .kind.topup { background: #eefaf1; color: #15803d; border: 1px solid #a7d9b6; }
.flow-row .kind.withdrawal { background: #fdeeee; color: #b91c1c; border: 1px solid #efb4b4; }
.flow-row input { width: 100%; min-width: 0; padding: 7px 8px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 13.5px; }
.flow-row .rm { position: relative; }
.flow-row .rm span { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--text-muted); }
.flow-row .rm input { padding-left: 32px; }
.flow-row button { border: 0; background: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 0; }
.flow-row button:hover { color: var(--danger); }
.flow-add { display: flex; gap: 8px; margin-top: 8px; }
.flow-add button { flex: 1; border: 1px solid; border-radius: 8px; padding: 8px; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.flow-add button[data-add="topup"] { background: #eefaf1; color: #15803d; border-color: #a7d9b6; }
.flow-add button[data-add="topup"]:hover:not(:disabled) { background: #dcf3e3; border-color: #15803d; }
.flow-add button[data-add="withdrawal"] { background: #fdeeee; color: #b91c1c; border-color: #efb4b4; }
.flow-add button[data-add="withdrawal"]:hover:not(:disabled) { background: #fadcdc; border-color: #b91c1c; }
.flow-add button:disabled { opacity: .45; cursor: not-allowed; }
h3.sub-table { font-size: 13px; color: var(--text-muted); margin: 16px 0 0; text-transform: uppercase; letter-spacing: .06em; }

/* Date boxes: type DD/MM/YYYY or pick from the calendar button */
.date-field { position: relative; display: flex; min-width: 0; }
.date-field input:not(.native) { flex: 1; min-width: 0; padding-right: 34px; }
.date-field .cal {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 6px; background: none; color: var(--brand); cursor: pointer; padding: 0;
}
.date-field .cal:hover:not(:disabled) { background: var(--chip); }
.date-field .cal:disabled { color: var(--text-muted); opacity: .45; cursor: not-allowed; }
/* The real <input type="date"> sits invisibly under the button so the calendar opens there. */
.date-field .native { position: absolute; right: 0; bottom: 0; width: 34px; height: 100%; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.flow-row { grid-template-columns: 82px minmax(122px, 1.3fr) minmax(80px, 1fr) 20px; gap: 5px; }
.flow-row .kind { font-size: 12px; padding: 4px 2px; }
.flow-row .date-field input:not(.native) { padding-left: 7px; padding-right: 30px; }
.flow-row .cal { color: inherit; }

/* Portfolio dropdown */
.combo { position: relative; }
.combo-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  font: inherit; font-size: 14px; color: var(--text); cursor: pointer; text-align: left;
}
.combo-btn:hover, .combo.open .combo-btn { border-color: var(--brand); }
.combo-btn .placeholder { color: var(--text-muted); }
#comboLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo .caret { color: var(--brand); font-size: 12px; transition: transform .15s; }
.combo.open .caret { transform: rotate(180deg); }
.combo-panel {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 28, 69, .14); padding: 8px 0 0;
}
.combo-panel .search { width: calc(100% - 16px); margin: 0 8px 6px; }

/* Download PDF */
.actions .pdf-btn { background: var(--brand); border-color: var(--brand); color: #fff; padding: 8px 18px; }
.actions .pdf-btn:hover:not(:disabled) { background: var(--brand-dark); }
.actions .pdf-btn:disabled { opacity: .7; cursor: progress; }

/* Header: user + log out */
.site-header .user { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.logout-btn {
  font-size: 13px; font-weight: 600; color: var(--brand); text-decoration: none; white-space: nowrap;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; background: var(--surface);
}
.logout-btn:hover { border-color: var(--brand); }

/* Form buttons: Clear + Generate */
.form-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 20px; }
.form-actions .primary { margin-top: 0; }
.secondary {
  padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--brand); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
}
.secondary:hover { border-color: var(--brand); }
.login-card input + input { margin-top: 10px; }
