:root {
  color-scheme: light;
  --bg: #f3f6f6; --surface: #ffffff; --surface-2: #eaf0ef; --text: #162220;
  --muted: #64726f; --line: #d8e1df; --primary: #0d766e; --primary-strong: #075d57;
  --primary-soft: #d9efec; --accent: #d98b32; --danger: #b83b4b; --danger-soft: #f9e1e5;
  --success: #267a50; --warning: #a76519; --shadow: 0 16px 44px rgba(27,52,48,.1);
  --radius: 18px; --sidebar: 264px; --sidebar-small: 82px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1114; --surface: #121b1e; --surface-2: #1a272a; --text: #edf5f3;
  --muted: #9aaba8; --line: #2a393c; --primary: #47c5b8; --primary-strong: #69dace;
  --primary-soft: #173b39; --accent: #f0a952; --danger: #f07d8d; --danger-soft: #3c2229;
  --success: #63cf96; --warning: #f0b465; --shadow: 0 16px 44px rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-width: 320px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.boot { min-height: 100vh; display: grid; place-content: center; gap: 1rem; text-align: center; color: var(--muted); }
.boot i { color: var(--primary); font-size: 3rem; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar); padding: 1rem; display: flex; flex-direction: column; background: #0d302e; color: #e9fbf8; transition: width .2s, transform .2s; }
.brand { display: flex; align-items: center; gap: .8rem; padding: .5rem .55rem 1.25rem; color: inherit; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 14px; background: #49c1b5; color: #082d2a; font-size: 1.2rem; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.brand-copy { min-width: 0; }
.brand-copy strong, .brand-copy small { display: block; white-space: nowrap; }
.brand-copy small { margin-top: .1rem; color: #a9d4cf; font-size: .73rem; }
.nav { display: grid; gap: .3rem; overflow-y: auto; padding-right: .15rem; }
.nav a { position: relative; display: flex; align-items: center; gap: .85rem; min-height: 44px; padding: .7rem .8rem; border-radius: 12px; color: #c6e0dc; text-decoration: none; }
.nav a i { width: 22px; flex: none; text-align: center; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.11); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: 0; height: 20px; width: 3px; border-radius: 3px; background: #59d6c9; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: .8rem; }
.user-chip { display: flex; gap: .7rem; align-items: center; padding: .55rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.avatar-fallback { display: grid; place-items: center; color: var(--primary); }
.user-copy { overflow: hidden; }
.user-copy strong, .user-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-copy small { color: #a9d4cf; font-size: .75rem; }
.version-link { display: block; padding: .4rem .55rem; color: #a9d4cf; font-size: .74rem; text-decoration: none; }
.sidebar-collapse { width: 100%; margin-top: .4rem; border: 0; background: transparent; color: #c6e0dc; min-height: 38px; border-radius: 10px; cursor: pointer; }
.sidebar-collapse:hover { background: rgba(255,255,255,.1); }
.main { min-height: 100vh; margin-left: var(--sidebar); transition: margin-left .2s; }
.topbar { position: sticky; top: 0; z-index: 30; min-height: 70px; display: flex; align-items: center; gap: .8rem; padding: .75rem clamp(1rem,3vw,2.2rem); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent); }
.topbar h1 { margin: 0; font-size: clamp(1.15rem,2vw,1.45rem); }
.topbar-actions { margin-left: auto; display: flex; gap: .45rem; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; }
.mobile-menu { display: none; }
.update-notice { position: sticky; top: 70px; z-index: 29; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: .85rem; margin: 0; padding: .8rem clamp(1rem,3vw,2.2rem); border-bottom: 1px solid color-mix(in srgb,var(--accent) 55%,var(--line)); background: color-mix(in srgb,var(--accent) 16%,var(--surface)); box-shadow: 0 8px 22px rgba(0,0,0,.08); }
.update-notice-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--accent); color: #251405; }
.update-notice strong, .update-notice span { display: block; }
.update-notice div > span { margin-top: .15rem; color: var(--muted); font-size: .82rem; }
.update-app i.fa-spinner { animation: spin .7s linear infinite; }
.content { width: min(1500px,100%); margin: 0 auto; padding: clamp(1rem,3vw,2.2rem); }
.page-head { display: flex; gap: 1rem; align-items: end; justify-content: space-between; margin-bottom: 1.35rem; }
.page-head h2 { margin: 0 0 .25rem; font-size: clamp(1.55rem,3vw,2.1rem); letter-spacing: -.03em; }
.page-head p { margin: 0; color: var(--muted); }
.btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; border: 1px solid var(--line); border-radius: 12px; padding: .62rem .95rem; background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer; font-weight: 650; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(0,0,0,.08); }
.btn-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #072724; }
.btn-danger { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.btn-sm { min-height: 34px; padding: .38rem .65rem; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.cards { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.card, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric { padding: 1.2rem; overflow: hidden; position: relative; }
.metric::after { content: ""; position: absolute; width: 90px; height: 90px; border-radius: 50%; right: -35px; top: -35px; background: var(--primary-soft); }
.metric-label { color: var(--muted); font-size: .82rem; font-weight: 650; }
.metric-value { display: block; margin-top: .42rem; font-size: clamp(1.35rem,2.7vw,2rem); letter-spacing: -.04em; }
.metric-note { display: block; color: var(--muted); font-size: .75rem; margin-top: .35rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(300px,.8fr); gap: 1rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.05rem 1.15rem; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 1rem; }
.panel-body { padding: 1rem 1.15rem; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .82rem .9rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
td.wrap { white-space: normal; min-width: 220px; max-width: 420px; }
td.actions, th.actions { position: sticky; right: 0; z-index: 2; background: var(--surface); box-shadow: -8px 0 14px -13px #000; }
th.actions { background: var(--surface-2); }
tbody tr:hover td { background: color-mix(in srgb,var(--primary-soft) 28%,var(--surface)); }
.truncate { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.badge { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; padding: .28rem .55rem; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.success { color: var(--success); background: color-mix(in srgb,var(--success) 13%,var(--surface)); }
.badge.warning { color: var(--warning); background: color-mix(in srgb,var(--warning) 14%,var(--surface)); }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.money { font-variant-numeric: tabular-nums; text-align: right; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty i { display: block; margin-bottom: .8rem; font-size: 2rem; color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(12,minmax(0,1fr)); gap: .85rem 1rem; }
.field { grid-column: span 6; min-width: 0; }
.field.full { grid-column: 1/-1; }
.field.third { grid-column: span 4; }
.field.quarter { grid-column: span 3; }
.field label { display: block; margin-bottom: .35rem; font-size: .82rem; font-weight: 700; }
.field-help { display: block; margin-top: .32rem; color: var(--muted); font-size: .74rem; line-height: 1.35; }
input, select, textarea, .ts-control { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--text); padding: .68rem .75rem; min-height: 42px; }
textarea { min-height: 100px; resize: vertical; }
.ts-wrapper { color: var(--text); }
.ts-wrapper .ts-control,
.ts-wrapper.full .ts-control,
.ts-wrapper.single.input-active .ts-control { border-color: var(--line); background: var(--surface); color: var(--text); box-shadow: none; }
.ts-wrapper.focus .ts-control { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb,var(--primary) 20%,transparent); }
.ts-wrapper .ts-control > input { color: var(--text)!important; caret-color: var(--primary); }
.ts-wrapper .ts-control > input::placeholder { color: var(--muted); opacity: 1; }
.ts-wrapper.single .ts-control > .item { color: var(--text); }
.ts-wrapper.multi .ts-control > div { border: 1px solid color-mix(in srgb,var(--primary) 35%,var(--line)); background: var(--primary-soft); color: var(--text); }
.ts-wrapper.multi .ts-control > div.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.ts-wrapper.plugin-remove_button:not(.rtl) .item .remove { border-left-color: color-mix(in srgb,var(--primary) 35%,var(--line)); }
.ts-wrapper.disabled .ts-control,
.ts-wrapper.disabled .ts-control * { background: var(--surface-2); color: var(--muted); }
.ts-dropdown { z-index: 10000; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.ts-dropdown .ts-dropdown-content { background: var(--surface); color: var(--text); }
.ts-dropdown .option { color: var(--text); }
.ts-dropdown .active,
.ts-dropdown .option:hover { background: var(--primary-soft); color: var(--text); }
.ts-dropdown .selected { color: var(--primary-strong); font-weight: 700; }
.ts-dropdown .create,
.ts-dropdown .no-results { color: var(--muted); }
.ts-dropdown .optgroup-header { border-color: var(--line); background: var(--surface-2); color: var(--muted); }
.ts-dropdown [data-selectable] .highlight { border-radius: 3px; background: color-mix(in srgb,var(--accent) 30%,transparent); color: var(--text); }
:root[data-theme="dark"] .ts-wrapper.multi .ts-control > div.active { color: #072724; }
:root[data-theme="dark"] .ts-dropdown .selected { color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; }
dialog { width: min(720px,calc(100% - 2rem)); max-height: min(90vh,850px); overflow: auto; border: 1px solid var(--line); border-radius: 20px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 28px 90px rgba(0,0,0,.34); }
dialog::backdrop { background: rgba(3,16,15,.58); backdrop-filter: blur(4px); }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.dialog-head h3 { margin: 0; }
.dialog-body { padding: 1.2rem; }
.close-dialog { border: 0; background: transparent; color: var(--muted); font-size: 1.15rem; cursor: pointer; }
.detail-hero { padding: 1.25rem; margin-bottom: 1rem; display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.detail-hero h2 { margin: .2rem 0 .4rem; }
.detail-meta { color: var(--muted); font-size: .85rem; }
.timeline { display: grid; gap: .8rem; }
.comment { display: flex; gap: .75rem; }
.comment-body { flex: 1; padding: .8rem 1rem; border-radius: 14px; background: var(--surface-2); }
.comment-body header { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .35rem; font-size: .8rem; }
.comment-body p { white-space: pre-wrap; margin: 0; line-height: 1.5; }
.task-list { display: grid; gap: .65rem; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: start; padding: .85rem; border: 1px solid var(--line); border-radius: 14px; }
.task.blocked { opacity: .6; }
.task.completed { background: color-mix(in srgb,var(--success) 7%,var(--surface)); }
.sequence-line { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: .74rem; font-weight: 800; }
.documents { display: grid; grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap: .7rem; }
.document { padding: .8rem; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.document i { color: var(--primary); margin-right: .4rem; }
.uploader { border: 1px dashed var(--primary); border-radius: 15px; padding: 1rem; background: color-mix(in srgb,var(--primary-soft) 45%,var(--surface)); }
.uploader-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.previews { display: grid; grid-template-columns: repeat(auto-fill,minmax(120px,1fr)); gap: .65rem; margin-top: .8rem; }
.preview { position: relative; min-height: 100px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.preview img { width: 100%; height: 100px; object-fit: cover; }
.preview span { display: block; padding: .35rem; font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview button { position: absolute; top: .3rem; right: .3rem; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0,0,0,.68); color: #fff; cursor: pointer; }
.camera-stage { display: none; margin-top: .8rem; }
.camera-stage.active { display: block; }
.camera-stage video { width: 100%; max-height: 320px; border-radius: 12px; background: #000; }
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0,1.15fr) minmax(400px,.85fr); }
.login-art { padding: clamp(2rem,7vw,7rem); display: flex; flex-direction: column; justify-content: center; color: #effcf9; background: radial-gradient(circle at 75% 20%,rgba(103,219,205,.32),transparent 30%), linear-gradient(145deg,#073d39,#0e6861 64%,#0a4b47); }
.login-art .brand-mark { width: 58px; height: 58px; margin-bottom: 2rem; font-size: 1.5rem; }
.login-art h1 { margin: 0; max-width: 800px; font-size: clamp(2.7rem,6vw,5.6rem); line-height: .97; letter-spacing: -.06em; }
.login-art p { max-width: 590px; color: #c7e9e4; font-size: clamp(1rem,2vw,1.25rem); line-height: 1.6; }
.login-panel { display: grid; place-content: center; padding: 2rem; background: var(--surface); }
.login-card { width: min(390px,100%); }
.login-card h2 { margin: 0 0 .5rem; font-size: 1.8rem; }
.login-card p { color: var(--muted); line-height: 1.5; }
.login-card .btn { width: 100%; margin-top: 1.2rem; }
.login-card small { display: block; margin-top: 1.2rem; color: var(--muted); line-height: 1.5; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 10000; display: grid; gap: .6rem; width: min(380px,calc(100% - 2rem)); }
.toast { padding: .85rem 1rem; border-radius: 13px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { border-color: var(--danger); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.loading { min-height: 260px; display: grid; place-content: center; color: var(--muted); }
.spinner { width: 30px; height: 30px; margin: auto auto .7rem; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.sidebar-small .sidebar { width: var(--sidebar-small); }
body.sidebar-small .main { margin-left: var(--sidebar-small); }
body.sidebar-small .brand-copy, body.sidebar-small .nav span, body.sidebar-small .user-copy, body.sidebar-small .version-link span { display: none; }
body.sidebar-small .nav a { justify-content: center; }
body.sidebar-small .user-chip { justify-content: center; }
@media (max-width: 1050px) { .cards { grid-template-columns: repeat(2,1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .sidebar { width: min(86vw,300px); transform: translateX(-105%); box-shadow: 16px 0 50px rgba(0,0,0,.3); }
  body.mobile-nav-open .sidebar { transform: translateX(0); }
  body.sidebar-small .sidebar { width: min(86vw,300px); }
  body.sidebar-small .brand-copy, body.sidebar-small .nav span, body.sidebar-small .user-copy, body.sidebar-small .version-link span { display: block; }
  body.sidebar-small .nav a, body.sidebar-small .user-chip { justify-content: initial; }
  .main, body.sidebar-small .main { margin-left: 0; }
  .mobile-menu { display: grid; }
  .sidebar-collapse { display: none; }
  .content { padding: 1rem; }
  .update-notice { position: static; grid-template-columns: auto 1fr; padding: .8rem 1rem; }
  .update-notice .btn { grid-column: 1/-1; width: 100%; }
  .page-head { align-items: start; flex-direction: column; }
  .page-head .btn { width: 100%; }
  .cards { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .metric { padding: .9rem; }
  .field, .field.third, .field.quarter { grid-column: 1/-1; }
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 47vh; padding: 2rem 1.4rem; }
  .login-art h1 { font-size: clamp(2.5rem,13vw,4rem); }
  .login-panel { padding: 2rem 1.4rem; }
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { margin-bottom: .8rem; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
  table.responsive td { display: grid; grid-template-columns: 120px 1fr; white-space: normal; border-bottom: 1px solid var(--line); }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
  table.responsive td.actions { position: static; display: flex; background: var(--surface); }
  .detail-hero { flex-direction: column; }
}
@media (max-width: 440px) { .cards { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto!important; animation-duration: .01ms!important; transition-duration: .01ms!important; } }
