/* Entity Registry — spruce & brass ledger */
:root {
  --ink:    #17251f;
  --spruce: #2e5d47;
  --spruce-dark: #1e3d30;
  --brass:  #a5802f;
  --paper:  #eef1ec;
  --card:   #ffffff;
  --line:   #d5dcd4;
  --muted:  #6b7a70;
  --danger: #9c3a2b;
  --ok-bg:  #e4efe6;
  --err-bg: #f6e4df;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
h1, h2, .brand, .tree-name { font-family: Georgia, "Times New Roman", serif; letter-spacing: .01em; }
h1 { font-size: 1.5rem; margin: 0; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 0; font-weight: 600; }
a { color: var(--spruce); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--spruce-dark); color: #fff;
  padding: .65rem 1.25rem;
  border-bottom: 3px solid var(--brass);
}
.brand a { color: #fff; text-decoration: none; font-size: 1.15rem; }
.mainnav { display: flex; gap: 1rem; flex-wrap: wrap; }
.mainnav a { color: #d9e4dc; text-decoration: none; padding: .2rem 0; border-bottom: 2px solid transparent; }
.mainnav a:hover { color: #fff; border-bottom-color: var(--brass); }
.whoami { margin-left: auto; display: flex; align-items: center; gap: .75rem; font-size: .85rem; color: #c8d4cb; }

.wrap { max-width: 1100px; margin: 1.5rem auto 4rem; padding: 0 1rem; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-2 .card { margin-bottom: 0; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* Ownership tree — the registry's signature */
.tree { list-style: none; margin: 0; padding-left: 0; }
.tree .tree { padding-left: 1.6rem; border-left: 2px solid var(--line); margin-left: .65rem; }
.tree li { position: relative; margin: .45rem 0; }
.tree .tree > li::before {
  content: ""; position: absolute; left: -1.6rem; top: 1.1rem;
  width: 1.1rem; height: 2px; background: var(--line);
}
.tree-node {
  display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .6rem;
  text-decoration: none; color: var(--ink);
  padding: .35rem .6rem; border-radius: 4px; border: 1px solid transparent;
}
.tree-node:hover { background: var(--paper); border-color: var(--line); }
.tree-name { font-size: 1.02rem; }
.tree-meta { color: var(--muted); font-size: .8rem; }
.tree-dissolved > .tree-node .tree-name { text-decoration: line-through; color: var(--muted); }

/* Badges */
.badge {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  padding: .12rem .5rem; border-radius: 999px; white-space: nowrap;
}
.badge-active    { background: var(--ok-bg); color: var(--spruce-dark); }
.badge-pending   { background: #f3edda; color: #7a5f18; }
.badge-dissolved { background: var(--err-bg); color: var(--danger); }
.badge-tasks     { background: #e7ecf5; color: #2f4a78; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .4rem .6rem; border-bottom: 2px solid var(--line); }
td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.row-muted td { color: var(--muted); }
.td-actions { white-space: nowrap; text-align: right; }
.td-actions form { display: inline-block; margin-left: .3rem; }
table.kv th { text-transform: none; letter-spacing: 0; font-size: .9rem; width: 10rem; border-bottom: 1px solid var(--line); }

/* Forms */
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .1rem; }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=date], select, textarea {
  width: 100%; padding: .5rem .6rem; margin-top: .2rem;
  border: 1px solid var(--line); border-radius: 4px;
  font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brass); outline-offset: 1px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1.2rem; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }

/* Buttons */
.btn {
  display: inline-block; cursor: pointer;
  border: 1px solid var(--line); border-radius: 4px;
  background: #fff; color: var(--ink);
  padding: .45rem .9rem; font: inherit; text-decoration: none;
}
.btn:hover { border-color: var(--spruce); }
.btn-primary { background: var(--spruce); border-color: var(--spruce); color: #fff; }
.btn-primary:hover { background: var(--spruce-dark); }
.btn-danger { color: var(--danger); border-color: #e3c4bc; }
.btn-danger:hover { background: var(--err-bg); }
.btn-quiet { background: transparent; border-color: #4a6a58; color: #d9e4dc; }
.btn-small { padding: .15rem .55rem; font-size: .78rem; }

/* Misc */
.flash { padding: .6rem .9rem; border-radius: 4px; margin-bottom: 1rem; }
.flash-ok  { background: var(--ok-bg); color: var(--spruce-dark); }
.flash-err { background: var(--err-bg); color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.inline { display: inline; }
.inline-reset { display: flex; gap: .4rem; margin-top: .4rem; }
.inline-reset input { width: 14rem; }
details.inline summary { list-style: none; }
.secret { background: #fdf6e3; border: 1px solid var(--brass); padding: .1rem .4rem; border-radius: 3px; }
.crumb { margin: 0; font-size: .8rem; }
.entity-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.entity-head p { margin: .15rem 0; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--line); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tabs a {
  text-decoration: none; color: var(--muted);
  padding: .45rem .9rem; border: 1px solid transparent; border-bottom: none;
  border-radius: 6px 6px 0 0; margin-bottom: -2px;
}
.tabs a:hover { color: var(--ink); }
.tabs .tab-active {
  color: var(--ink); background: var(--card);
  border-color: var(--line); border-bottom: 2px solid var(--card);
}

/* Login */
.login-card { max-width: 400px; margin: 8vh auto; }
.login-card form label { margin-bottom: .7rem; }
.login-card button { width: 100%; margin-top: .5rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Calendar */
.cal-nav { display: flex; gap: .4rem; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  background: var(--line); gap: 1px; margin-top: .75rem;
}
.cal-dow {
  background: var(--paper); padding: .35rem .5rem;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.cal-cell { background: #fff; min-height: 6.2rem; padding: .35rem .4rem; }
.cal-empty { background: var(--paper); }
.cal-today { background: #f6faf3; box-shadow: inset 0 0 0 2px var(--brass); }
.cal-daynum { font-size: .78rem; color: var(--muted); margin-bottom: .25rem; }
.cal-today .cal-daynum { color: var(--brass); font-weight: 700; }
.cal-event {
  display: block; font-size: .74rem; line-height: 1.25;
  padding: .18rem .35rem; margin-bottom: .25rem;
  border-radius: 3px; text-decoration: none; color: var(--ink);
  border-left: 3px solid;
}
.cal-filing { background: #eef3ea; border-left-color: var(--spruce); }
.cal-task   { background: #eaeef5; border-left-color: #2f4a78; }
.cal-closed { opacity: .55; text-decoration: line-through; }
.cal-overdue { background: var(--err-bg); border-left-color: var(--danger); }
.cal-overdue-text { color: var(--danger); }
.cal-entity { display: block; color: var(--muted); font-size: .68rem; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 2px; vertical-align: middle; }
.dot-filing { background: var(--spruce); }
.dot-task   { background: #2f4a78; }
@media (max-width: 800px) {
  .cal-grid { grid-template-columns: repeat(7, minmax(2.5rem, 1fr)); font-size: .9em; }
  .cal-cell { min-height: 4rem; }
  .cal-entity { display: none; }
}

/* Drag & drop upload zone */
.dropzone {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 1.6rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--spruce); }
.dz-over { border-color: var(--brass); background: #faf6ea; }
.dz-has-files { border-style: solid; border-color: var(--spruce); background: #f4f8f2; }
.dropzone input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.dz-title { margin: 0; font-family: Georgia, serif; font-size: 1.05rem; color: var(--ink); }
.dz-sub { margin: .2rem 0 0; font-size: .8rem; color: var(--muted); }
.dz-list { list-style: none; margin: .6rem 0 0; padding: 0; font-size: .82rem; color: var(--spruce-dark); position: relative; z-index: 1; pointer-events: none; }
.dz-list li { padding: .1rem 0; }

/* People tab */
.people-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .people-grid { grid-template-columns: 1fr; } }
.person { border: 1px solid var(--line); border-radius: 6px; padding: .9rem 1rem; background: #fdfdfc; }
.person-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.person-name { font-family: Georgia, serif; font-size: 1.08rem; display: block; }
.person-title { color: var(--brass); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.person-contacts { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; margin: .5rem 0; font-size: .86rem; }
.person-resp { font-size: .88rem; margin: .4rem 0; }
.person-edit summary { list-style: none; display: inline-block; margin-top: .3rem; }

/* Accounting */
.num, .num-in { text-align: right; }
.num-in { width: 7rem; }
.num-table td.num, .num-table th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--danger); }
.je-entry { border: 1px solid var(--line); border-radius: 6px; margin-bottom: .8rem; overflow: hidden; }
.je-head { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .8rem; background: var(--paper); font-size: .9rem; align-items: center; flex-wrap: wrap; }
.je-detail td { padding: .3rem .8rem; font-size: .88rem; }
.je-lines select, .je-lines input { margin-top: 0; }
.je-lines td { padding: .25rem .3rem; }
.report-controls { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.report-controls label { margin: 0; }
.report-title { font-family: Georgia, serif; margin: 1rem 0 .5rem; }
.report th { background: var(--paper); text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--ink); padding-top: .8rem; }
.report-total td { border-top: 1px solid var(--ink); font-weight: 600; }
.report-grand td { border-top: 2px solid var(--ink); font-weight: 700; }
.tabs-extra { padding: .45rem .9rem; border-radius: 6px 6px 0 0; }

/* Banking & reconciliation */
.check-inline { display: flex; align-items: center; gap: .45rem; font-size: .9rem; color: var(--ink); margin-top: 1.4rem; }
.check-inline input { width: auto; margin: 0; }
.recon-stats { display: flex; gap: 2rem; flex-wrap: wrap; padding: .6rem .8rem; background: var(--paper); border-radius: 6px; margin-bottom: .8rem; font-size: .92rem; }
.ok-text { color: var(--spruce); }

/* Task priorities */
.pri {
  display: inline-block; width: 1.45rem; height: 1.45rem; line-height: 1.45rem;
  text-align: center; border-radius: 50%; font-size: .78rem; font-weight: 700;
}
.pri-A { background: var(--err-bg); color: var(--danger); border: 1px solid var(--danger); }
.pri-B { background: #f3edda; color: #7a5f18; border: 1px solid var(--brass); }
.pri-C { background: var(--paper); color: var(--muted); border: 1px solid var(--line); }
.task-desc { font-size: .86rem; color: var(--muted); margin-top: .2rem; white-space: normal; }
.task-edit summary { list-style: none; display: inline-block; margin-top: .3rem; }
