/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:             #f3f5f8;
  --surface:        #ffffff;
  --border:         #dde1e7;
  --border-focus:   #393975;
  --text-primary:   #181818;
  --text-secondary: #514f4d;
  --text-muted:     #939393;

  --accent:         #393975;
  --accent-dark:    #2a2a5a;
  --accent-light:   #eeeef6;

  --brand-orange:      #ef674c;
  --brand-orange-dark: #d4512e;

  --teal:           #0f766e;
  --teal-dark:      #0d5f57;
  --teal-light:     #ccfbf1;

  --danger:         #c23934;
  --danger-light:   #fde8e8;
  --warning:        #c07300;
  --warning-light:  #fef3c7;
  --success:        #2e7d32;
  --success-light:  #e8f5e9;

  --radius:         8px;
  --radius-sm:      5px;
  --shadow-card:    0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-modal:   0 20px 60px rgba(0,0,0,.22);

  font-size: 15px;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 100px;
}

/* ============================================================
   UTILITY
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   STATE SCREENS
   ============================================================ */
.loading-screen,
.state-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
  padding: 24px;
}

.loading-bar-track {
  width: 320px;
  height: 10px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #393975, #ef674c);
  border-radius: 99px;
  animation: sweep 1.4s ease-in-out infinite;
}
@keyframes sweep {
  0%   { width: 0%;  margin-left: 0; }
  50%  { width: 55%; margin-left: 22%; }
  100% { width: 0%;  margin-left: 100%; }
}
.loading-label { color: var(--text-muted); font-size: .875rem; }

.loading-logo {
  width: 180px;
  height: 180px;
  margin-bottom: 32px;
  animation: logo-pulse 1.8s ease-in-out infinite;
}
@keyframes logo-pulse {
  0%   { opacity: 1;    filter: none; }
  50%  { opacity: 0.18; filter: grayscale(1); }
  100% { opacity: 1;    filter: none; }
}

.state-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 40px 48px;
  max-width: 440px;
  width: 100%;
  text-align: center;
}
.state-card h2 { font-size: 1.125rem; margin-bottom: 10px; }
.state-msg { color: var(--text-secondary); font-size: .875rem; margin-bottom: 20px; }
.state-msg.error { color: var(--danger); }

.success-icon {
  width: 52px; height: 52px;
  background: var(--success-light);
  color: var(--success);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.success-icon .bool-icon { width: 28px; height: 28px; filter: invert(29%) sepia(60%) saturate(500%) hue-rotate(90deg) brightness(85%) contrast(90%); }
.success-actions { display: flex; flex-direction: column; gap: 8px; }

/* ============================================================
   APP HEADER
   ============================================================ */
.app-header {
  background: #393975;
  border-bottom: 3px solid #ef674c;
}
.app-header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 28px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.app-header-tool {
  font-size: 1.125rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: .01em;
}
.app-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-logo {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 4px;
  background: #ffffff;
  padding: 3px;
}
.app-header-name {
  font-size: 1.0625rem;
  font-weight: 700;
  color: rgba(255,255,255,.85);
  letter-spacing: .01em;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.page-header-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 28px 20px;
}
.page-title {
  font-size: 1.4375rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.02em;
  line-height: 1.25;
}
.page-subtitle {
  font-size: .875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   FORM BODY
   ============================================================ */
.form-body {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ============================================================
   FORM SECTIONS (cards)
   ============================================================ */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: visible;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  border-radius: var(--radius) var(--radius) 0 0;
}
.section-header-icon {
  width: 16px; height: 16px;
  opacity: .65;
  flex-shrink: 0;
}
.section-header-title {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
}
.section-header-required {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--brand-orange);
  background: #fef1ee;
  border-radius: 4px;
  padding: 2px 7px;
}
.section-header-optional {
  font-size: .6875rem;
  color: var(--text-muted);
  font-style: italic;
}
.section-header-actions {
  margin-left: auto;
}

.section-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  line-height: 1;
}

.section-body {
  padding: 20px;
}

.section-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  font-size: .875rem;
  color: var(--text-muted);
}
.section-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   ORG SEARCH
   ============================================================ */
.org-search-wrap {
  position: relative;
}
.org-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.org-search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}
.org-search-input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9375rem;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.org-search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(57,57,117,.1);
}
.org-search-input::placeholder { color: var(--text-muted); }

.org-search-spinner {
  position: absolute;
  right: 12px;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.org-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.13);
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
}

.org-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--border);
}
.org-result-item:last-child { border-bottom: none; }
.org-result-item:hover { background: var(--bg); }
.org-result-item:hover .org-result-name { color: var(--accent); }

.org-result-info { flex: 1; min-width: 0; }
.org-result-name {
  font-weight: 700;
  font-size: .9375rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .1s;
}
.org-result-meta {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.org-result-status {
  flex-shrink: 0;
}

.org-result-item--create {
  background: var(--accent-light);
  border-top: 1px solid #d4d4ee;
}
.org-result-item--create:first-child { border-top: none; }
.org-result-item--create:hover { background: #e0e0f0; }
.org-result-item--create .org-result-name { color: var(--accent); }

.org-result-item--empty {
  padding: 14px;
  font-size: .875rem;
  color: var(--text-muted);
  font-style: italic;
  cursor: default;
  text-align: center;
}
.org-result-item--empty:hover { background: none; }

.org-search-hint {
  font-size: .8125rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Org status badges */
.org-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.org-status--active     { background: #e8f5e9; color: #2e7d32; }
.org-status--target     { background: var(--accent-light); color: var(--accent-dark); }
.org-status--disengaged { background: #fff8e1; color: #f57f17; }
.org-status--lost, .org-status--legacy { background: var(--danger-light); color: var(--danger); }

/* Selected org card */
.org-selected-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--accent-light);
  border: 1.5px solid #c8c8e8;
  border-radius: var(--radius-sm);
}
.org-selected-info { flex: 1; min-width: 0; }
.org-selected-name {
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--text-primary);
}
.org-selected-meta {
  font-size: .8125rem;
  color: var(--text-secondary);
  margin-top: 3px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* New org fields */
.new-org-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}
.new-org-fields .form-grid-2 {
  margin: 0;
}

/* New org banner */
.new-org-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--accent-light);
  border: 1px solid #c8c8e8;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 16px;
}
.new-org-banner-icon {
  width: 15px; height: 15px;
  filter: invert(22%) sepia(50%) saturate(600%) hue-rotate(210deg) brightness(80%) contrast(90%);
  flex-shrink: 0;
}

/* ============================================================
   DUPLICATE WARNING
   ============================================================ */
.duplicate-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--warning-light);
  border: 1px solid #f5c400;
  border-radius: var(--radius-sm);
  margin-top: 14px;
}
.duplicate-warning-icon {
  width: 17px; height: 17px;
  flex-shrink: 0;
  margin-top: 1px;
  filter: invert(48%) sepia(70%) saturate(600%) hue-rotate(7deg) brightness(90%) contrast(90%);
}
.duplicate-warning-text {
  flex: 1;
  font-size: .875rem;
  line-height: 1.5;
}
.duplicate-warning-text strong {
  display: block;
  font-weight: 700;
  color: #7c5a00;
}
.duplicate-warning-text span {
  color: var(--text-secondary);
  font-size: .8125rem;
}

/* ============================================================
   CONTACTS SECTION
   ============================================================ */
.contacts-section-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.contacts-from-org-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.contacts-from-org-label .bool-icon {
  width: 13px; height: 13px;
}

.contacts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (max-width: 600px) {
  .contacts-grid { grid-template-columns: 1fr; }
}

.contacts-empty {
  font-size: .875rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
}

.contact-card {
  position: relative;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.contact-card--new {
  background: var(--success-light);
  border: 1px solid #c8e6c9;
}
.contact-card--primary {
  background: var(--surface);
  border: 1.5px solid #c8c8e8;
}

.contact-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding-right: 32px;
}
.contact-card-name {
  font-weight: 700;
  font-size: .9375rem;
}
.contact-card-primary-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.contact-card-new-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--success);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.contact-card-field {
  font-size: .8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.contact-card-field a {
  color: var(--accent);
  text-decoration: none;
}
.contact-card-field a:hover { text-decoration: underline; }

.contact-remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 5px;
  cursor: pointer;
  opacity: .75;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  transition: opacity .12s, background .12s, color .12s;
}
.contact-remove-btn:hover {
  opacity: 1;
  background: var(--danger-light);
  border-color: #f5c6c6;
  color: var(--danger);
}

/* ============================================================
   FORM PRIMITIVES
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
  align-items: start;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  align-items: start;
}
.form-field--full {
  grid-column: 1 / -1;
}
@media (max-width: 560px) {
  .form-grid, .form-grid-2 { grid-template-columns: 1fr; }
  .form-field--full { grid-column: 1; }
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}

.label-icon {
  width: 13px; height: 13px;
  opacity: .6;
  flex-shrink: 0;
}

.required-chip {
  font-size: .6875rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--brand-orange);
  background: #fef1ee;
  border-radius: 4px;
  padding: 1px 6px;
}

/* Text / number inputs */
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="url"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field textarea,
.form-field select:not(.ts-wrapper select) {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9375rem;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}
.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(57,57,117,.1);
}

/* Floating label
 * Strategy: label starts in the "up" position (small, at top). The
 * :placeholder-shown:not(:focus) rule pushes it down when the field is empty
 * and not focused. On focus or when the user types, it snaps back up.
 * The JS-managed .has-value class acts as a fallback for Cleave.js fields.
 */
.float-field {
  position: relative;
}
.float-field .float-input {
  padding: 22px 12px 7px;
}
.float-field textarea.float-input {
  padding-top: 22px;
  resize: vertical;
}

/* Default (up) state: small label at top */
.float-field .float-label {
  position: absolute;
  top: 7px;
  left: 12px;
  transform: none;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  pointer-events: none;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: top .14s ease, font-size .14s ease, font-weight .14s ease,
              letter-spacing .14s ease, text-transform .14s ease,
              color .14s ease, transform .14s ease;
}

/* Empty + unfocused: drop label to placeholder position */
.float-field .float-input:placeholder-shown:not(:focus) + .float-label {
  top: 50%;
  transform: translateY(-50%);
  font-size: .9375rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}
/* Textarea: don't vertically centre — sit near the top-left content area */
.float-field textarea.float-input:placeholder-shown:not(:focus) + .float-label {
  top: 13px;
  transform: none;
  font-size: .9375rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* Focused: accent colour, always in up position */
.float-field .float-input:focus + .float-label {
  color: var(--accent);
  top: 7px;
  transform: none;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
}

/* JS fallback for Cleave.js and programmatic values */
.float-field.has-value .float-label {
  top: 7px;
  transform: none;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
}

/* Date input — normalise browser chrome */
.form-field input[type="date"] {
  height: 40px;
  padding: 0 12px;
  line-height: 40px;
}

/* Select styling (native, outside TomSelect) */
.form-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23939393' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px !important;
  cursor: pointer;
}

/* Tom Select overrides */
.ts-wrapper {
  font-family: inherit;
}
.ts-wrapper .ts-control {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: .9375rem;
  font-family: inherit;
  min-height: 42px;
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(57,57,117,.1);
  outline: none;
}
.ts-wrapper .ts-dropdown {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0,0,0,.1);
  font-family: inherit;
  font-size: .9375rem;
}
.ts-wrapper .ts-dropdown .option { padding: 9px 12px; }
.ts-wrapper .ts-dropdown .option.active { background: var(--accent-light); color: var(--accent); }
.ts-wrapper .ts-dropdown .option:hover { background: var(--bg); }

/* Segmented controls */
.seg-group {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}
.seg-btn {
  flex: 1;
  height: 38px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, color .12s;
  border-right: 1px solid var(--border);
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--border); color: var(--text-primary); }
.seg-btn.active {
  background: var(--accent);
  color: #fff;
}
.seg-btn.active:hover { background: var(--accent-dark); }

/* Toggle switch */
.toggle-row-pair {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.next-action-toggle-row {
  display: flex;
  align-items: center;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}
.toggle-input { display: none; }
.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  flex-shrink: 0;
  transition: background .2s;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-input:checked + .toggle-switch { background: var(--accent); }
.toggle-input:checked + .toggle-switch::after { left: 18px; }

/* Validation message */
.validation-msg {
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: .8125rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: background .12s, color .12s, border-color .12s, opacity .12s;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn-success {
  background: #16a34a;
  color: #fff;
  font-weight: 700;
}
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-ghost {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); border-color: #c0c7d0; color: var(--text-primary); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #a12a26; }

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: .8rem;
}

.btn-icon-sm {
  width: 14px; height: 14px;
  flex-shrink: 0;
}
.btn-success .btn-icon-sm { filter: brightness(0) invert(1); }
.btn-primary .btn-icon-sm { filter: brightness(0) invert(1); }

/* ============================================================
   STICKY SUBMIT BAR
   ============================================================ */
.submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  z-index: 50;
}
.submit-bar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}
.submit-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   MODAL / DRAWER
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.42);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.add-note-modal { max-width: 560px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: none;
  background: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: background .12s, color .12s;
  flex-shrink: 0;
  padding: 0;
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.add-note-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.drawer-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.drawer-title-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
}

/* ============================================================
   FLATPICKR TWEAKS
   ============================================================ */
.flatpickr-calendar {
  font-family: 'Plus Jakarta Sans', sans-serif;
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.15);
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.flatpickr-day:hover {
  background: var(--accent-light);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .app-header-inner { padding: 0 16px; }
  .page-header-inner { padding: 16px; }
  .form-body { padding: 16px; }
  .section-body { padding: 16px; }
  .submit-bar-inner { padding: 12px 16px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .state-card { padding: 28px 24px; }
}
