:root {
  --ink:#0f172a; --mute:#64748b; --line:#e2e8f0; --canvas:#f8fafc; --paper:#fff;
  --brand:#0EA5E9; --brand-dark:#0284C7;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--canvas); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
html.hub-embed, html.hub-embed body { height: 100%; overflow: hidden; }
body.drawer-open, body.drawer-open .main { overflow: hidden; }
.hub-loading { min-height: 100%; display: grid; place-items: center; color: var(--mute); font-weight: 600; }
.view-loader {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  overflow: hidden; z-index: 40; pointer-events: none;
}
.view-loader i {
  display: block; height: 100%; width: 34%;
  background: linear-gradient(90deg, var(--brand), #7dd3fc);
  animation: viewLoaderSlide 1.05s cubic-bezier(.4,0,.2,1) infinite;
}
#app { position: relative; }
@keyframes viewLoaderSlide { 0% { transform: translateX(-120%); } 100% { transform: translateX(380%); } }
@media (prefers-reduced-motion: reduce) {
  .view-loader i { animation: none; width: 100%; opacity: .7; }
}

.shell { display: flex; height: 100%; }
.side { width: 240px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 8px; }
.side h1 { margin: 0 0 4px; font-size: 16px; font-weight: 800; }
.side p { margin: 0 0 12px; font-size: 12px; color: var(--mute); }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 999px; border: 0; background: transparent; cursor: pointer; font-weight: 600; font-size: 13px; color: #334155; text-align: left; }
.nav-item:hover { background: #f1f5f9; }
.nav-item.on { background: #E0F2FE; color: #0369A1; }
.nav-item .nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: #dc2626; color: #fff; font-size: 10px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-item.on .nav-badge { background: var(--brand); color: #fff; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid #f1f5f9; display: flex; align-items: center; gap: 8px; }
.side-user { flex: 1; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { flex: 1; min-width: 0; overflow: auto; padding: 20px 24px 40px; position: relative; }
html.hub-embed .side { display: none; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.bar h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 700; font-size: 13px; cursor: pointer; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; }
.btn-ghost { background: #f1f5f9; color: #334155; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #f1f5f9; font-size: 13px; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--mute); background: #f8fafc; }
th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
th.th-sort:hover, th.th-sort.on { color: #0f172a; }
th.th-sort span { display: inline-flex; align-items: center; gap: 6px; }
th.th-sort i { font-style: normal; font-size: 10px; opacity: .4; }
th.th-sort.on i { opacity: 1; color: var(--brand); }
tr:hover td { background: #fafbfc; }
tr[data-id] { cursor: pointer; }
tbody tr.tb-day-sep,
tbody tr.tb-day-sep:hover { cursor: default; background: #eef2f7 !important; }
tbody tr.tb-day-sep td { padding: 9px 16px; border-top: 1px solid #dbe3ef; border-bottom: 1px solid #dbe3ef; }
tbody tr.tb-day-sep:hover td { background: #eef2f7 !important; }
.tb-day-sep-inner { display: flex; align-items: center; gap: 8px; font-size: 10px; font-weight: 700; color: #334155; letter-spacing: .01em; }
.tb-day-sep-inner .svg-ico { width: 14px; height: 14px; flex-shrink: 0; }
.list-rows .tb-day-sep { padding: 9px 12px; background: #eef2f7; border-top: 1px solid #dbe3ef; border-bottom: 1px solid #dbe3ef; margin: 0 -4px; }
.cell-sub { font-size: 12px; color: var(--mute); margin-top: 2px; }
.empty { padding: 40px; text-align: center; color: var(--mute); }
.em-icon { font-size: 28px; color: #94a3b8; margin-bottom: 8px; }
.em-icon .svg-ico { width: 28px; height: 28px; }

.badge { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-on, .badge-green { background: #dcfce7; color: #166534; }
.badge-off, .badge-gray { background: #f1f5f9; color: #64748b; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-blue { background: #e0f2fe; color: #0369a1; }
.cat-commercial { background: #dbeafe; color: #1e40af; }
.cat-technique { background: #ede9fe; color: #6d28d9; }
.cat-secretariat { background: #fce7f3; color: #9d174d; }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.chip { border: 1px solid var(--line); background: #fff; color: #334155; border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer; line-height: 1.2; }
.chip.on { background: #E0F2FE; border-color: #7DD3FC; color: #0369A1; }
.chip-search {
  position: relative; display: flex; align-items: center;
  width: 32px; height: 28px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; overflow: hidden; cursor: pointer; flex-shrink: 0;
  transition: width .22s ease, border-color .15s ease;
}
.chip-search.open { width: 240px; cursor: text; }
.chip-search.open:focus-within { border-color: var(--brand); }
.chip-search-ico { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: #94a3b8; pointer-events: none; }
.chip-search-ico svg { width: 14px; height: 14px; display: block; }
.chip-search input {
  width: 100%; border: 0; background: transparent; padding: 6px 12px 6px 30px;
  font-size: 12px; font-weight: 600; color: var(--ink); line-height: 1.2; opacity: 0;
}
.chip-search.open input { opacity: 1; }
.chip-search input:focus { outline: none; }

.drawer {
  position: fixed; inset: 0; z-index: 50;
  display: flex; justify-content: flex-end;
  background: rgba(15,23,42,.28);
  opacity: 0;
}
.drawer.is-in { animation: drawerFadeIn .18s ease forwards; }
.drawer.is-out { animation: drawerFadeOut .16s ease forwards; }
.drawer-panel {
  width: min(460px, 100%);
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 40px rgba(15,23,42,.12);
  display: flex; flex-direction: column;
  min-height: 0;
  transform: translateX(18px);
}
.drawer.is-in .drawer-panel { animation: drawerIn .22s ease forwards; }
.drawer.is-out .drawer-panel { animation: drawerOut .16s ease forwards; }
.drawer-head { flex-shrink: 0; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0 0 4px; font-size: 17px; line-height: 1.3; }
.drawer-head .sub { font-size: 12px; color: var(--mute); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.drawer-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 20px; }
.drawer-foot {
  flex-shrink: 0; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding: 12px 20px; border-top: 1px solid var(--line); background: #fff;
}
@keyframes drawerFadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes drawerFadeOut { from { opacity: 1 } to { opacity: 0 } }
@keyframes drawerIn { from { transform: translateX(24px) } to { transform: none } }
@keyframes drawerOut { from { transform: none } to { transform: translateX(16px) } }
@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer.is-in, .drawer.is-out, .drawer-panel, .drawer.is-in .drawer-panel, .drawer.is-out .drawer-panel {
    animation: none !important; opacity: 1; transform: none;
  }
  .chip-search { transition: none; }
}

.field { width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: #fff; }
.field:focus { outline: none; border-color: var(--brand); }
label.lbl { display: block; font-size: 12px; font-weight: 700; color: var(--mute); margin: 0 0 4px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 16px; font-size: 13px; margin-bottom: 16px; }
.kv dt { color: var(--mute); font-weight: 700; }
.kv dd { margin: 0; }
.block { background: #f8fafc; border: 1px solid #f1f5f9; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.block h4 { margin: 0 0 8px; font-size: 11px; font-weight: 800; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--mute); font-size: 13px; }

.drawer-panel > .tabs { flex-shrink: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 16px; }
.tab { border: 0; background: transparent; padding: 10px 14px; font-weight: 700; font-size: 13px; color: var(--mute); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--brand-dark); border-bottom-color: var(--brand); }

.assignees { display: flex; flex-wrap: wrap; gap: 6px; }
.assignee { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); padding: 3px 10px 3px 4px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.assignee .av {
  width: 20px; height: 20px; border-radius: 50%;
  background: #E0F2FE; color: #0369A1; font-weight: 800; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
}

.sub-progress { height: 6px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.sub-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #059669); }
.sub-hint { font-size: 12px; color: var(--mute); margin: 0 0 10px; }
.sub-list { display: flex; flex-direction: column; gap: 8px; }
.sub-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; }
.sub-row-main { display: flex; gap: 10px; align-items: flex-start; }
.sub-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.sub-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sub-add { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }

.people-q { margin-bottom: 0; }
.people-pick { position: relative; }
.people-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.people-x { border: none; background: transparent; font-size: 16px; line-height: 1; cursor: pointer; color: #64748b; }
.people-sug {
  margin-top: 6px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15,23,42,.1); max-height: 200px; overflow: auto;
}
.people-sug button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; border: none; background: #fff; padding: 8px 12px; text-align: left; cursor: pointer; font: inherit;
}
.people-sug button:hover { background: #E0F2FE; }
.people-sug small { color: #94a3b8; font-size: 11px; }

.cr-sub { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.cr-sub-top { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.create-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { color: #b91c1c; font-size: 13px; margin: 8px 0; }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item { display: flex; gap: 10px; }
.tl-ico { width: 28px; height: 28px; border-radius: 8px; background: #E0F2FE; color: #0369A1; display: grid; place-items: center; flex-shrink: 0; }
.tl-head { font-size: 13px; }
.tl-time, .tl-detail { color: var(--mute); font-weight: 500; }
.tl-comment-body { font-size: 13px; margin-top: 4px; white-space: pre-wrap; }

.task-elapsed {
  display: inline-flex; font-size: 11px; font-weight: 800; color: var(--mute);
  background: #f1f5f9; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.task-elapsed.warn { color: #92400e; background: #fef3c7; }
.task-elapsed.alert { color: #b91c1c; background: #fee2e2; }
.task-elapsed.ok { color: #065f46; background: #d1fae5; }

.svg-ico { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }
.icon-btn {
  background: #f1f5f9; color: var(--mute); border: none; border-radius: 10px;
  width: 36px; height: 36px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #e2e8f0; color: var(--ink); }
.icon-btn.danger { color: #dc2626; }

.spinner {
  width: 28px; height: 28px; margin: 48px auto; display: block;
  border: 3px solid #e2e8f0; border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 24px; box-shadow: 0 12px 40px rgba(15,23,42,.06);
}
.login-card h2 { margin: 0 0 8px; font-size: 20px; }
.login-card p { color: var(--mute); font-size: 13px; margin: 0 0 16px; }
.login-card .err { min-height: 16px; }

.panel-shell { height: 100%; display: flex; flex-direction: column; background: #fff; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid #f1f5f9; }
.panel-head strong { display: block; font-size: 14px; }
.panel-head em { font-style: normal; font-size: 11px; color: var(--mute); font-weight: 600; }
.panel-tabs { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid #f1f5f9; }
.panel-tabs .nav-item { flex: 1; justify-content: center; }
.list-rows { padding: 4px; display: flex; flex-direction: column; }
.list-row {
  appearance: none; border: none; background: transparent; text-align: left;
  width: 100%; padding: 10px 12px; border-radius: 10px; cursor: pointer; font: inherit; color: inherit;
}
.list-row:hover { background: #f8fafc; }
.list-row-title { font-size: 13px; font-weight: 700; }
.list-row-sub { font-size: 11px; color: var(--mute); margin-top: 2px; }
.list-row-top { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
html.panel-mode .main { padding: 10px; }

.dt-comment-form { display: flex; flex-direction: column; gap: 8px; }
.vocal-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.vocal-table td { padding: 6px 4px; }
.vt-lbl { color: var(--mute); font-weight: 700; width: 110px; }
.vt-chat { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.vt-msg { max-width: 92%; }
.vt-agent { align-self: flex-start; }
.vt-caller { align-self: flex-end; }
.vt-who { font-size: 10px; font-weight: 800; color: var(--mute); margin-bottom: 2px; }
.vt-bubble { background: #f1f5f9; border-radius: 12px; padding: 8px 12px; font-size: 13px; }
.vt-agent .vt-bubble { background: #E0F2FE; }
.vt-text { white-space: pre-wrap; font-size: 12px; background: #f8fafc; padding: 10px; border-radius: 10px; overflow: auto; }
.vocal-recording { margin: 10px 0; }
.cell-title { font-weight: 700; }
.sub-acts .btn { padding: 6px 10px; font-size: 12px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #16a34a; display: inline-block; margin-right: 4px; }
.live-dot.offline { background: #dc2626; }
.nav-badge.amber { background: #d97706; }
textarea.field { resize: vertical; min-height: 72px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.detail-desc { font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.tab-num {
  display: inline-flex; min-width: 16px; height: 16px; padding: 0 5px;
  border-radius: 999px; background: #e2e8f0; color: #475569;
  font-size: 10px; font-weight: 800; align-items: center; justify-content: center; vertical-align: middle;
}
.tab.on .tab-num { background: #bae6fd; color: #0369A1; }
.btn-success { background: #dcfce7; color: #166534; }
.create-subs-head { margin: 14px 0 8px; }
.create-subs-head strong { display: block; font-size: 13px; }
.create-subs-head .muted { display: block; margin-top: 2px; font-size: 12px; }
.login-card input { width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; margin: 0 0 10px; }
.login-card input:focus { outline: none; border-color: var(--brand); }
.login-card label { display: block; font-size: 12px; font-weight: 700; color: var(--mute); margin: 0 0 4px; }
.login-card .btn-primary, .login-card .btn-ghost { width: 100%; justify-content: center; }
.login-card .btn-ghost { margin-top: 8px; }
.brand-big {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 16px; margin-bottom: 12px;
}
.tl-ico.open, .tl-ico.create { background: #E0F2FE; color: #0369A1; }
.tl-ico.done { background: #dcfce7; color: #166534; }
.tl-ico.cancel { background: #fee2e2; color: #b91c1c; }
.tl-ico.assign { background: #fef3c7; color: #92400e; }
tr.enter, .list-row.enter { animation: rowIn .8s ease; }
@keyframes rowIn { from { background: #E0F2FE; } to { background: transparent; } }
.drawer-wide .drawer-panel { width: min(520px, 100%); }
