/* Courta identity v1. Shared by Leads, lead details, Account and the auth shell. */
:root {
  color-scheme: light;
  --brand-50: 240 247 241;
  --brand-100: 223 239 228;
  --brand-200: 190 218 201;
  --brand-300: 150 193 169;
  --brand-400: 87 142 121;
  --brand-500: 53 117 99;
  --brand-600: 18 58 45;
  --brand-700: 7 55 67;
  --brand-800: 9 45 47;
  --brand-900: 8 37 34;
  --brand-950: 5 27 25;
  --neutral-50: 244 245 239;
  --neutral-100: 237 241 233;
  --neutral-200: 218 226 218;
  --neutral-300: 189 203 193;
  --neutral-400: 111 133 124;
  --neutral-500: 91 112 102;
  --neutral-600: 70 93 83;
  --neutral-700: 47 74 62;
  --neutral-800: 27 62 50;
  --neutral-900: 7 55 67;
  --neutral-950: 5 30 35;
  --color-primary: #c6f82e;
  --color-on-primary: #073743;
  --color-secondary: #123a2d;
  --color-accent: #c6f82e;
  --color-bg: #f4f5ef;
  --color-background: var(--color-bg);
  --color-fg: #073743;
  --color-foreground: var(--color-fg);
  --color-card: #fff;
  --color-muted: #edf1e9;
  --color-muted-fg: #465d53;
  --color-border: #dae2da;
  --color-ring: #357563;
  --font-heading: 'Anuphan', 'IBM Plex Sans Thai', sans-serif;
  --font-body: 'IBM Plex Sans Thai', system-ui, sans-serif;
  --radius-control: 10px;
  --radius-card: 16px;
}
body { margin: 0; background: var(--color-bg); color: var(--color-fg); font-family: var(--font-body); }
h1,h2,h3,h4 { font-family: var(--font-heading); }
button,input,select,textarea { font-family: inherit; }
button,a,input,select,textarea { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--color-ring); outline-offset: 3px; }
::selection { background: var(--color-primary); color: var(--color-on-primary); }
body > header.border-b { border-top: 3px solid var(--color-primary); }
.courta-brand { display: inline-flex; align-items: center; flex-shrink: 0; gap: 10px; color: var(--color-fg); text-decoration: none; }
.courta-brand img { display: block; width: 43px; height: 28px; object-fit: contain; }
.courta-brand span { font: 700 24px/1 var(--font-heading); letter-spacing: -.9px; }
header nav a { min-height: 36px; display: inline-flex; align-items: center; border-radius: var(--radius-control); }
header nav a[aria-current=page],header nav a.bg-slate-900 { background: var(--color-muted); color: var(--color-secondary); }
.button-primary { background: var(--color-primary); color: var(--color-on-primary); border-color: transparent; font-weight: 600; }
.button-primary:hover { background: #b4e524; color: var(--color-on-primary); }
.button-primary:disabled { opacity: .6; cursor: default; }
button:not(:disabled),select,a { cursor: pointer; }
.button-primary, #pw-save { min-height: 40px; }
#radarGrid > button { min-height: 72px; border-radius: 12px; }
#radarGrid > button.bg-brand-600 { background: var(--color-secondary); border-color: var(--color-secondary); }
main > section.rounded-xl { border-radius: var(--radius-card); }
thead { color: var(--color-muted-fg); }
tbody tr:hover { background-color: #f7faf4; }
.cs-overlay { box-sizing: border-box; position: fixed; inset: 0; z-index: 1000; background: var(--color-secondary); display: grid; place-items: center; padding: 32px 20px; overflow: auto; font-family: var(--font-body); color: var(--color-fg); }
.cs-card { box-sizing: border-box; width: 100%; max-width: 420px; background: var(--color-card); border: 1px solid var(--color-border); border-top: 5px solid var(--color-primary); border-radius: 20px; padding: 36px 32px; box-shadow: 0 16px 48px #00180d33; }
.cs-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; font: 700 30px/1 var(--font-heading); letter-spacing: -1px; }
.cs-logo { display: block; width: 49px; height: 32px; object-fit: contain; }
.cs-eyebrow { margin: 0 0 10px; color: var(--color-muted-fg); font: 600 10px/1.5 var(--font-body); letter-spacing: .15em; }
.cs-card h1,.cs-card h2 { margin: 0 0 10px; font: 600 28px/1.3 var(--font-heading); }
.cs-sub { margin: 0 0 24px; color: var(--color-muted-fg); font-size: 14px; line-height: 1.7; }
.cs-field { margin-bottom: 18px; }
.cs-field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.cs-field input { box-sizing: border-box; width: 100%; min-height: 48px; padding: 11px 14px; font-size: 16px; border: 1px solid rgb(var(--neutral-300)); border-radius: var(--radius-control); background: #fff; color: var(--color-fg); }
.cs-field input:focus { outline: 2px solid var(--color-ring); outline-offset: 2px; }
.cs-hint { margin: 4px 0 0; font-size: 12px; color: var(--color-muted-fg); }
.cs-error { min-height: 20px; margin: 0 0 12px; font-size: 13px; color: #b91c1c; }
.cs-ok { margin: 0 0 10px; font-size: 13px; color: #047857; }
.cs-btn { box-sizing: border-box; width: 100%; min-height: 48px; padding: 12px 16px; font-size: 15px; font-weight: 600; color: var(--color-on-primary); background: var(--color-primary); border: 0; border-radius: var(--radius-control); cursor: pointer; }
.cs-btn:hover { background: #b4e524; }
.cs-btn:disabled { opacity: .6; cursor: default; }
.cs-btn.cs-ghost { color: var(--color-fg); background: #fff; border: 1px solid var(--color-border); }
.cs-btn.cs-ghost:hover { background: var(--color-muted); }
.cs-row { display: flex; gap: 8px; }
.cs-account { position: relative; margin-left: auto; }
.cs-floating { position: fixed; top: 12px; right: 12px; z-index: 60; }
.cs-chip { display: flex; align-items: center; gap: 8px; max-width: 260px; min-height: 40px; padding: 4px 12px 4px 4px; font: 13px var(--font-body); color: var(--color-fg); text-decoration: none; background: #fff; border: 1px solid var(--color-border); border-radius: 999px; }
.cs-chip:hover,.cs-chip[aria-current=page] { border-color: var(--color-secondary); }
.cs-avatar { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: rgb(var(--brand-100)); color: var(--color-secondary); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.cs-chip-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-banner { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1200; display: flex; align-items: center; gap: 12px; max-width: min(92vw,560px); padding: 10px 12px 10px 16px; font: 14px var(--font-body); color: #7f1d1d; background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; box-shadow: 0 4px 14px #0f172a1f; }
.cs-banner[hidden] { display: none; }
.cs-banner button { min-width: 32px; min-height: 32px; font-size: 18px; line-height: 1; color: #7f1d1d; background: none; border: 0; border-radius: 6px; }
.cs-version { padding: 10px 20px 14px; font: 11px 'Fira Code',monospace; color: var(--color-muted-fg); }
@media(max-width:1500px) { .cs-chip-email { display: none; } .cs-chip { padding: 4px; } }
@media(max-width:767px) {
  body > header > .courta-topbar { height: auto; min-height: 64px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; gap: 12px; }
  body > header > div > div:first-child { gap: 16px; }
  body > header > div > div:last-child { flex-wrap: wrap; }
  body > header > .courta-leads-topbar { position: relative; }
  .courta-leads-topbar > div:first-child { padding-right: 44px; }
  .courta-leads-topbar > div:last-child { width: 100%; gap: 8px; }
  .courta-leads-topbar .cs-account { position: absolute; top: 12px; right: 20px; }
  #activeRuleHint { display: block; max-width: 100%; }
  .cs-card { padding: 28px 24px; }
}
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; } }

/* Dense working layout: keep text readable and recover space from padding. */
.page-leads .courta-topbar { height: 48px; }
.page-leads .courta-brand img { width: 37px; height: 24px; }
.page-leads .courta-brand span { font-size: 22px; }
.page-leads .courta-topbar > div:first-child { gap: 16px; }
.page-leads header nav a { min-height: 32px; padding: 4px 10px; }
.page-leads .button-primary { min-height: 32px; }
.page-leads .cs-chip { min-height: 32px; }
.page-leads .cs-avatar { width: 24px; height: 24px; }
.leads-layout { padding: 12px 16px; }
.leads-layout > :not([hidden]) ~ :not([hidden]) { margin-top: 10px; margin-bottom: 0; }
.leads-calendar { padding: 8px; }
.leads-calendar > div:first-child { margin-bottom: 6px; gap: 6px; }
#radarGrid { gap: 4px; grid-template-columns: repeat(6,minmax(0,1fr)); }
#radarGrid > button { min-height: 46px; padding: 4px 8px; border-radius: 8px; }
#radarGrid > button > div:last-child { margin-top: 2px; }
.leads-filters,.leads-filters > div { gap: 6px; }
.leads-results thead th { padding-top: 7px; padding-bottom: 7px; }
#leadsTableBody > tr > td { padding-top: 6px; padding-bottom: 6px; }
#leadsTableBody td > .flex.flex-wrap { gap: 3px; }
#leadsTableBody [data-act=copy],#leadsTableBody td a:not([data-lead-link]) { padding: 2px 6px; }
#leadsTableBody td select,#leadsTableBody td input { padding-top: 3px; padding-bottom: 3px; }
.leads-results > div:last-child { padding-top: 6px; padding-bottom: 6px; }
.lead-detail h1 { font-size: 22px; }
.lead-detail #f-notes { min-height: 100px; }
@media(min-width:1024px) { #radarGrid { grid-template-columns: repeat(12,minmax(0,1fr)); } }
@media(max-width:767px) {
  .page-leads > header > .courta-topbar { min-height: 0; height: auto; padding-top: 8px; padding-bottom: 8px; gap: 6px; }
  .page-leads .courta-leads-topbar .cs-account { top: 8px; right: 12px; }
  .page-leads .courta-leads-topbar { padding-left: 12px; padding-right: 12px; }
  .page-leads .courta-topbar > div:last-child { gap: 6px; }
  .page-leads .button-primary { min-height: 36px; }
  .leads-layout { padding: 8px 12px; }
  .leads-calendar > div:first-child > div:first-child { display: contents; }
  .leads-calendar > div:first-child { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 4px; }
  .leads-calendar > div:first-child > div:first-child > div { grid-column: 1; grid-row: 1; justify-self: start; }
  .leads-calendar #btnAllMonths { grid-column: 2; grid-row: 1; }
  .leads-calendar #activeRuleHint { grid-column: 1 / -1; grid-row: 2; }
  #activeRuleHint { font-size: 10px; line-height: 1.4; }
  #radarGrid > button { min-height: 44px; padding: 4px; }
  #radarGrid > button > div:first-child > span:first-child { font-size: 10px; }
  #radarGrid > button > div:first-child > span:last-child { font-size: 12px; }
  #radarGrid > button > div:last-child { font-size: 9px; }
  .leads-filters .relative { width: 100%; }
  .leads-filters > div:last-child { margin-left: auto; }
}
@media(pointer:coarse) {
  #leadsTableBody [data-act=copy],#leadsTableBody td select,#leadsTableBody td input { min-height: 32px; }
}

/* Lead workspace: a compact editing row and an inline tournament composer. */
.page-lead .courta-topbar { min-height: 48px; padding-top: 4px; padding-bottom: 4px; gap: 16px; }
.page-lead .courta-brand img { width: 37px; height: 24px; }
.page-lead .courta-brand span { font-size: 22px; }
.page-lead header nav { order: 0; width: auto; }
.page-lead header nav a { min-height: 32px; padding: 4px 10px; }
.page-lead .cs-chip { min-height: 32px; }
.page-lead .cs-avatar { width: 24px; height: 24px; }
.lead-workspace { max-width: 1360px; margin: 0 auto; padding: 10px 18px 16px; }
.lead-breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; font-size: 12px; color: var(--color-muted-fg); }
.lead-breadcrumbs a:hover { color: var(--color-fg); }
.lead-heading { display: grid; grid-template-columns: minmax(0,1fr) 200px; gap: 16px; margin-top: 10px; }
.lead-id { display: flex; align-items: center; gap: 8px; font: 11px 'Fira Code',monospace; color: var(--color-muted-fg); }
.lead-workspace h1 { margin: 4px 0; font-size: 20px; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
.lead-identity > p { font-size: 12px; line-height: 1.5; color: var(--color-muted-fg); }
.lead-status label,.lead-workspace label { font-size: 12px; line-height: 1.4; }
.lead-status #save-state { margin-top: 3px; min-height: 18px; font-size: 11px; line-height: 1.4; color: var(--color-muted-fg); }
.lead-workspace h2 { font-size: 14px; font-weight: 600; line-height: 1.5; }
.lead-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lead-section-heading #history-count { font-size: 12px; font-weight: 400; color: var(--color-muted-fg); }
.lead-workspace input,.lead-workspace select { min-width: 0; min-height: 34px; padding: 5px 9px; font-size: 13px; line-height: 1.5; border-radius: 8px; }
.lead-workspace label { margin-bottom: 4px; }
.lead-season { margin-top: 10px; }
.season-legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--color-muted-fg); font-size: 11px; }
.season-legend > span { display: inline-flex; align-items: center; gap: 4px; }
.season-marker { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; }
.season-held { background: var(--color-fg); }
.season-both { background: #059669; }
.season-reach { border: 2px solid var(--color-secondary); border-radius: 50%; }
.season-none { width: 4px; height: 4px; margin: 3px; background: rgb(var(--neutral-300)); border-radius: 50%; }
.lead-season-grid { display: grid; grid-template-columns: repeat(12,minmax(0,1fr)); gap: 1px; padding: 0; margin: 6px 0 0; list-style: none; background: var(--color-border); border: 1px solid var(--color-border); border-radius: 10px; overflow: hidden; }
.season-month { min-width: 0; padding: 7px 6px; background: var(--color-card); }
.season-month[aria-current=date] { box-shadow: inset 0 2px 0 var(--color-secondary); }
.season-month-label { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 12px; font-weight: 600; }
.season-summary { margin-top: 2px; color: var(--color-muted-fg); font-size: 11px; line-height: 1.4; text-align: center; white-space: nowrap; }
.lead-fields { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.35fr) minmax(0,1fr); gap: 18px; padding: 12px 0; margin-top: 12px; border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
.lead-fields > section { min-width: 0; }
.lead-follow-fields,.contact-fields { display: grid; gap: 8px; margin-top: 6px; }
.contact-fields > div { display: grid; grid-template-columns: 64px minmax(0,1fr); align-items: center; gap: 4px 6px; }
.contact-fields > div > label { margin: 0; }
.contact-fields > div > div { min-width: 0; }
.contact-fields button,.contact-fields a { min-height: 34px; padding: 5px 8px; font-size: 12px; }
.also-phones { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px; font-size: 11px; }
.also-phones:empty { display: none; }
.lead-workspace #f-notes { margin-top: 6px; min-height: 110px; height: 110px; padding: 8px 10px; font-size: 13px; resize: vertical; }
.lead-history { margin-top: 10px; }
.lead-history button { min-height: 32px; padding: 5px 10px; border: 1px solid var(--color-border); border-radius: 8px; font-size: 12px; }
.lead-history button:disabled { opacity: .45; cursor: default; }
#event-status { margin-top: 4px; color: #047857; font-size: 12px; }
#event-status:empty { display: none; }
.history-scroll { margin-top: 6px; overflow-x: auto; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-card); }
.history-scroll table { font-size: 12px; }
.history-scroll th,.history-scroll td { padding: 6px 10px; }
.history-scroll th { background: var(--color-muted); }
.history-scroll td:nth-child(3) { min-width: 220px; }
.history-scroll td:nth-child(4) { min-width: 180px; }
.history-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; color: var(--color-muted-fg); font-size: 11px; }
.history-pagination > div { display: flex; align-items: center; gap: 8px; }
.history-pagination button { background: #fff; }
.event-form { display: grid; grid-template-columns: 2fr 1fr 1.5fr 1.5fr; gap: 10px; padding: 12px; margin-top: 8px; border: 1px solid rgb(var(--brand-200)); border-radius: 12px; background: rgb(var(--brand-50)); }
.event-form[hidden] { display: none; }
.event-form > div { min-width: 0; }
.event-form-heading { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.event-form-heading h3 { font-size: 14px; font-weight: 600; }
.event-form-heading p { color: var(--color-muted-fg); font-size: 12px; }
.event-error { grid-column: 1 / -1; color: #b91c1c; font-size: 12px; }
.event-error:empty { display: none; }
.event-form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
#event-cancel { background: #fff; }
@media(max-width:1023px) {
  .lead-fields { grid-template-columns: 1fr 1.4fr; }
  .lead-notes { grid-column: 1 / -1; }
  .lead-workspace #f-notes { height: 72px; min-height: 72px; }
  .season-legend { font-size: 10px; gap: 6px; }
  .event-form { grid-template-columns: 1fr 1fr; }
}
@media(max-width:639px) {
  .page-lead > header > .courta-topbar { min-height: 48px; padding: 6px 12px; gap: 12px; }
  .lead-workspace { padding: 8px 12px 16px; }
  .lead-view-summary { display: none; }
  .lead-workspace h1 { font-size: 18px; }
  .lead-heading { grid-template-columns: minmax(0,1fr); gap: 8px; }
  .lead-status { display: grid; grid-template-columns: 46px minmax(0,1fr); align-items: center; gap: 2px 6px; }
  .lead-status label { margin: 0; }
  .lead-status #save-state { grid-column: 2; }
  .lead-season > .lead-section-heading { flex-wrap: wrap; gap: 4px; }
  .lead-season-grid { grid-template-columns: repeat(6,minmax(0,1fr)); }
  .season-month { padding: 6px 2px; }
  .season-summary { font-size: 10px; }
  .lead-fields { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .lead-follow-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .lead-workspace input { font-size: 16px; }
  .event-form { grid-template-columns: minmax(0,1fr); }
}
@media(pointer:coarse) {
  .lead-history button { min-height: 40px; }
  .lead-workspace input,.lead-workspace select,.contact-fields button,.contact-fields a { min-height: 40px; }
}
