/* sanbiki-crm: one stylesheet in the Sanbiki corporate identity (build.sanbiki.ai, portal.sanbiki.ai). Mobile first. */
:root {
  color-scheme: light;
  --sb-accent: #E5A630; --sb-on: #1A1A1A; --sb-link: #8A5A00; --sb-wall: #F2F2F0; --sb-card: #FFFFFF;
  --sb-text: #111111; --sb-meta: #6B6B6B; --sb-bar: #F9F9F8; --sb-chip: #F2F2F0; --sb-line: #E4E4E0;
  --sb-danger: #B42318; --sb-note: #FFF1C9;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 -apple-system, system-ui, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
       color: var(--sb-text); background: var(--sb-wall); min-height: 100dvh; }
a { color: var(--sb-link); }
h1 { font-size: 22px; font-weight: 700; margin: 4px 0 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
h2 { font-size: 17px; font-weight: 700; margin: 24px 0 10px; }
p { margin: 0 0 14px; }
.meta, .muted { color: var(--sb-meta); font-size: 14px; }
.warn { color: var(--sb-link); font-weight: 600; }
.error { color: var(--sb-danger); font-weight: 600; }
.note { padding: 10px 12px; border-radius: 12px; background: var(--sb-note); margin: 0 0 14px; font-size: 14px; }

/* top bar: logo, name, nav, language chips */
.sb-hd { background: var(--sb-bar); position: sticky; top: 0; z-index: 5; padding-top: env(safe-area-inset-top);
         border-bottom: 1px solid var(--sb-line); }
.sb-hd-in { max-width: 1120px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 8px 10px;
            flex-wrap: wrap; }
.sb-id { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--sb-text); min-width: 0; }
.sb-id img { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: block; }
.sb-id div { display: flex; flex-direction: column; line-height: 1.25; }
.sb-id b { font-size: 17px; font-weight: 700; }
.sb-id span { color: var(--sb-meta); font-size: 12px; }
.sb-nav { order: 2; margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sb-l { font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--sb-text); padding: 7px 13px;
        border-radius: 20px; background: var(--sb-card); border: 1px solid var(--sb-line); white-space: nowrap;
        cursor: pointer; width: auto; min-height: 0; }
.sb-l:hover { color: var(--sb-link); border-color: var(--sb-accent); }
.sb-l[aria-current] { border-color: var(--sb-accent); }
.sb-l.sb-quiet { background: transparent; border-color: transparent; color: var(--sb-meta); }
.sb-nav form { margin: 0; }
.sb-lt { order: 3; display: inline-flex; background: var(--sb-chip); border: 1px solid var(--sb-line); border-radius: 20px;
         padding: 3px; gap: 2px; }
.sb-lt a { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-decoration: none; color: var(--sb-meta);
           padding: 6px 11px; border-radius: 16px; min-width: 38px; text-align: center; line-height: 1.2; }
.sb-lt a[aria-current] { background: var(--sb-card); color: var(--sb-text); box-shadow: 0 1px 2px rgba(0,0,0,.14); }
@media (max-width: 640px) {
  .sb-lt { order: 2; margin-left: auto; }
  .sb-nav { order: 3; margin-left: 0; flex-basis: 100%; }
}

/* page */
main { max-width: 1120px; margin: 0 auto; padding: 12px 12px max(24px, env(safe-area-inset-bottom)); }
@media (min-width: 641px) { main { padding: 20px 16px 40px; } }
.card { background: var(--sb-card); border-radius: 16px; padding: 18px 16px; margin: 0 0 14px; }
.card.narrow, main.signin .card { max-width: 420px; margin: 32px auto; padding: 20px 18px; }
.card > :last-child { margin-bottom: 0; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 900px) { .grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* forms */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
label { display: block; margin: 0 0 12px; }
label > span { display: block; margin-bottom: 6px; color: var(--sb-meta); font-size: 13px; }
label.contact > span { color: var(--sb-link); }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0 14px 6px 0; color: var(--sb-text); font-size: 15px; }
.checks { display: flex; flex-wrap: wrap; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: inherit; padding: 11px 12px; border: 1px solid var(--sb-meta);
  border-radius: 12px; background: #fff; min-height: 44px; }
input[readonly], fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea {
  background: var(--sb-bar); border-color: var(--sb-line); color: var(--sb-meta); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--sb-link); }
button { font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 20px; padding: 10px 18px;
         min-height: 44px; background: var(--sb-accent); color: var(--sb-on); }
button.wide, main.signin button { width: 100%; }
button.link { background: none; color: var(--sb-link); padding: 0 4px; min-height: 0; font-weight: 600; text-decoration: underline; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--sb-link); outline-offset: 2px; }
form.inline { display: inline; }
.search { display: flex; gap: 8px; margin: 0 0 14px; }
.search input { flex: 1; min-width: 0; }
.danger { margin: 18px 0; }
.danger button { background: transparent; color: var(--sb-danger); border: 1px solid var(--sb-danger); }
details.card > summary { cursor: pointer; font-weight: 600; color: var(--sb-link); list-style: none; }
details.card > summary::before { content: "+ "; }
details.card[open] > summary { margin-bottom: 12px; }
details.card[open] > summary::before { content: "− "; }

/* tables in a card; they scroll sideways on a phone */
.scroll { background: var(--sb-card); border-radius: 16px; overflow-x: auto; margin: 0 0 14px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--sb-line); white-space: nowrap; vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--sb-meta); }
tr:last-child td { border-bottom: 0; }
td a { font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }
td.empty { color: var(--sb-meta); }
ul.plain { list-style: none; padding: 0; margin: 0 0 14px; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--sb-line); }
ul.plain li:last-child { border-bottom: 0; }

/* chips */
.tag, .stage { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .02em; padding: 2px 9px;
               border-radius: 20px; background: var(--sb-chip); border: 1px solid var(--sb-line); color: var(--sb-meta); }
.stage-customer { background: #E7F4EA; border-color: #BFE0C7; color: #1F6B34; }
.stage-trial { background: var(--sb-note); border-color: #F1D27A; color: var(--sb-link); }
.stage-lead { background: #EEF2FB; border-color: #CCD7F0; color: #2B4A8B; }
.stage-churned { background: #FBEDEC; border-color: #F0C9C5; color: var(--sb-danger); }
.stage-internal { background: var(--sb-chip); }
code { font: 13px ui-monospace, Menlo, monospace; }
main.signin input[type=email], main.signin input[type=password] { margin-bottom: 12px; }
.tag.new { background: #E7F4EA; border-color: #BFE0C7; color: #1F6B34; }
.tag.off { background: #FBEDEC; border-color: #F0C9C5; color: var(--sb-danger); }
.pill { display: inline-block; margin: 0 6px 4px 0; }
ol.versions { list-style: none; padding: 0; margin: 0; }
ol.versions li { padding: 10px 0; border-bottom: 1px solid var(--sb-line); }
ol.versions li:last-child { border-bottom: 0; }
.vhead { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
table.diff { margin-top: 6px; font-size: 13px; }
table.diff td { padding: 4px 8px; white-space: normal; word-break: break-word; }
table.diff td.from { color: var(--sb-danger); text-decoration: line-through; }
table.diff td.to { color: #1F6B34; }
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--sb-meta); font-size: 13px; }
dl.facts dd { margin: 0; word-break: break-word; }

/* agent sign-in: the code the owner compares with the agent's */
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px; letter-spacing: .12em; }
legend { font-weight: 600; margin-bottom: 8px; }

/* company tree (parent_id): the list as an indented tree, breadcrumbs, group card, company references */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-start; margin: 0 0 6px; }
.toolbar .search { flex: 1 1 260px; margin-bottom: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; font-weight: 600; text-decoration: none;
       border-radius: 20px; padding: 10px 18px; min-height: 44px; background: var(--sb-accent); color: var(--sb-on);
       white-space: nowrap; border: 1px solid var(--sb-accent); }
.btn:hover { filter: brightness(.96); }
.btn.small { padding: 6px 14px; min-height: 36px; font-size: 14px; }
.btn.ghost { background: var(--sb-card); border-color: var(--sb-line); color: var(--sb-text); }
.actions { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 14px; color: var(--sb-meta); margin: 0 0 2px; }
.crumbs a { text-decoration: none; font-weight: 600; }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-current] { color: var(--sb-text); }
.co-sep { color: var(--sb-meta); margin: 0 5px; }
.coref { white-space: nowrap; }
.coref a.co-up { color: var(--sb-meta); font-weight: 500; }
.tag.sub { background: #EEF2FB; border-color: #CCD7F0; color: #2B4A8B; }
.tree-tools { margin: 0 0 8px; font-size: 14px; }
table.tree td.co-cell { white-space: nowrap; }
table.tree tr.parent td.co-cell a.co-name { font-weight: 700; }
table.tree tr:not(.d0) td.co-cell a.co-name::before { content: "└ "; color: var(--sb-meta); font-weight: 400; }
table.tree tr[hidden] { display: none; }
.twisty { background: none; border: 0; padding: 0; margin: 0 6px 0 0; min-height: 0; width: 26px; height: 26px;
          color: var(--sb-text); font-size: 16px; line-height: 1; border-radius: 6px; vertical-align: 0; }
.twisty::before { content: "▾"; }
.twisty[aria-expanded="false"]::before { content: "▸"; }
.twisty:hover { background: var(--sb-chip); color: var(--sb-text); }
.twisty-sp { display: inline-block; width: 26px; margin-right: 6px; }
section.group .head h2 { margin-top: 0; }
ul.cotree { list-style: none; padding: 0; margin: 8px 0 0; }
ul.cotree li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 8px; border-bottom: 1px solid var(--sb-line); }
ul.cotree li:last-child { border-bottom: 0; }
ul.cotree li:not(.d0)::before { content: "└"; color: var(--sb-meta); }
ul.cotree li.current { background: var(--sb-note); border-radius: 10px; }
ul.cotree li a { font-weight: 600; text-decoration: none; }
ul.cotree li.d0 > a, ul.cotree li.d0 > b { font-size: 16px; }
.form-narrow { max-width: 640px; }
table.tree tr.d1 td.co-cell { padding-left: calc(12px + 1.6em); }
ul.cotree li.d1 { padding-left: 1.6em; }
table.tree tr.d2 td.co-cell { padding-left: calc(12px + 3.2em); }
ul.cotree li.d2 { padding-left: 3.2em; }
table.tree tr.d3 td.co-cell { padding-left: calc(12px + 4.8em); }
ul.cotree li.d3 { padding-left: 4.8em; }
table.tree tr.d4 td.co-cell { padding-left: calc(12px + 6.4em); }
ul.cotree li.d4 { padding-left: 6.4em; }
table.tree tr.d5 td.co-cell { padding-left: calc(12px + 8.0em); }
ul.cotree li.d5 { padding-left: 8.0em; }
table.tree tr.d6 td.co-cell { padding-left: calc(12px + 9.6em); }
ul.cotree li.d6 { padding-left: 9.6em; }
table.tree tr.d7 td.co-cell { padding-left: calc(12px + 11.2em); }
ul.cotree li.d7 { padding-left: 11.2em; }
table.tree tr.d8 td.co-cell { padding-left: calc(12px + 12.8em); }
ul.cotree li.d8 { padding-left: 12.8em; }
