/* Company Hub — CRM design system (Odoo/Zoho-inspired) */
:root {
  --brand: #714b67; --brand-dark: #5d3d55; --brand-ink: #f3eaf1;
  --bg: #f1f0f5; --sheet: #ffffff; --ink: #1f2532; --muted: #7c8493;
  --accent: #714b67; --accent-soft: #f3ecf2; --line: #e2e2ea; --line-dark: #cfcfda;
  --green: #28a06a; --green-soft: #e3f4ec; --amber: #c47f0e; --amber-soft: #fcf1dd;
  --red: #d44b3f; --red-soft: #fbe9e7; --gray: #67707f; --gray-soft: #ededf2;
  --purple: #6d5bd0; --purple-soft: #edeafa; --teal: #0e8f8f; --teal-soft: #e0f2f2;
  --shadow: 0 1px 3px rgba(31,37,50,.08);
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
       sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.01em; }

/* ================= Top app bar ================= */
.appbar { background: var(--brand); color: var(--brand-ink); display: flex; align-items: center;
          gap: .25rem; padding: 0 1rem 0 .8rem; height: 46px; position: sticky; top: 0; z-index: 50; }
.appbar .brand { color: #fff; font-weight: 700; font-size: .98rem; padding: 0 .7rem 0 .2rem;
                 display: flex; align-items: center; gap: .45rem; white-space: nowrap; }
.appbar nav { display: flex; align-items: center; gap: .15rem; overflow-x: auto; }
.appbar nav a { color: rgba(255,255,255,.78); padding: .34rem .8rem; border-radius: 6px;
                font-weight: 500; font-size: .9rem; white-space: nowrap; }
.appbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.appbar nav a.active { background: rgba(0,0,0,.28); color: #fff; }
.appbar .search { margin-left: auto; width: 300px; }
.appbar .search input { width: 100%; padding: .35rem .8rem; border-radius: 6px; border: 0;
                        background: rgba(255,255,255,.16); color: #fff; font: inherit; font-size: .87rem; }
.appbar .search input::placeholder { color: rgba(255,255,255,.55); }
.appbar .search input:focus { outline: 0; background: #fff; color: var(--ink); }
.appbar .user { display: flex; align-items: center; gap: .6rem; margin-left: .8rem;
                font-size: .85rem; color: rgba(255,255,255,.85); white-space: nowrap; }
.appbar .user form { display: inline; }
.appbar .user button { background: none; border: 0; color: rgba(255,255,255,.65);
                       cursor: pointer; font: inherit; padding: 0; }
.appbar .user button:hover { color: #fff; }

/* ================= Control bar ================= */
.control-bar { background: var(--sheet); border-bottom: 1px solid var(--line);
               display: flex; align-items: center; gap: 1rem; padding: .55rem 1.2rem;
               position: sticky; top: 46px; z-index: 40; min-height: 50px; }
.control-bar .bc { font-size: .95rem; font-weight: 600; }
.control-bar .bc a { color: var(--muted); font-weight: 500; }
.control-bar .bc .sep { color: var(--line-dark); margin: 0 .35rem; }
.control-bar .cb-actions { display: flex; gap: .5rem; align-items: center; }
.control-bar .cb-right { margin-left: auto; display: flex; gap: .8rem; align-items: center;
                         font-size: .82rem; color: var(--muted); }
.view-switch { display: flex; border: 1px solid var(--line-dark); border-radius: 6px; overflow: hidden; }
.view-switch a { padding: .3rem .65rem; color: var(--muted); font-size: .85rem; }
.view-switch a:hover { text-decoration: none; background: var(--gray-soft); }
.view-switch a.active { background: var(--accent); color: #fff; }

.page { padding: 1rem 1.2rem 3rem; }

/* ================= Buttons ================= */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .42rem .9rem;
       border-radius: 6px; border: 1px solid var(--line-dark); background: var(--sheet);
       color: var(--ink); font: inherit; font-weight: 500; font-size: .87rem; cursor: pointer;
       white-space: nowrap; }
.btn:hover { background: var(--gray-soft); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.small { padding: .22rem .6rem; font-size: .8rem; }

/* ================= Record: sheet + chatter ================= */
.record-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.1rem;
               align-items: start; max-width: 1420px; }
@media (max-width: 1100px) { .record-wrap { grid-template-columns: 1fr; } }
.sheet { background: var(--sheet); border: 1px solid var(--line); border-radius: 4px;
         box-shadow: var(--shadow); padding: 1.5rem 2rem 1.2rem; }
.sheet-top { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-start;
             margin-bottom: 1.2rem; }
.sheet-top .kind-tag { font-size: .72rem; font-weight: 700; text-transform: uppercase;
                       letter-spacing: .07em; color: var(--muted); }
.sheet-top h1 { margin: .1rem 0 .3rem; font-size: 1.55rem; font-weight: 650; }
.sheet-top .sub { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* Smart buttons (related-record counters) */
.sbtns { display: flex; border: 1px solid var(--line-dark); border-radius: 6px;
         overflow: hidden; flex-shrink: 0; }
.sbtn { display: flex; flex-direction: column; align-items: flex-start; padding: .45rem .95rem;
        border-right: 1px solid var(--line); min-width: 86px; color: var(--ink); cursor: pointer; }
.sbtn:last-child { border-right: 0; }
.sbtn:hover { background: var(--accent-soft); text-decoration: none; }
.sbtn b { font-size: 1.02rem; font-weight: 700; line-height: 1.2; }
.sbtn span { font-size: .72rem; color: var(--muted); }

/* Field grid */
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .1rem 2.5rem;
         margin-bottom: .4rem; }
@media (max-width: 720px) { .fgrid { grid-template-columns: 1fr; } }
.frow { display: grid; grid-template-columns: 138px minmax(0, 1fr); align-items: baseline;
        padding: .32rem 0; border-bottom: 1px solid #f2f2f6; font-size: .9rem; }
.flabel { color: var(--muted); font-size: .84rem; }
.fval { font-weight: 500; word-break: break-word; }
.fval code { background: var(--gray-soft); padding: .05rem .4rem; border-radius: 4px;
             font-size: .84rem; font-weight: 400; }
.fval.empty-val { color: var(--line-dark); font-weight: 400; }

/* Notebook tabs (inside sheet) */
.nb-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line-dark); margin-top: 1.1rem;
           flex-wrap: wrap; }
.nb-tabs a { padding: .5rem 1.1rem; font-weight: 600; font-size: .87rem; color: var(--muted);
             border-bottom: 3px solid transparent; margin-bottom: -1px; display: flex;
             align-items: center; gap: .45rem; }
.nb-tabs a:hover { color: var(--ink); text-decoration: none; }
.nb-tabs a.active { color: var(--accent); border-color: var(--accent); }
.chip { background: var(--gray-soft); color: var(--gray); border-radius: 99px; font-size: .7rem;
        font-weight: 700; padding: .02rem .48rem; }
.nb-tabs a.active .chip { background: var(--accent-soft); color: var(--accent); }
.tabpane { display: none; padding-top: 1rem; }
.tabpane.active { display: block; }
.tabpane .toolbar { margin-bottom: .7rem; }

/* Chatter */
.chatter { display: flex; flex-direction: column; gap: 1rem; }
.chatter .composer { background: var(--sheet); border: 1px solid var(--line); border-radius: 4px;
                     box-shadow: var(--shadow); padding: .9rem 1rem; }
.chatter .composer h4 { margin: 0 0 .5rem; font-size: .82rem; text-transform: uppercase;
                        letter-spacing: .05em; color: var(--muted); }
.chatter textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px;
                    padding: .5rem .7rem; font: inherit; font-size: .88rem; resize: vertical; }
.chatter .c-actions { display: flex; gap: .5rem; margin-top: .55rem; align-items: center; }
.chatter .c-actions input[type=file] { font-size: .78rem; width: auto; }
.msg { display: flex; gap: .7rem; padding: .7rem 1rem; background: var(--sheet);
       border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); }
.msg .body { min-width: 0; flex: 1; }
.msg .meta { font-size: .78rem; color: var(--muted); margin-bottom: .1rem; }
.msg .meta b { color: var(--ink); }
.side-card { background: var(--sheet); border: 1px solid var(--line); border-radius: 4px;
             box-shadow: var(--shadow); padding: .9rem 1rem; }
.side-card h4 { margin: 0 0 .5rem; font-size: .82rem; text-transform: uppercase;
                letter-spacing: .05em; color: var(--muted); }
.side-card .rows .row { display: flex; gap: .5rem; padding: .3rem 0; font-size: .87rem;
                        border-bottom: 1px solid #f2f2f6; align-items: center; }
.side-card .rows .row:last-child { border-bottom: 0; }
.side-card .rows .grow { flex: 1; min-width: 0; }

/* Avatars */
.av { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: .68rem;
      font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
      flex-shrink: 0; text-transform: uppercase; }

/* ================= List views ================= */
.list-wrap { background: var(--sheet); border: 1px solid var(--line); border-radius: 4px;
             box-shadow: var(--shadow); overflow: hidden; }
table.o-list { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.o-list th { text-align: left; padding: .5rem .8rem; font-size: .72rem; color: var(--muted);
                  text-transform: uppercase; letter-spacing: .05em; background: #fafafc;
                  border-bottom: 1px solid var(--line-dark); white-space: nowrap; }
table.o-list td { padding: .48rem .8rem; border-bottom: 1px solid #f0f0f5; }
table.o-list tbody tr { cursor: pointer; }
table.o-list tbody tr:hover { background: var(--accent-soft); }
table.o-list .cbx { width: 30px; text-align: center; }
table.o-list input[type=checkbox] { accent-color: var(--accent); }
td .rowact { visibility: hidden; font-size: .8rem; }
tr:hover .rowact { visibility: visible; }

/* Filter toolbar */
.toolbar { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.toolbar .label { font-size: .75rem; color: var(--muted); font-weight: 600;
                  text-transform: uppercase; letter-spacing: .05em; }
a.fpill { display: inline-block; padding: .24rem .8rem; border-radius: 99px; font-size: .8rem;
          font-weight: 550; color: var(--muted); background: var(--sheet);
          border: 1px solid var(--line-dark); }
a.fpill:hover { text-decoration: none; color: var(--ink); background: var(--gray-soft); }
a.fpill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page > .toolbar { margin-bottom: .8rem; }

/* ================= Kanban ================= */
.kb { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(255px, 1fr);
      gap: .9rem; overflow-x: auto; align-items: start; padding-bottom: .5rem; }
.kb-col { background: #e9e7ee; border-radius: 8px; padding: .6rem .6rem .3rem; }
.kb-col h4 { margin: 0 .3rem .6rem; font-size: .75rem; text-transform: uppercase;
             letter-spacing: .06em; color: var(--gray); display: flex; justify-content: space-between; }
.kb-card { background: var(--sheet); border-radius: 6px; padding: .6rem .8rem; margin-bottom: .55rem;
           box-shadow: var(--shadow); border-left: 3px solid var(--gray); display: block;
           color: var(--ink); font-size: .87rem; }
.kb-card:hover { text-decoration: none; box-shadow: 0 3px 10px rgba(31,37,50,.14); }
.kb-card b { display: block; margin-bottom: .15rem; }
.kb-card .muted { font-size: .78rem; }
.kb-card.active, .kb-card.live, .kb-card.online { border-left-color: var(--green); }
.kb-card.planning, .kb-card.commissioning, .kb-card.on_hold { border-left-color: var(--amber); }
.kb-card.done, .kb-card.dormant { border-left-color: var(--gray); }
.kb-card.offline { border-left-color: var(--red); }
.kb-card.bench, .kb-card.planned { border-left-color: var(--purple); }

/* ================= Pills ================= */
.pill { display: inline-block; padding: .1rem .6rem; border-radius: 99px; font-size: .74rem;
        font-weight: 600; text-transform: capitalize; background: var(--gray-soft);
        color: var(--gray); white-space: nowrap; }
.pill.live, .pill.active, .pill.online { background: var(--green-soft); color: var(--green); }
.pill.commissioning, .pill.planning, .pill.prospect, .pill.on_hold { background: var(--amber-soft); color: var(--amber); }
.pill.offline { background: var(--red-soft); color: var(--red); }
.pill.bench, .pill.planned { background: var(--purple-soft); color: var(--purple); }
.pill.done, .pill.dormant, .pill.retired, .pill.decommissioned { background: var(--gray-soft); color: var(--gray); }
.pill.restricted { background: var(--red-soft); color: var(--red); }

/* ================= KPI tiles ================= */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem;
        margin-bottom: 1.1rem; }
.kpi { background: var(--sheet); border: 1px solid var(--line); border-radius: 4px;
       box-shadow: var(--shadow); padding: .8rem 1rem; display: flex; gap: .8rem;
       align-items: center; }
.kpi .ic { width: 40px; height: 40px; border-radius: 8px; background: var(--accent-soft);
           display: flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.kpi b { font-size: 1.35rem; display: block; line-height: 1.15; }
.kpi span { font-size: .78rem; color: var(--muted); }
.kpi a { color: inherit; }
.kpi a:hover { text-decoration: none; }

/* ================= Markdown (notes tab / knowledge) ================= */
.md { line-height: 1.6; font-size: .92rem; }
.md :first-child { margin-top: 0; } .md :last-child { margin-bottom: 0; }
.md h1, .md h2 { font-size: 1.1rem; border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.md h3 { font-size: .98rem; }
.md pre { background: #262433; color: #e8e6f0; padding: .8rem 1rem; border-radius: 6px;
          overflow-x: auto; font-size: .82rem; }
.md code { background: var(--gray-soft); padding: .07rem .35rem; border-radius: 4px; font-size: .86em; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; font-size: .87rem; }
.md th, .md td { border: 1px solid var(--line); padding: .3rem .6rem; }
.md blockquote { border-left: 3px solid var(--accent); margin: .6rem 0; padding: .1rem .9rem;
                 color: var(--muted); }
a.wikilink { background: var(--accent-soft); padding: .03rem .3rem; border-radius: 4px;
             font-weight: 550; }
a.wikilink:hover { text-decoration: none; filter: brightness(.95); }
a.wikilink-missing { background: var(--red-soft); color: var(--red); }

/* ================= Files ================= */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; }
.file-card { background: var(--sheet); border: 1px solid var(--line); border-radius: 6px;
             overflow: hidden; display: block; }
.file-card img { width: 100%; height: 110px; object-fit: cover; display: block; }
.file-card .ficon { height: 110px; display: flex; align-items: center; justify-content: center;
                    font-size: 1.9rem; background: var(--gray-soft); }
.file-card .fmeta { padding: .45rem .65rem; font-size: .76rem; }

/* ================= Forms ================= */
form.stack label { display: block; font-weight: 600; font-size: .83rem; margin: .85rem 0 .25rem; }
form.stack label:first-child { margin-top: 0; }
input[type=text], input[type=password], input[type=url], input[type=email], input[type=search],
input[type=file], select, textarea {
  width: 100%; padding: .45rem .65rem; border: 1px solid var(--line-dark); border-radius: 6px;
  font: inherit; font-size: .9rem; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft);
                                            border-color: var(--accent); }
textarea { font-family: ui-monospace, "Cascadia Code", Menlo, monospace; font-size: .85rem; }
.errors { color: var(--red); font-size: .85rem; }
.helptext { color: var(--muted); font-size: .77rem; display: block; margin-top: .15rem; }

/* ================= Login ================= */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
              background: linear-gradient(140deg, var(--brand-dark) 0%, var(--brand) 55%, #8d6180 100%); }
.login-box { background: var(--sheet); border-radius: 10px; padding: 2rem 2.2rem; width: 380px;
             box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-box h1 { margin: 0 0 .1rem; }

.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: .87rem; padding: .4rem 0; }
.mt { margin-top: .9rem; }
