/* ==========================================================================
   TOP CNC — Auth pages and the authenticated panel shell
   Depends on topcnc-base.css tokens and form primitives.
   ========================================================================== */

/* --- Auth card --------------------------------------------------------- */
.topcnc-auth { padding-block: var(--tc-space-12); background: linear-gradient(180deg, #fff, var(--tc-bg-muted)); flex: 1; }
.topcnc-auth__card {
	max-width: 460px; margin-inline: auto;
	background: #fff; border: 1px solid var(--tc-border); border-radius: var(--tc-radius-lg);
	padding: var(--tc-space-8); box-shadow: var(--tc-shadow-lg);
}
.topcnc-auth__card--wide { max-width: 680px; }
.topcnc-auth__title { font-size: var(--tc-fs-xl); margin-bottom: var(--tc-space-2); }
.topcnc-auth__subtitle { color: var(--tc-text-muted); font-size: var(--tc-fs-sm); margin-bottom: var(--tc-space-6); }
.topcnc-auth__hint { margin: var(--tc-space-6) 0 0; text-align: center; font-size: var(--tc-fs-sm); color: var(--tc-text-muted); }
.topcnc-auth__divider { display: flex; align-items: center; gap: var(--tc-space-3); color: var(--tc-text-muted); font-size: var(--tc-fs-xs); margin: var(--tc-space-4) 0; }
.topcnc-auth__divider::before, .topcnc-auth__divider::after { content: ""; flex: 1; height: 1px; background: var(--tc-border); }

.topcnc-pending { text-align: center; display: grid; gap: var(--tc-space-4); justify-items: center; }
.topcnc-pending__icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--tc-accent-100); color: var(--tc-accent-600); }
.topcnc-pending__actions { display: flex; gap: var(--tc-space-3); flex-wrap: wrap; justify-content: center; }

/* --- Panel layout ------------------------------------------------------ */
:root { --tc-sidebar-w: 260px; }
.topcnc-panel-body { background: var(--tc-bg-muted); display: block; }
.topcnc-panel { display: flex; min-height: 100vh; }

.topcnc-sidebar {
	width: var(--tc-sidebar-w); flex: 0 0 auto;
	background: var(--tc-bg-dark); color: var(--tc-text-on-dark);
	display: flex; flex-direction: column; gap: var(--tc-space-6);
	padding: var(--tc-space-6) var(--tc-space-4);
	position: sticky; top: 0; height: 100vh;
}
.topcnc-sidebar__logo { color: #fff; padding-inline: var(--tc-space-2); }
.topcnc-sidebar__logo .topcnc-logo__text span { color: var(--tc-accent); }
.topcnc-sidebar__org { display: grid; gap: 6px; padding: var(--tc-space-3); background: rgba(255,255,255,0.06); border-radius: var(--tc-radius-sm); }
.topcnc-sidebar__org-name { font-weight: 700; font-size: var(--tc-fs-sm); }
.topcnc-sidebar__org .topcnc-badge { justify-self: start; }

.topcnc-sidebar__nav { display: grid; gap: 4px; flex: 1; align-content: start; }
.topcnc-sidebar__link {
	display: flex; align-items: center; gap: var(--tc-space-3);
	padding: 0.6rem var(--tc-space-3); border-radius: var(--tc-radius-sm);
	color: var(--tc-text-on-dark-muted); font-weight: 500; font-size: var(--tc-fs-sm);
}
.topcnc-sidebar__link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.topcnc-sidebar__link.is-active { background: var(--tc-primary); color: #fff; }
.topcnc-sidebar__soon { font-size: var(--tc-fs-xs); color: var(--tc-text-on-dark-muted); padding: var(--tc-space-3); opacity: 0.7; }

.topcnc-sidebar__user { display: flex; align-items: center; justify-content: space-between; gap: var(--tc-space-3); padding-top: var(--tc-space-4); border-top: 1px solid rgba(255,255,255,0.1); font-size: var(--tc-fs-sm); }
.topcnc-sidebar__user strong { display: block; color: #fff; }
.topcnc-sidebar__user small { color: var(--tc-text-on-dark-muted); }
.topcnc-sidebar__logout { color: var(--tc-text-on-dark-muted); display: inline-flex; padding: 6px; border-radius: 6px; }
.topcnc-sidebar__logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

.topcnc-panel__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topcnc-topbar {
	display: flex; align-items: center; gap: var(--tc-space-4);
	background: #fff; border-bottom: 1px solid var(--tc-border);
	padding: 0 var(--tc-space-6); min-height: 64px; position: sticky; top: 0; z-index: 20;
}
.topcnc-topbar__title { font-size: var(--tc-fs-lg); margin: 0; flex: 1; }
.topcnc-topbar__site { font-size: var(--tc-fs-sm); color: var(--tc-text-muted); }
.topcnc-topbar__burger { display: none; width: 40px; height: 40px; flex-direction: column; justify-content: center; align-items: center; gap: 5px; }
.topcnc-topbar__burger span { width: 22px; height: 2px; background: var(--tc-text); border-radius: 2px; }

.topcnc-panel__content { padding: var(--tc-space-6); display: grid; gap: var(--tc-space-6); align-content: start; }

@media (max-width: 900px) {
	.topcnc-sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 50; transform: translateX(100%); transition: transform 0.2s ease; }
	.topcnc-sidebar.is-open { transform: none; }
	.topcnc-topbar__burger { display: inline-flex; }
	.topcnc-panel__content { padding: var(--tc-space-4); }
}

/* --- Panel widgets ----------------------------------------------------- */
.topcnc-panel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--tc-space-4); }
.topcnc-panel-split { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--tc-space-6); align-items: start; }
@media (max-width: 1100px) { .topcnc-panel-grid { grid-template-columns: 1fr 1fr; } .topcnc-panel-split { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .topcnc-panel-grid { grid-template-columns: 1fr; } }

.topcnc-card__title { font-size: var(--tc-fs-lg); margin-bottom: var(--tc-space-4); }
.topcnc-stat { display: grid; gap: 4px; }
.topcnc-stat__label { font-size: var(--tc-fs-sm); color: var(--tc-text-muted); }
.topcnc-stat__value { font-size: var(--tc-fs-2xl); color: var(--tc-primary); line-height: 1.2; }
.topcnc-stat__sub { font-size: var(--tc-fs-sm); color: var(--tc-text-muted); }

.topcnc-next-steps h2 { font-size: var(--tc-fs-lg); }
.topcnc-next-steps ol { padding-inline-start: 1.4rem; display: grid; gap: var(--tc-space-2); }
.topcnc-next-steps li.is-done { color: var(--tc-text-muted); text-decoration: line-through; }

.topcnc-table { width: 100%; border-collapse: collapse; font-size: var(--tc-fs-sm); }
.topcnc-table th, .topcnc-table td { padding: 0.7rem 0.6rem; border-bottom: 1px solid var(--tc-border); text-align: right; vertical-align: middle; }
.topcnc-table thead th { color: var(--tc-text-muted); font-weight: 500; font-size: var(--tc-fs-xs); }
.topcnc-table__ltr { direction: ltr; text-align: left !important; font-size: var(--tc-fs-xs); }
.topcnc-table__actions { white-space: nowrap; }
.topcnc-table .topcnc-badge { margin-inline-start: 6px; }
.topcnc-inline-form { display: inline; }
.topcnc-inline-form select { padding: 0.35rem 0.5rem; border: 1px solid var(--tc-border); border-radius: 6px; background: #fff; font-size: var(--tc-fs-xs); }
.topcnc-table tr.is-muted td { opacity: 0.6; }
.topcnc-empty-state { color: var(--tc-text-muted); margin: 0; line-height: 1.9; }
.topcnc-prewrap { white-space: pre-wrap; margin: 0; }

/* --- Page head, filters, forms ---------------------------------------- */
.topcnc-page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--tc-space-4); flex-wrap: wrap; }
.topcnc-page-head__title { font-size: var(--tc-fs-xl); margin: 0; }
.topcnc-filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: var(--tc-space-3); align-items: end; padding: var(--tc-space-4); }
@media (max-width: 900px) { .topcnc-filters { grid-template-columns: 1fr 1fr; } }
.topcnc-form__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--tc-space-4); }
.topcnc-form__grid .topcnc-field--full { grid-column: 1 / -1; }
@media (max-width: 900px) { .topcnc-form__grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .topcnc-form__grid { grid-template-columns: 1fr; } }
.topcnc-form__actions { display: flex; gap: var(--tc-space-3); align-items: center; flex-wrap: wrap; }
.topcnc-passport-form { gap: var(--tc-space-6); }

/* --- Machine cards ----------------------------------------------------- */
.topcnc-machine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--tc-space-4); }
.topcnc-machine-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; transition: transform 0.15s, box-shadow 0.15s; }
.topcnc-machine-card:hover { transform: translateY(-2px); box-shadow: var(--tc-shadow-lg); color: inherit; }
.topcnc-machine-card.is-muted { opacity: 0.7; }
/* Fixed-height cover: the image is absolutely positioned so its size never depends on the
   intrinsic photo size (a percentage height inside an auto grid row resolves to auto). */
.topcnc-machine-card__thumb { position: relative; height: 170px; flex: 0 0 170px; overflow: hidden; background: var(--tc-bg-muted); display: grid; place-items: center; color: var(--tc-text-muted); border-bottom: 1px solid var(--tc-border); }
.topcnc-machine-card__thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.topcnc-machine-card__thumb svg { width: 40px; height: 40px; }
.topcnc-machine-card__body { position: relative; background: #fff; }
.topcnc-filters > * { min-width: 0; }
.topcnc-machine-card__body { padding: var(--tc-space-4); display: grid; gap: var(--tc-space-2); }
.topcnc-machine-card__head { display: flex; justify-content: space-between; align-items: center; gap: var(--tc-space-2); }
.topcnc-machine-card__sub { font-size: var(--tc-fs-sm); color: var(--tc-text-muted); text-align: right; }
.topcnc-machine-card__meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px var(--tc-space-3); margin: var(--tc-space-2) 0 0; font-size: var(--tc-fs-xs); }
.topcnc-machine-card__meta dt { color: var(--tc-text-muted); }
.topcnc-machine-card__meta dd { margin: 0; font-weight: 500; }

/* --- Machine page ------------------------------------------------------ */
.topcnc-machine-head { display: grid; grid-template-columns: 1fr auto; gap: var(--tc-space-2) var(--tc-space-4); }
.topcnc-machine-head__id { display: flex; align-items: center; gap: var(--tc-space-2); flex-wrap: wrap; }
.topcnc-machine-head__sub { grid-column: 1; margin: 0; color: var(--tc-text-muted); font-size: var(--tc-fs-sm); }
.topcnc-machine-head__actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: var(--tc-space-2); align-items: center; flex-wrap: wrap; }
@media (max-width: 700px) { .topcnc-machine-head { grid-template-columns: 1fr; } .topcnc-machine-head__actions { grid-column: 1; grid-row: auto; } }

.topcnc-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--tc-border); overflow-x: auto; }
.topcnc-tabs__item { display: inline-flex; align-items: center; gap: 6px; padding: 0.6rem 0.9rem; color: var(--tc-text-muted); font-size: var(--tc-fs-sm); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.topcnc-tabs__item:hover { color: var(--tc-primary); }
.topcnc-tabs__item.is-active { color: var(--tc-primary); border-color: var(--tc-accent); }
.topcnc-tabs__item.is-soon { opacity: 0.55; }

.topcnc-passport { display: grid; grid-template-columns: 1fr 1fr; gap: var(--tc-space-4); }
.topcnc-passport > .topcnc-passport__next, .topcnc-passport > .topcnc-card:nth-child(3) { grid-column: 1 / -1; }
@media (max-width: 900px) { .topcnc-passport { grid-template-columns: 1fr; } }
.topcnc-passport__grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--tc-space-3) var(--tc-space-4); margin: 0; }
.topcnc-passport__grid dt { font-size: var(--tc-fs-xs); color: var(--tc-text-muted); }
.topcnc-passport__grid dd { margin: 0; font-weight: 500; }
.topcnc-passport__grid dd[dir="ltr"] { text-align: right; }

.topcnc-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--tc-space-3); }
.topcnc-photo { margin: 0; border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); overflow: hidden; background: #fff; }
.topcnc-photo img { width: 100%; height: 130px; object-fit: cover; }
.topcnc-photo figcaption { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 8px; font-size: var(--tc-fs-xs); }
.topcnc-photo figcaption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topcnc-timeline { list-style: none; display: grid; gap: var(--tc-space-3); }
.topcnc-timeline > li { display: grid; grid-template-columns: 120px 1fr; gap: 4px var(--tc-space-3); padding-bottom: var(--tc-space-3); border-bottom: 1px dashed var(--tc-border); font-size: var(--tc-fs-sm); }
.topcnc-timeline time { color: var(--tc-text-muted); font-size: var(--tc-fs-xs); }
.topcnc-timeline > li > .topcnc-text-muted { grid-column: 2; font-size: var(--tc-fs-xs); }
.topcnc-timeline__diff { grid-column: 2; list-style: none; font-size: var(--tc-fs-xs); color: var(--tc-text-muted); display: grid; gap: 2px; }

/* --- Billing ----------------------------------------------------------- */
.topcnc-banner { display: flex; align-items: center; justify-content: space-between; gap: var(--tc-space-3); flex-wrap: wrap; padding: var(--tc-space-3) var(--tc-space-4); border-radius: var(--tc-radius-sm); font-weight: 500; }
.topcnc-banner--warn { background: var(--tc-warning-100); color: var(--tc-warning); }
.topcnc-banner--danger { background: var(--tc-danger-100); color: var(--tc-danger); }
.topcnc-billing-state { display: flex; justify-content: space-between; align-items: center; gap: var(--tc-space-4); flex-wrap: wrap; border-inline-start: 4px solid var(--tc-success); }
.topcnc-billing-state--grace { border-inline-start-color: var(--tc-warning); }
.topcnc-billing-state--readonly { border-inline-start-color: var(--tc-danger); }
.topcnc-billing-state > div { display: grid; gap: 4px; }
.topcnc-plans--panel { margin-top: var(--tc-space-4); }
.topcnc-plans--panel .topcnc-plan { padding: var(--tc-space-8) var(--tc-space-6) var(--tc-space-6); }
.topcnc-plan--current { border-color: var(--tc-success); }
.topcnc-plan--current .topcnc-plan__ribbon { background: var(--tc-success-100); color: var(--tc-success); }
.topcnc-quote { display: grid; gap: 6px; margin: var(--tc-space-2) 0 var(--tc-space-4); padding: var(--tc-space-3); background: var(--tc-bg-muted); border-radius: var(--tc-radius-sm); font-size: var(--tc-fs-sm); }
.topcnc-quote > div { display: flex; justify-content: space-between; gap: var(--tc-space-2); }
.topcnc-quote dt { color: var(--tc-text-muted); }
.topcnc-quote dd { margin: 0; font-weight: 500; }
.topcnc-quote__total { border-top: 1px dashed var(--tc-border); padding-top: 6px; font-weight: 700; }
.topcnc-quote__total dd { color: var(--tc-primary); font-size: var(--tc-fs-lg); }
.topcnc-quote__dates dd { font-weight: 400; }
.topcnc-plan__gateway { width: 100%; margin-bottom: var(--tc-space-2); padding: 0.5rem; border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); }
.topcnc-billing-note { margin-top: var(--tc-space-4); font-size: var(--tc-fs-sm); }
.topcnc-toggle a.topcnc-toggle__btn { color: var(--tc-text-muted); }
.topcnc-toggle a.topcnc-toggle__btn.is-active { color: #fff; }

/* --- Documents --------------------------------------------------------- */
.topcnc-card--narrow { max-width: 760px; }
.topcnc-panel-stack { display: grid; gap: var(--tc-space-4); align-content: start; }
.topcnc-passport__grid--1 { grid-template-columns: 1fr; }
.topcnc-form__grid--2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .topcnc-form__grid--2 { grid-template-columns: 1fr; } }
.topcnc-check-group--scroll { max-height: 180px; overflow-y: auto; padding: 6px 8px; border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); background: #fff; }
.topcnc-docs-table td { vertical-align: top; }
.topcnc-doc-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.topcnc-doc-title svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--tc-text-muted); }
.topcnc-docs-table small { display: block; font-size: var(--tc-fs-xs); }
.topcnc-doc-status--queued { background: var(--tc-bg-muted); color: var(--tc-text-muted); }
.topcnc-doc-status--processing { background: var(--tc-accent-100); color: var(--tc-accent-600); }
.topcnc-doc-status--ready { background: var(--tc-success-100); color: var(--tc-success); }
.topcnc-doc-status--failed { background: var(--tc-danger-100); color: var(--tc-danger); }
.topcnc-doc-status[data-pending="1"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-inline-end: 6px; display: inline-block; animation: topcnc-pulse 1.2s ease-in-out infinite; }
@keyframes topcnc-pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.topcnc-doc-status__msg { max-width: 260px; white-space: normal; margin-top: 4px; }
.topcnc-docs-note { margin: var(--tc-space-4) 0 0; font-size: var(--tc-fs-xs); }
.topcnc-progress { height: 8px; background: var(--tc-bg-muted); border-radius: 999px; overflow: hidden; }
.topcnc-progress > span { display: block; height: 100%; background: var(--tc-accent); border-radius: 999px; transition: width 0.4s ease; min-width: 4%; }
.topcnc-doc-progress { display: grid; gap: var(--tc-space-2); margin-bottom: var(--tc-space-4); }
.topcnc-doc-pages { display: grid; gap: var(--tc-space-2); }
.topcnc-doc-page { border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); background: #fff; }
.topcnc-doc-page > summary { cursor: pointer; padding: 0.6rem 0.9rem; font-weight: 600; font-size: var(--tc-fs-sm); display: flex; justify-content: space-between; gap: var(--tc-space-2); }
.topcnc-doc-page > summary small { font-weight: 400; }
.topcnc-doc-page__text { margin: 0; padding: 0.75rem 0.9rem; border-top: 1px solid var(--tc-border); white-space: pre-wrap; font-family: var(--tc-font); font-size: var(--tc-fs-sm); line-height: 1.9; max-height: 420px; overflow: auto; background: var(--tc-bg-muted); }
.topcnc-doc-page > p { padding: 0.6rem 0.9rem; margin: 0; }
.topcnc-doc-search__form { display: flex; gap: var(--tc-space-2); }
.topcnc-doc-search__form input[type="search"] { flex: 1; padding: 0.7rem 0.9rem; border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); font: inherit; }
.topcnc-doc-search__hint, .topcnc-doc-search__meta { margin: var(--tc-space-3) 0 0; font-size: var(--tc-fs-xs); }
.topcnc-doc-results { list-style: none; display: grid; gap: var(--tc-space-3); margin-top: var(--tc-space-4); counter-reset: hit; }
.topcnc-doc-result { border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); padding: var(--tc-space-3) var(--tc-space-4); background: #fff; }
.topcnc-doc-result__head { display: flex; align-items: center; gap: var(--tc-space-2); flex-wrap: wrap; font-weight: 600; margin-bottom: 4px; }
.topcnc-doc-result__snippet { margin: 0; font-size: var(--tc-fs-sm); color: var(--tc-text); line-height: 1.9; }
.topcnc-doc-result__snippet mark { background: var(--tc-accent-100); color: inherit; padding: 0 2px; border-radius: 3px; }
.topcnc-knowledge { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--tc-space-3); margin-bottom: var(--tc-space-3); }
.topcnc-knowledge__item { display: grid; justify-items: center; gap: 2px; padding: var(--tc-space-3); border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); background: var(--tc-bg-muted); color: var(--tc-text); }
.topcnc-knowledge__item strong { font-size: var(--tc-fs-xl); color: var(--tc-primary); }
.topcnc-knowledge__item span { font-size: var(--tc-fs-xs); color: var(--tc-text-muted); }
.topcnc-knowledge__item.is-soon { opacity: 0.55; }
a.topcnc-knowledge__item:hover { border-color: var(--tc-accent); background: #fff; }
@media (max-width: 600px) { .topcnc-knowledge { grid-template-columns: 1fr 1fr; } }

/* --- Machine AI -------------------------------------------------------- */
.topcnc-ai { display: grid; grid-template-columns: 280px 1fr; gap: var(--tc-space-4); align-items: start; }
@media (max-width: 900px) { .topcnc-ai { grid-template-columns: 1fr; } }
.topcnc-ai__threads-head { display: flex; justify-content: space-between; align-items: center; gap: var(--tc-space-2); margin-bottom: var(--tc-space-3); }
.topcnc-ai__threads-head .topcnc-card__title { margin: 0; }
.topcnc-ai__list { list-style: none; display: grid; gap: 4px; }
.topcnc-ai__list a { display: grid; gap: 2px; padding: 0.5rem 0.7rem; border-radius: var(--tc-radius-sm); color: var(--tc-text); }
.topcnc-ai__list a:hover { background: var(--tc-bg-muted); }
.topcnc-ai__list li.is-active a { background: var(--tc-primary-100); }
.topcnc-ai__list strong { font-size: var(--tc-fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topcnc-ai__list small { font-size: var(--tc-fs-xs); }
.topcnc-ai__quota { margin: var(--tc-space-4) 0 0; font-size: var(--tc-fs-xs); line-height: 1.8; }
.topcnc-ai__chat { display: grid; gap: var(--tc-space-4); min-height: 60vh; }
.topcnc-ai__chat-head { display: flex; justify-content: space-between; align-items: center; gap: var(--tc-space-2); }
.topcnc-ai__chat-head .topcnc-card__title { margin: 0; }
.topcnc-ai__thread { display: grid; gap: var(--tc-space-4); align-content: start; }
.topcnc-ai__intro { text-align: center; display: grid; justify-items: center; gap: var(--tc-space-2); padding: var(--tc-space-6) var(--tc-space-4); }
.topcnc-ai__intro svg { width: 40px; height: 40px; color: var(--tc-accent); }
.topcnc-ai__intro h4 { margin: 0; }
.topcnc-ai__intro p { max-width: 560px; }
.topcnc-ai__examples { list-style: none; display: grid; gap: 6px; font-size: var(--tc-fs-sm); color: var(--tc-text-muted); }
.topcnc-ai__examples li::before { content: "«"; } .topcnc-ai__examples li::after { content: "»"; }
.topcnc-msg { display: grid; gap: 4px; max-width: 92%; }
.topcnc-msg--user { justify-self: start; }
.topcnc-msg--assistant { justify-self: stretch; max-width: 100%; }
.topcnc-msg__bubble { padding: var(--tc-space-3) var(--tc-space-4); border-radius: var(--tc-radius); line-height: 1.9; }
.topcnc-msg--user .topcnc-msg__bubble { background: var(--tc-primary); color: #fff; border-start-end-radius: 4px; }
.topcnc-msg--user p { margin: 0; }
.topcnc-msg--assistant .topcnc-msg__bubble { background: var(--tc-bg-muted); border: 1px solid var(--tc-border); border-start-start-radius: 4px; }
.topcnc-msg time { font-size: var(--tc-fs-xs); color: var(--tc-text-muted); }
.topcnc-msg__image img { max-width: 240px; max-height: 240px; border-radius: var(--tc-radius-sm); margin-top: 6px; }
.topcnc-msg__body p { margin: 0 0 var(--tc-space-2); } .topcnc-msg__body p:last-child { margin: 0; }
.topcnc-msg__body ul, .topcnc-msg__body ol { padding-inline-start: 1.4rem; margin: 0 0 var(--tc-space-2); display: grid; gap: 4px; }
.topcnc-msg__body h4 { font-size: var(--tc-fs-md); margin: var(--tc-space-2) 0; }
.topcnc-msg__body code { font-family: var(--tc-font-mono); font-size: 0.9em; background: #fff; padding: 0 4px; border-radius: 4px; direction: ltr; unicode-bidi: embed; }
.topcnc-cite { display: inline-block; font-size: var(--tc-fs-xs); background: var(--tc-accent-100); color: var(--tc-accent-600); padding: 0 6px; border-radius: 999px; margin-inline: 2px; vertical-align: middle; white-space: nowrap; }
.topcnc-cite:hover { background: var(--tc-accent); color: #fff; }
.topcnc-msg__sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: var(--tc-space-3); padding-top: var(--tc-space-2); border-top: 1px dashed var(--tc-border); font-size: var(--tc-fs-xs); }
.topcnc-msg__flag { font-size: var(--tc-fs-xs); padding: 4px 10px; border-radius: 6px; margin-bottom: var(--tc-space-2); font-weight: 500; }
.topcnc-msg__flag--ungrounded { background: var(--tc-warning-100); color: var(--tc-warning); }
.topcnc-msg__flag--sensitive { background: var(--tc-danger-100); color: var(--tc-danger); }
.topcnc-msg__meta { display: flex; align-items: center; gap: var(--tc-space-3); }
.topcnc-msg__feedback button { background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; padding: 0 4px; opacity: 0.5; font-size: 14px; }
.topcnc-msg__feedback button:hover, .topcnc-msg__feedback button.is-on { opacity: 1; border-color: var(--tc-border); background: #fff; }
.topcnc-ai__composer { display: grid; gap: var(--tc-space-2); border-top: 1px solid var(--tc-border); padding-top: var(--tc-space-4); }
.topcnc-ai__composer textarea { width: 100%; padding: 0.7rem 0.9rem; border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); font: inherit; resize: vertical; }
.topcnc-ai__composer-bar { display: flex; justify-content: space-between; align-items: center; gap: var(--tc-space-3); flex-wrap: wrap; }
.topcnc-ai__attach { display: inline-flex; align-items: center; gap: 6px; font-size: var(--tc-fs-sm); color: var(--tc-text-muted); cursor: pointer; }
.topcnc-ai__attach input { display: none; }
.topcnc-ai__attach > span:first-of-type { display: inline-flex; align-items: center; gap: 4px; }
.topcnc-ai__attach svg { width: 18px; height: 18px; }
.topcnc-ai__attach-name { font-size: var(--tc-fs-xs); color: var(--tc-primary); }
.topcnc-ai__thinking { margin: 0; font-size: var(--tc-fs-sm); color: var(--tc-accent-600); }
.topcnc-ai__thinking::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--tc-accent); border-top-color: transparent; margin-inline-end: 8px; animation: topcnc-spin 0.8s linear infinite; vertical-align: middle; }
@keyframes topcnc-spin { to { transform: rotate(360deg); } }

/* --- Usage & quota ----------------------------------------------------- */
.topcnc-quota-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--tc-space-4); }
.topcnc-quota { display: grid; gap: 6px; padding: var(--tc-space-4); border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); background: var(--tc-bg-muted); }
.topcnc-quota__value { font-size: var(--tc-fs-xl); color: var(--tc-primary); line-height: 1.3; }
.topcnc-quota__value small { font-size: var(--tc-fs-xs); color: var(--tc-text-muted); font-weight: 400; margin-inline-start: 6px; }
.topcnc-quota .topcnc-progress > span { background: var(--tc-success); }
.topcnc-quota.is-warn .topcnc-progress > span { background: var(--tc-accent); }
.topcnc-quota.is-danger .topcnc-progress > span { background: var(--tc-danger); }
.topcnc-filters--usage { grid-template-columns: 1fr 1fr 1fr 1fr auto; }
.topcnc-panel-grid--2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .topcnc-panel-grid--2 { grid-template-columns: 1fr; } }
.topcnc-pagination-inline { display: flex; gap: var(--tc-space-3); align-items: center; margin: var(--tc-space-3) 0 0; font-size: var(--tc-fs-sm); }

/* --- Maintenance cases ------------------------------------------------- */
.topcnc-panel-grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .topcnc-panel-grid--4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .topcnc-panel-grid--4 { grid-template-columns: 1fr; } }
.topcnc-filters--cases { grid-template-columns: repeat(4, 1fr); }
.topcnc-filters--cases > .topcnc-field:first-child { grid-column: span 2; }
@media (max-width: 900px) { .topcnc-filters--cases { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .topcnc-filters--cases { grid-template-columns: 1fr; } .topcnc-filters--cases > .topcnc-field:first-child { grid-column: auto; } }
.topcnc-form__grid--3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) { .topcnc-form__grid--3 { grid-template-columns: 1fr; } }
.topcnc-case-form .topcnc-card__title { margin-top: var(--tc-space-4); padding-top: var(--tc-space-4); border-top: 1px solid var(--tc-border); font-size: var(--tc-fs-md); }
.topcnc-case-form .topcnc-card__title:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.topcnc-alert--info { background: var(--tc-primary-100); color: var(--tc-primary); border-radius: var(--tc-radius-sm); padding: var(--tc-space-3) var(--tc-space-4); font-size: var(--tc-fs-sm); }
.topcnc-case-title { font-weight: 600; }
.topcnc-cases-table small { display: block; font-size: var(--tc-fs-xs); }
.topcnc-case-status--open { background: var(--tc-accent-100); color: var(--tc-accent-600); }
.topcnc-case-status--in_progress { background: var(--tc-primary-100); color: var(--tc-primary); }
.topcnc-case-status--resolved { background: var(--tc-success-100); color: var(--tc-success); }
.topcnc-case-status--closed { background: var(--tc-bg-muted); color: var(--tc-text-muted); }
.topcnc-case-status--cancelled { background: var(--tc-bg-muted); color: var(--tc-text-muted); text-decoration: line-through; }
.topcnc-prio { display: inline-block; font-size: var(--tc-fs-xs); padding: 0 8px; border-radius: 999px; border: 1px solid var(--tc-border); white-space: nowrap; }
.topcnc-prio--high { border-color: var(--tc-accent); color: var(--tc-accent-600); }
.topcnc-prio--critical { background: var(--tc-danger-100); border-color: var(--tc-danger); color: var(--tc-danger); font-weight: 600; }
.topcnc-parts input { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--tc-border); border-radius: 6px; font: inherit; }
.topcnc-parts td { padding: 4px; }
.topcnc-parts__qty { max-width: 80px; }
.topcnc-similar { list-style: none; display: grid; gap: var(--tc-space-3); }
.topcnc-similar li { display: grid; gap: 2px; padding-bottom: var(--tc-space-2); border-bottom: 1px dashed var(--tc-border); font-size: var(--tc-fs-sm); }
.topcnc-similar li p { margin: 0; font-size: var(--tc-fs-xs); color: var(--tc-text-muted); }
.topcnc-timeline--case > li { grid-template-columns: 120px 1fr; }
.topcnc-timeline--case > li > div { display: grid; gap: 4px; }
.topcnc-timeline--case p { margin: 0; }
.topcnc-attachment { display: inline-flex; align-items: center; gap: 6px; font-size: var(--tc-fs-xs); }
.topcnc-attachment img { max-width: 160px; max-height: 120px; border-radius: 6px; border: 1px solid var(--tc-border); }
.topcnc-comment-form { margin-top: var(--tc-space-4); padding-top: var(--tc-space-4); border-top: 1px solid var(--tc-border); }
.topcnc-cite--case { background: var(--tc-success-100); color: var(--tc-success); }
.topcnc-cite--case:hover { background: var(--tc-success); color: #fff; }
.topcnc-msg__actions { margin-top: var(--tc-space-2); }

/* --- Alarm assistant --------------------------------------------------- */
.topcnc-card__subtitle { font-size: var(--tc-fs-md); margin: var(--tc-space-4) 0 var(--tc-space-2); }
.topcnc-alarm-code { font-family: var(--tc-font-mono); font-weight: 700; }
.topcnc-alarm-status--open { background: var(--tc-accent-100); color: var(--tc-accent-600); }
.topcnc-alarm-status--resolved { background: var(--tc-success-100); color: var(--tc-success); }
.topcnc-alarm-status--escalated { background: var(--tc-primary-100); color: var(--tc-primary); }
.topcnc-alarm-status--dismissed { background: var(--tc-bg-muted); color: var(--tc-text-muted); }
.topcnc-sev { display: inline-block; font-size: var(--tc-fs-xs); padding: 0 8px; border-radius: 999px; border: 1px solid var(--tc-border); white-space: nowrap; }
.topcnc-sev--warning { border-color: var(--tc-accent); color: var(--tc-accent-600); }
.topcnc-sev--stop { background: var(--tc-accent-100); border-color: var(--tc-accent); color: var(--tc-accent-600); font-weight: 600; }
.topcnc-sev--danger { background: var(--tc-danger-100); border-color: var(--tc-danger); color: var(--tc-danger); font-weight: 700; }
.topcnc-alarm-top { display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--tc-font-mono); font-size: var(--tc-fs-sm); }
.topcnc-alarm-top a { background: var(--tc-bg-muted); padding: 2px 8px; border-radius: 6px; }
.topcnc-alarm-top--list { list-style: none; }
.topcnc-diag__meaning { font-size: var(--tc-fs-md); font-weight: 500; line-height: 1.9; }
.topcnc-diag__knowledge { font-size: var(--tc-fs-sm); color: var(--tc-text-muted); }
.topcnc-diag__causes { padding-inline-start: 1.4rem; display: grid; gap: 6px; }
.topcnc-lik--high { border-color: var(--tc-danger); color: var(--tc-danger); }
.topcnc-lik--medium { border-color: var(--tc-accent); color: var(--tc-accent-600); }
.topcnc-steps { list-style: none; display: grid; gap: var(--tc-space-2); counter-reset: step; }
.topcnc-step { display: grid; grid-template-columns: 36px 1fr; gap: var(--tc-space-3); align-items: start; padding: var(--tc-space-3); border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); background: #fff; }
.topcnc-step.is-done { background: var(--tc-success-100); border-color: var(--tc-success); }
.topcnc-step.is-done .topcnc-step__body > span:first-child { text-decoration: line-through; color: var(--tc-text-muted); }
.topcnc-step.is-safety { border-inline-start: 4px solid var(--tc-danger); }
.topcnc-step__form { margin: 0; }
.topcnc-step__check { width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--tc-border); background: #fff; cursor: pointer; font-size: 16px; color: var(--tc-success); }
.topcnc-step.is-done .topcnc-step__check { border-color: var(--tc-success); background: var(--tc-success); color: #fff; }
.topcnc-step__body { display: grid; gap: 4px; line-height: 1.8; }
.topcnc-step__body::before { counter-increment: step; content: "مرحله " counter(step); font-size: var(--tc-fs-xs); color: var(--tc-text-muted); }
.topcnc-alert--error ul { margin: 6px 0 0; padding-inline-start: 1.2rem; }
.topcnc-cite--alarm { background: var(--tc-primary-100); color: var(--tc-primary); }
.topcnc-cite--alarm:hover { background: var(--tc-primary); color: #fff; }

.topcnc-soon { text-align: center; padding: var(--tc-space-12) var(--tc-space-6); display: grid; justify-items: center; gap: var(--tc-space-2); color: var(--tc-text-muted); }
.topcnc-soon svg { width: 40px; height: 40px; }
.topcnc-soon h3 { margin: 0; color: var(--tc-text); }
