/* PAC E-Cabinet. Inter (css/fonts.css, the PAC ERP standard), data-first,
   compact, works from 360 px phones up. One accent: cabinet green; gold for
   the cabinet itself; status always carries a word, never colour alone. */
:root {
  --ink: #17211f; --muted: #5f6b69; --line: #e2e7e6; --line-2: #eef2f1; --bg: #f4f6f5; --card: #fff;
  --brand: #123c3a; --brand-2: #1c5754; --accent: #1f7a6d; --accent-pale: #e5f3f0; --gold: #e9c46a;
  --bad: #c0392b; --bad-pale: #fdecea; --warn: #b26a00; --warn-pale: #fff3dc; --soon: #2f5fb3; --soon-pale: #e8effb;
  --radius: 10px; --side-w: 280px; --top-h: 52px;
  --shadow: 0 1px 2px rgba(18, 40, 38, .06), 0 4px 14px rgba(18, 40, 38, .06);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: 'cv11', 'ss01'; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
table, .num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { flex: none; vertical-align: -3px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid #cfd8d6;
  background: #fff; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover:not(:disabled) { background: #f2f6f5; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: #17665b; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #19695e; }
.btn-danger { background: var(--bad); border-color: #a5301f; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a5301f; }
.btn-block { width: 100%; justify-content: center; height: 40px; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 13px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: inherit; }
.icon-btn:hover { background: rgba(0, 0, 0, .06); }
input, select, textarea { width: 100%; height: 34px; padding: 0 10px; border: 1px solid #cfd8d6; border-radius: 8px; background: #fff; }
textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid rgba(31, 122, 109, .35); outline-offset: 1px; border-color: var(--accent); }
.fld { display: grid; gap: 4px; }
.fld > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.span2 { grid-column: span 2; }
.alert { padding: 8px 10px; border-radius: 8px; background: var(--bad-pale); color: var(--bad); font-size: 13px; margin: 0; }

/* ----------------------------------------------------------------- splash */
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: linear-gradient(160deg, #123c3a, #0b2725); padding: 16px; }
.splash-in { text-align: center; color: #d9e7e5; }
.spinner { width: 26px; height: 26px; margin: 16px auto 10px; border: 3px solid rgba(255, 255, 255, .25); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 14px; padding: 26px 22px; display: grid; gap: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.login-card h1 { font-size: 20px; }
.login-card p { margin: 0; }

/* ----------------------------------------------------------------- layout */
#app { height: 100%; display: flex; flex-direction: column; }
.top { height: var(--top-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--brand); color: #fff; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 14.5px; letter-spacing: .01em; white-space: nowrap; }
/* Opened inside the POLCAS ERP: the ERP's own tab already says what this is. */
html.embedded .brand { display: none; }
html.embedded .top { padding-left: 8px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border-radius: 8px; color: #cfe2df; text-decoration: none; border: 0; background: none; cursor: pointer; white-space: nowrap; font-weight: 550; }
.tab:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.tab.active { background: rgba(255, 255, 255, .14); color: #fff; }
.tab .count { background: var(--gold); color: #3b2a00; border-radius: 999px; font-size: 11px; padding: 0 6px; font-weight: 700; }
.who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #cfe2df; white-space: nowrap; }
.who .role { background: rgba(233, 196, 106, .18); color: var(--gold); border-radius: 999px; padding: 1px 8px; font-weight: 600; text-transform: capitalize; }
.body { flex: 1; display: flex; min-height: 0; }
.side { width: var(--side-w); flex: none; background: #fff; border-right: 1px solid var(--line); overflow: auto; padding: 12px 10px 24px; }
.main { flex: 1; min-width: 0; overflow: auto; padding: 14px 18px 40px; }
.only-phone { display: none; }

/* ------------------------------------------------------------------ logos */
.co-logo { display: inline-grid; place-items: center; flex: none; border-radius: 8px; background: var(--brand); color: var(--gold);
  font-weight: 700; letter-spacing: .02em; overflow: hidden; }
.co-logo.has-img { background: #fff; border: 1px solid var(--line); }
.co-logo img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.co-card { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fafcfb; }
.co-card b { display: block; font-size: 13.5px; line-height: 1.25; }
.co-line { display: inline-flex; align-items: center; gap: 10px; }
.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.logo-preview { min-width: 56px; min-height: 56px; display: grid; place-items: center; }

/* ------------------------------------------------------------------- tree */
.side-head { display: grid; gap: 8px; margin-bottom: 10px; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: 14px; }
.node { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 7px; cursor: pointer; user-select: none; color: #2b3836; }
.node:hover { background: var(--line-2); }
.node.active { background: var(--accent-pale); color: #0f4f46; font-weight: 600; }
.node.drop { outline: 2px dashed var(--accent); background: var(--accent-pale); }
.node .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .lock { color: var(--warn); }
.node .act { opacity: 0; width: 26px; height: 26px; }
.node:hover .act, .node.active .act { opacity: 1; }
.node .twist { width: 16px; display: grid; place-items: center; color: var(--muted); transition: transform .12s; }
.node .twist.open { transform: rotate(90deg); }
.drawer-node { font-weight: 550; }

/* --------------------------------------------------------------- content */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs button { border: 0; background: none; padding: 2px 4px; border-radius: 6px; cursor: pointer; color: var(--accent); font-weight: 550; }
.crumbs button:hover { background: var(--accent-pale); }
.crumbs .sep { color: #a6b2b0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.page-head h1 { font-size: 19px; flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.bulk { position: sticky; top: -14px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 10px;
  background: #102f2d; color: #fff; border-radius: 10px; box-shadow: var(--shadow); }
.bulk .btn { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .2); }
.bulk .btn:hover:not(:disabled) { background: rgba(255, 255, 255, .18); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 14px; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .ic { color: #a6b2b0; }

table.data { width: 100%; border-collapse: separate; border-spacing: 0; }
table.data th { position: sticky; top: 0; background: #f7f9f8; text-align: left; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: #fafcfb; }
table.data tbody tr.sel td { background: #eef8f6; }
table.data .chk { width: 34px; }
.title-cell b { font-weight: 600; }
.title-cell .sub { font-size: 12px; color: var(--muted); }
.docno { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; color: #355; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; background: var(--line-2); color: #364543; padding: 1px 8px; font-size: 12px; }
.chip.type { background: var(--accent-pale); color: #0f4f46; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 1px 7px; font-size: 12px; background: var(--line-2); color: #364543; white-space: nowrap; }
.badge.bad { background: var(--bad-pale); color: var(--bad); font-weight: 600; }
.badge.warn { background: var(--warn-pale); color: var(--warn); font-weight: 600; }
.badge.soon { background: var(--soon-pale); color: var(--soon); }
.badge.conf { background: var(--warn-pale); color: var(--warn); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pill { border: 1px solid #cfd8d6; background: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; font-weight: 550; }
.pill.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ----------------------------------------------------------------- modals */
.m-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(9, 25, 24, .45); display: grid; place-items: center; padding: 16px; }
.m-box { width: min(560px, 100%); max-height: calc(100% - 20px); display: flex; flex-direction: column; background: #fff; border-radius: 14px; box-shadow: 0 24px 70px rgba(0, 0, 0, .3); }
.m-box.wide { width: min(1040px, 100%); }
.m-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.m-head h2 { flex: 1; font-size: 16px; }
.m-body { padding: 14px 18px 16px; overflow: auto; display: grid; gap: 12px; }
.m-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.pop { position: fixed; z-index: 60; min-width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, .18); padding: 5px; }
.pop-item { display: flex; width: 100%; align-items: center; gap: 8px; padding: 7px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: left; }
.pop-item:hover { background: var(--line-2); }
.pop-item.danger { color: var(--bad); }
#toasts { position: fixed; z-index: 70; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100% - 24px)); }
.toast { background: #10302d; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); transition: opacity .3s; font-weight: 500; }
.toast.err { background: var(--bad); }
.toast.out { opacity: 0; }

/* ------------------------------------------------------- document sheet */
.doc-view { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.preview { min-height: 420px; background: #eef2f1; border-radius: 10px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); }
.preview iframe { width: 100%; height: 70vh; border: 0; background: #fff; }
.preview img { max-width: 100%; max-height: 70vh; display: block; }
.preview .empty { padding: 20px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.versions { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; }
.versions li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.versions li:last-child { border-bottom: 0; }
.versions .grow { flex: 1; min-width: 0; }
.upl-list { display: grid; gap: 8px; }
.upl-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.upl-row .bar { grid-column: span 2; height: 4px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.upl-row .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.upl-row.done .bar i { background: #2e8b57; }
.upl-row.fail .bar i { background: var(--bad); width: 100% !important; }
.dropzone { border: 2px dashed #b9c8c5; border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.dropzone.over { border-color: var(--accent); background: var(--accent-pale); }
.picker { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }

/* ------------------------------------------------------------------ phone */
@media (max-width: 860px) {
  .only-phone { display: inline-grid; color: #fff; }
  .side { position: fixed; z-index: 30; top: var(--top-h); bottom: 0; left: 0; width: min(320px, 88vw); transform: translateX(-102%); transition: transform .18s; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  .side.open { transform: none; }
  .main { padding: 12px 12px 40px; }
  .who .name { display: none; }
  .brand b { display: none; }
  .doc-view { grid-template-columns: 1fr; }
  .preview iframe { height: 55vh; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  /* Tables become cards: a row per document, its fields stacked. */
  table.data.cards thead { display: none; }
  table.data.cards, table.data.cards tbody, table.data.cards tr, table.data.cards td { display: block; width: 100%; }
  table.data.cards tr { position: relative; padding: 10px 10px 10px 40px; border-bottom: 1px solid var(--line-2); }
  table.data.cards td { padding: 1px 0; border: 0; }
  table.data.cards td.chk { position: absolute; left: 10px; top: 12px; width: auto; }
  table.data.cards td[data-k]:empty { display: none; }
  table.data.cards td.hide-phone { display: none; }
  .m-wrap { padding: 0; place-items: end stretch; }
  .m-box, .m-box.wide { width: 100%; max-height: 94%; border-radius: 16px 16px 0 0; }
}
