/* Baobab Live Projects — minimal internal admin styling */

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #e3e3df;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --accent: #1f3a3d;
  --accent-soft: #e3eded;
  --danger: #c0392b;
  --danger-soft: #fbe6e3;

  --status-planning: #d8e6f3;     --status-planning-fg:#1d3a6b;
  --status-live: #d8edd0;         --status-live-fg:#1f5b22;
  --status-onhold: #f6e6b3;       --status-onhold-fg:#6b521b;
  --status-legacy: #e1e1de;       --status-legacy-fg:#3a3a36;
  --status-pitching: #e6dcf3;     --status-pitching-fg:#4a2e7a;
  --status-lost: #f3d4d4;         --status-lost-fg:#822121;

  --pay-unpaid: #f3d4d4;          --pay-unpaid-fg:#822121;
  --pay-fully-paid: #d8edd0;      --pay-fully-paid-fg:#1f5b22;
  --pay-pctpaid: #f6e6b3;         --pay-pctpaid-fg:#6b521b;

  --surface-alt: #fafaf7;
  --input-bg: #ffffff;
  --invalid-bg: #fff8f7;
  --accent-hover: #16292b;
  --on-accent: #ffffff;
  --logo: #252e37;

  --radius: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --menu-shadow: 0 10px 24px rgba(0,0,0,.08);

  color-scheme: light;
}

/* Dark theme */
:root[data-theme="dark"] {
  --bg: #151817;
  --surface: #1d2120;
  --surface-alt: #232827;
  --border: #323837;
  --text: #e8e8e4;
  --muted: #9a9e98;
  --accent: #8cc4c4;
  --accent-soft: #24393a;
  --accent-hover: #a6d4d4;
  --on-accent: #10201f;
  --danger: #ef7a6c;
  --danger-soft: #3a2220;
  --input-bg: #181c1b;
  --invalid-bg: #2c1d1b;
  --logo: #dfdcda;

  --shadow: 0 1px 2px rgba(0,0,0,.3);
  --menu-shadow: 0 10px 24px rgba(0,0,0,.45);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Figtree', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

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

.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.app-header .brand a { display: inline-flex; align-items: center; gap: .6rem; color: var(--text); font-size: 1.05rem; }
.app-header .brand a:hover { text-decoration: none; }
.app-header .brand-logo { display: block; width: 94px; height: 18px; color: var(--logo); }
.app-header .brand-logo svg { display: block; width: 100%; height: 100%; }
.app-header .brand-name { color: var(--muted); font-weight: 500; font-size: 1rem; padding-left: .6rem; border-left: 1px solid var(--border); }
.header-right { display: flex; align-items: center; gap: 1rem; }
.app-header nav { display: flex; gap: 1rem; }

/* Theme switch */
.theme-switch {
  position: relative;
  flex: 0 0 auto;
  width: 3.1rem; height: 1.7rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.theme-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-switch .theme-icon {
  position: absolute; top: 50%;
  width: .8rem; height: .8rem;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 1;
  transition: color .2s;
}
.theme-switch .theme-icon-sun  { left: .42rem; color: var(--on-accent); }
.theme-switch .theme-icon-moon { right: .42rem; }
:root[data-theme="dark"] .theme-switch .theme-icon-sun  { color: var(--muted); }
:root[data-theme="dark"] .theme-switch .theme-icon-moon { color: var(--on-accent); }
.theme-switch .theme-thumb {
  position: absolute; top: 2px; left: 2px;
  width: calc(1.7rem - 6px); height: calc(1.7rem - 6px);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .2s ease;
}
:root[data-theme="dark"] .theme-switch .theme-thumb { transform: translateX(1.4rem); }
@media (prefers-reduced-motion: reduce) {
  .theme-switch, .theme-switch .theme-thumb { transition: none; }
}
.app-header nav a { color: var(--muted); padding: .35rem .6rem; border-radius: var(--radius); font-weight: 500; }
.app-header nav a.active { background: var(--accent-soft); color: var(--accent); }
.app-header nav a.logout { color: var(--danger); }

.app-main { padding: 1.25rem 1.25rem 3rem; max-width: 100%; }
.app-footer { padding: 1rem 1.25rem; color: var(--muted); font-size: 1rem; }

.muted { color: var(--muted); }
.small { font-size: 1rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1em; }

.flash { padding: .65rem .85rem; border-radius: var(--radius); margin-bottom: .85rem; }
.flash-success { background: #d8edd0; color: #1f5b22; }
.flash-error   { background: #fbe6e3; color: #822121; }
:root[data-theme="dark"] .flash-success { background: #1f3322; color: #a8d8a0; }
:root[data-theme="dark"] .flash-error   { background: #3a2220; color: #f2b0a8; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.page-header h2 { margin: 0 0 .15rem; font-size: 1.35rem; font-weight: 600; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .5rem .9rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit; cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-small { padding: .3rem .55rem; font-size: 1rem; }

/* Filters */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  background: var(--surface);
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.filters label { display: block; font-size: 1rem; color: var(--muted); margin-bottom: .2rem; }
.filters select, .filters input { width: 100%; }
.filters .filter-actions { display: flex; align-items: flex-end; gap: .5rem; }
.filters .filter-search { grid-column: 1 / -1; }
.search-field { position: relative; }
.search-field .search-icon {
  position: absolute; left: .7rem; top: 50%;
  width: 1rem; height: 1rem;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.filters .search-field input { padding: .6rem .7rem .6rem 2.2rem; font-size: 1rem; }
.tags-filter select { height: 5rem; }
.multi-filter { position: relative; }
.multi-filter summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  list-style: none;
  cursor: pointer;
  width: 100%;
  min-height: 2.25rem;
  padding: .45rem .55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  font: inherit;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.multi-filter summary::-webkit-details-marker { display: none; }
.multi-filter summary::after {
  content: "";
  flex: 0 0 auto;
  width: .55rem;
  height: .55rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-.15rem) rotate(45deg);
  color: var(--muted);
}
.multi-filter summary:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.multi-filter-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + .25rem);
  left: 0;
  right: 0;
  padding: .35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  box-shadow: var(--menu-shadow);
}
.multi-filter-menu label {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
  padding: .4rem .35rem;
  color: var(--text);
}
.multi-filter-menu input[type="checkbox"] { width: auto; }

/* Inputs */
input[type=text], input[type=search], input[type=number], input[type=email], input[type=password],
select, textarea {
  width: 100%;
  padding: .45rem .55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  font: inherit;
  color: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
input.is-invalid, select.is-invalid, textarea.is-invalid {
  border-color: var(--danger);
  background: var(--invalid-bg);
}
input.is-invalid:focus, select.is-invalid:focus, textarea.is-invalid:focus {
  outline-color: var(--danger-soft);
  border-color: var(--danger);
}
textarea { resize: vertical; }

/* Table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.projects-table {
  width: 100%; border-collapse: collapse; min-width: 1400px;
}
.projects-table th, .projects-table td {
  padding: .55rem .65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}
.projects-table th { background: var(--surface-alt); font-weight: 600; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; position: sticky; top: 0; z-index: 1; }
.projects-table tbody tr:hover { background: var(--surface-alt); }
.projects-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.projects-table td.notes { color: var(--muted); }
.projects-table .notes-scroll {
  width: 360px;
  overflow-x: auto;
  white-space: nowrap;
}
.projects-table .notes-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.projects-table td.empty { text-align: center; padding: 2rem; color: var(--muted); }

.pill { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: 1rem; font-weight: 500; }
.status-planning { background: var(--status-planning); color: var(--status-planning-fg); }
.status-live     { background: var(--status-live);     color: var(--status-live-fg); }
.status-on-hold  { background: var(--status-onhold);   color: var(--status-onhold-fg); }
.status-legacy   { background: var(--status-legacy);   color: var(--status-legacy-fg); }
.status-pitching { background: var(--status-pitching); color: var(--status-pitching-fg); }
.status-lost     { background: var(--status-lost);     color: var(--status-lost-fg); }
.pay-unpaid      { background: var(--pay-unpaid);      color: var(--pay-unpaid-fg); }
.pay-fully-paid  { background: var(--pay-fully-paid);  color: var(--pay-fully-paid-fg); }
.pay-pctpaid     { background: var(--pay-pctpaid);     color: var(--pay-pctpaid-fg); }

.tag-chip {
  display: inline-block; padding: .05rem .45rem; margin: 0 .15rem .15rem 0;
  background: var(--tag-bg, var(--accent-soft)); color: var(--tag-fg, var(--accent));
  border-radius: 999px; font-size: 1rem;
}
.client-pill {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  padding: .14rem .55rem;
  border-radius: 999px;
  background: var(--client-color);
  color: var(--client-text);
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.color-swatch {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-right: .4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--swatch-color);
  vertical-align: -.16rem;
}
.color-field {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.color-field input[type=color] {
  width: 2.5rem;
  min-width: 2.5rem;
  height: 2.1rem;
  padding: .15rem;
  cursor: pointer;
}

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
.login-card { background: var(--surface); padding: 2rem; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 360px; }
.login-card h1 { margin: 0 0 .25rem; font-size: 1.3rem; font-weight: 500; }
.login-card form { margin-top: 1rem; display: grid; gap: .55rem; }
.login-card button { padding: .6rem; background: var(--accent); color: var(--on-accent); border: none; border-radius: var(--radius); cursor: pointer; font: inherit; }

/* Project form */
.project-form .grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .9rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem;
}
.field { display: flex; flex-direction: column; }
.field label { font-size: 1rem; color: var(--muted); margin-bottom: .25rem; }
.field .inline { display: flex; gap: .5rem; }
.field .inline > * { flex: 1; }
.field.has-error > label { color: var(--danger); }
.field-error {
  display: grid;
  gap: .1rem;
  margin-top: .25rem;
  color: var(--danger);
  font-size: 1rem;
  line-height: 1.35;
}
.field-error span { display: block; }
.inline-check { display: inline-flex; align-items: center; gap: .35rem; font-size: 1rem; margin-top: .25rem; color: var(--muted); }
.col-span-2 { grid-column: span 2; }
.tag-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .35rem .65rem; padding: .5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-alt);
}
.tag-check { display: flex; gap: .4rem; align-items: center; font-size: 1rem; }
.tag-check .tag-chip { margin: 0; }
.form-actions { display: flex; gap: .6rem; margin-top: 1rem; }
.add-contact-row { align-self: end; }
.add-contact-row.is-open { align-self: stretch; }
.add-contact-row details { background: var(--surface-alt); padding: .5rem .75rem; border-radius: var(--radius); border: 1px dashed var(--border); }
.add-contact-row summary { cursor: pointer; color: var(--accent); font-size: 1rem; }
.new-contact-inputs { margin-top: .5rem; flex-wrap: wrap; }
.new-contact-inputs input { flex: 1 1 220px; }

/* History */
.history { margin-top: 2rem; }
.history-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.history-table th, .history-table td { padding: .5rem .7rem; border-bottom: 1px solid var(--border); font-size: 1rem; text-align: left; vertical-align: top; }
.history-table th { background: var(--surface-alt); font-weight: 600; color: var(--muted); font-size: 1rem; text-transform: uppercase; }

/* Clients page */
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
.simple-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.simple-table th, .simple-table td { padding: .55rem .65rem; border-bottom: 1px solid var(--border); text-align: left; font-size: 1rem; vertical-align: middle; }
.simple-table th { background: var(--surface-alt); font-weight: 600; color: var(--muted); font-size: 1rem; text-transform: uppercase; }
.simple-table td.empty { text-align: center; color: var(--muted); padding: 1.5rem; }
.simple-table td.inline { display: flex; gap: .35rem; align-items: center; }
.stacked-form { display: grid; gap: .4rem; background: var(--surface); padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.stacked-form label { font-size: 1rem; color: var(--muted); }
.stacked-form button { justify-self: start; margin-top: .35rem; }
.inline-form { display: contents; }

@media (max-width: 1100px) {
  .project-form .grid { grid-template-columns: repeat(2, 1fr); }
  .col-span-2 { grid-column: span 2; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .app-header { padding: .65rem 1rem; gap: .5rem; }
  .app-header .brand-name { display: none; }
  .header-right, .app-header nav { gap: .35rem; }
  .app-header nav a { padding: .35rem .45rem; white-space: nowrap; }
  .project-form .grid { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
}
