:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #d9e1ee;
    --brand: #2254d8;
    --brand-dark: #183fa5;
    --soft: #eef3ff;
    --good: #0f8b5f;
    --warn: #a86605;
    --danger: #b42318;
}

/* Tasks / planner */
.task-toolbar-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px;
    margin-bottom: 16px;
}

.task-view-switch,
.task-filters,
.task-calendar-controls,
.task-relation-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-view-switch {
    padding: 4px;
    border-radius: 7px;
    background: color-mix(in srgb, var(--line) 55%, transparent);
}

.task-view-switch button {
    padding: 8px 11px;
    border: 0;
    background: transparent;
}

.task-view-switch button.active {
    color: #fff;
    background: var(--brand);
}

.task-filters input {
    width: min(330px, 30vw);
}

.task-view[hidden] {
    display: none !important;
}

.task-title-cell {
    display: grid;
    gap: 5px;
    min-width: 230px;
}

.task-title-cell > span,
.task-kanban-card-head > span,
.my-task-item > div > span,
.task-detail-meta span {
    color: var(--muted);
    font-size: 12px;
}

.task-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.task-tags > span {
    padding: 3px 7px;
    border: 1px solid color-mix(in srgb, var(--tag-color) 40%, transparent);
    border-radius: 999px;
    color: var(--tag-color);
    background: color-mix(in srgb, var(--tag-color) 10%, transparent);
    font-size: 11px;
    font-weight: 700;
}

.task-progress {
    display: grid;
    grid-template-columns: minmax(70px, 1fr) auto;
    gap: 7px;
    align-items: center;
}

.task-progress > div {
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--line) 70%, transparent);
}

.task-progress > div > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
}

.task-progress small,
.task-progress-empty {
    color: var(--muted);
    font-size: 11px;
}

.task-due.overdue {
    color: var(--danger);
    font-weight: 800;
}

.task-kanban {
    display: grid;
    grid-template-columns: repeat(4, minmax(245px, 1fr));
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.task-kanban-column {
    min-height: 560px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--panel) 88%, var(--bg));
    transition: border-color .15s ease, background .15s ease;
}

.task-kanban-column.drag-over {
    border-color: var(--brand);
    background: color-mix(in srgb, var(--brand) 8%, var(--panel));
}

.task-kanban-column-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
}

.task-kanban-column-head h2 {
    margin: 0;
    font-size: 15px;
}

.task-kanban-column-head > span {
    min-width: 25px;
    padding: 3px 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    color: var(--brand);
    text-align: center;
    font-size: 12px;
    font-weight: 800;
}

.task-kanban-cards {
    display: grid;
    align-content: start;
    gap: 9px;
    padding: 10px;
}

.task-kanban-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    cursor: grab;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .04);
}

.task-kanban-card.dragging {
    opacity: .45;
}

.task-kanban-card h3 {
    margin: 0;
    font-size: 14px;
    line-height: 1.35;
}

.task-kanban-card-head,
.task-kanban-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.task-kanban-meta {
    align-items: flex-start;
    flex-direction: column;
    color: var(--muted);
    font-size: 11px;
}

.kanban-empty {
    padding: 22px 8px;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}

.my-tasks-list {
    display: grid;
}

.my-task-item {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto 120px minmax(110px, .35fr) auto;
    gap: 16px;
    align-items: center;
    padding: 13px 16px;
    border-top: 1px solid var(--line);
}

.my-task-item:first-child {
    border-top: 0;
}

.my-task-item > div {
    display: grid;
    gap: 5px;
}

.task-calendar-panel {
    overflow: hidden;
}

.task-calendar-weekdays,
.task-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(110px, 1fr));
}

.task-calendar-weekdays {
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--line) 30%, transparent);
}

.task-calendar-weekdays span {
    padding: 9px;
    color: var(--muted);
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.task-calendar-grid {
    min-width: 770px;
}

.task-calendar-day {
    min-height: 126px;
    padding: 8px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.task-calendar-day.outside {
    background: color-mix(in srgb, var(--line) 18%, transparent);
}

.task-calendar-day.today {
    box-shadow: inset 0 0 0 2px var(--brand);
}

.task-calendar-number {
    display: block;
    margin-bottom: 7px;
    font-size: 12px;
    font-weight: 800;
}

.task-calendar-entry {
    display: block;
    width: 100%;
    margin: 0 0 4px;
    padding: 5px 6px;
    overflow: hidden;
    border: 0;
    border-left: 3px solid var(--brand);
    border-radius: 4px;
    background: color-mix(in srgb, var(--brand) 10%, transparent);
    color: var(--ink);
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
}

.task-calendar-entry.priority-high { border-left-color: var(--warn); }
.task-calendar-entry.priority-urgent { border-left-color: var(--danger); }

.task-dialog,
.task-preview-dialog {
    width: min(960px, calc(100vw - 40px));
    max-width: 960px;
    max-height: calc(100vh - 40px);
}

.task-dialog .full-width {
    grid-column: 1 / -1;
}

.task-dialog label small {
    color: var(--muted);
}

.task-relation-builder,
.task-detail-section {
    display: grid;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.task-relation-controls {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr) auto;
}

.task-relation-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.task-relation-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--brand) 7%, var(--panel));
    font-size: 12px;
}

.task-relation-chip button {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
}

.task-detail-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
}

.task-detail-meta > div {
    display: grid;
    gap: 5px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.task-detail-section {
    margin-top: 16px;
}

.task-description {
    margin: 0;
    line-height: 1.55;
}

.task-checklist {
    display: grid;
    gap: 6px;
}

.task-checklist-item {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) 34px;
    gap: 9px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.task-checklist-item.done > span {
    color: var(--muted);
    text-decoration: line-through;
}

.task-checklist-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.task-related-list {
    display: grid;
    gap: 7px;
}

.task-related-list a {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    text-decoration: none;
}

.task-related-list a > span {
    color: var(--muted);
    font-size: 11px;
}

html[data-theme="dark"] .task-kanban-column,
html[data-theme="dark"] .task-kanban-card {
    border-color: #2a303b;
    background: #14171d;
}

@media (max-width: 1100px) {
    .task-toolbar-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .task-filters {
        display: grid;
        grid-template-columns: minmax(200px, 1fr) repeat(3, minmax(140px, .45fr));
    }

    .task-filters input { width: 100%; }
    .my-task-item { grid-template-columns: minmax(220px, 1fr) auto auto; }
    .my-task-item > :nth-child(4), .my-task-item > :nth-child(5) { grid-column: 2 / -1; }
}

@media (max-width: 760px) {
    .task-view-switch { overflow-x: auto; }
    .task-view-switch button { flex: 0 0 auto; }
    .task-filters { grid-template-columns: 1fr; }
    .task-kanban { grid-template-columns: repeat(4, minmax(270px, 82vw)); }
    .task-detail-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .task-relation-controls { grid-template-columns: 1fr; }
    .my-task-item { grid-template-columns: 1fr; align-items: start; }
    .my-task-item > :nth-child(4), .my-task-item > :nth-child(5) { grid-column: auto; }
}

@media (max-width: 520px) {
    .task-dialog, .task-preview-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
    .task-detail-meta { grid-template-columns: 1fr; }
}

.project-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(180px, .35fr) minmax(200px, .4fr);
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(260px, 1fr));
    gap: 14px;
}

.project-card {
    display: flex;
    min-height: 300px;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.project-card-head,
.project-card-meta,
.project-card-counts,
.project-card-actions,
.project-progress,
.project-members,
.project-detail-summary {
    display: flex;
    align-items: center;
}

.project-card-head {
    justify-content: space-between;
}

.project-card-head > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
}

.project-card h2 {
    margin: 0;
    font-size: 19px;
    line-height: 1.3;
}

.project-card > p {
    display: -webkit-box;
    min-height: 42px;
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.project-progress {
    gap: 12px;
}

.project-progress > div {
    height: 8px;
    flex: 1;
    overflow: hidden;
    border-radius: 4px;
    background: color-mix(in srgb, var(--brand) 12%, transparent);
}

.project-progress > div > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
}

.project-progress strong {
    min-width: 38px;
    font-size: 12px;
    text-align: right;
}

.project-card-meta {
    gap: 16px;
    color: var(--muted);
    font-size: 12px;
}

.project-card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.project-card-counts {
    margin-top: auto;
    gap: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.project-card-counts strong {
    color: var(--ink);
}

.project-card-actions {
    gap: 8px;
}

.projects-empty {
    grid-column: 1 / -1;
}

.project-dialog,
.project-preview-dialog {
    width: min(980px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
}

.project-dialog .form-grid {
    align-items: start;
}

.project-dialog .form-grid > label {
    width: 100%;
}

.project-detail-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.project-detail-summary > div {
    display: flex;
    min-height: 68px;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.project-detail-summary span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.project-detail-section {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.project-detail-section h3 {
    margin: 0;
    font-size: 15px;
}

.project-detail-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
}

.project-members {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.project-member {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--brand) 10%, transparent);
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
}

.project-linked-list,
.project-documents {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.project-linked-list a,
.project-document {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    text-decoration: none;
}

.project-linked-list a:hover,
.project-document:hover {
    border-color: var(--brand);
}

.project-document > span {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 3px;
}

.project-document strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-document small {
    color: var(--muted);
}

html[data-theme="dark"] .project-card,
html[data-theme="dark"] .project-detail-section {
    border-color: #2a303b;
    background: #14171d;
}

@media (max-width: 1100px) {
    .projects-grid { grid-template-columns: repeat(2, minmax(260px, 1fr)); }
}

@media (max-width: 760px) {
    .project-toolbar,
    .projects-grid,
    .project-detail-columns,
    .project-detail-summary { grid-template-columns: 1fr; }
    .project-dialog,
    .project-preview-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
}

.knowledge-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.knowledge-sidebar {
    position: sticky;
    top: 72px;
    overflow: hidden;
    padding: 8px;
}

.knowledge-sidebar-title {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 10px 13px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}

.knowledge-sidebar-title i {
    color: var(--brand);
}

.knowledge-sidebar nav {
    display: grid;
    gap: 3px;
}

.knowledge-sidebar nav button {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    min-height: 40px;
    padding: 9px 10px;
    border: 0;
    background: transparent;
    text-align: left;
}

.knowledge-sidebar nav button.active {
    background: var(--soft);
    color: var(--brand);
}

.knowledge-sidebar nav button strong {
    min-width: 22px;
    padding: 2px 6px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--brand) 10%, transparent);
    font-size: 10px;
    text-align: center;
}

.knowledge-content {
    min-width: 0;
}

.knowledge-toolbar {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 220px;
    gap: 10px;
    padding: 12px;
}

.knowledge-section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    margin: 18px 2px 10px;
}

.knowledge-section-heading h2,
.knowledge-section-heading p {
    margin: 0;
}

.knowledge-section-heading p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.knowledge-articles {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

.knowledge-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 230px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.knowledge-card-open {
    display: grid;
    width: 100%;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 13px;
    padding: 14px 16px;
    border: 0;
    background: transparent;
    text-align: left;
}

.knowledge-card-open:hover h3 {
    color: var(--brand);
}

.knowledge-card-icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 7px;
    background: var(--soft);
    color: var(--brand);
}

.knowledge-card-meta,
.knowledge-card-footer,
.knowledge-reader-info {
    display: flex;
    align-items: center;
}

.knowledge-card-meta {
    justify-content: flex-start;
    gap: 10px;
    color: var(--muted);
    font-size: 11px;
}

.knowledge-card h3 {
    margin: 6px 0 5px;
    font-size: 15px;
}

.knowledge-card-open p {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.knowledge-card-footer {
    align-content: center;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
    padding: 12px 16px;
    border-top: 0;
    border-left: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
}

.knowledge-card-footer span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.knowledge-empty {
    grid-column: 1 / -1;
}

.knowledge-editor-dialog {
    width: min(1080px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
}

.knowledge-preview-dialog,
.knowledge-revisions-dialog {
    width: min(1080px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
}

.knowledge-editor-form {
    width: 100%;
}

.knowledge-meta-form {
    align-items: start;
}

.knowledge-meta-form > label {
    width: 100%;
}

.knowledge-meta-form > label[hidden] {
    display: none !important;
}

.knowledge-block-editor-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.knowledge-block-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.knowledge-block-toolbar button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 9px;
    font-size: 12px;
}

.knowledge-block-editor {
    display: grid;
    gap: 10px;
}

.knowledge-editor-block {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--panel) 92%, var(--bg));
}

.knowledge-editor-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 9px;
}

.knowledge-editor-block-head > span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.knowledge-editor-block-head > div {
    display: flex;
    gap: 4px;
}

.knowledge-editor-block-head .icon-button {
    width: 30px;
    height: 30px;
}

.knowledge-editor-block-fields {
    display: grid;
    gap: 8px;
}

.knowledge-editor-block-fields textarea,
.knowledge-editor-block-fields input,
.knowledge-editor-block-fields select {
    width: 100%;
}

.knowledge-block-inline {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 8px;
}

.knowledge-code-input,
.knowledge-code pre,
.knowledge-revision-preview pre {
    font-family: Consolas, "Courier New", monospace;
}

.knowledge-inline-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.knowledge-inline-check input {
    width: auto;
}

.knowledge-divider-preview {
    padding: 12px 0;
}

.knowledge-divider-preview span {
    display: block;
    border-top: 1px solid var(--line);
}

.knowledge-reader {
    width: 100%;
}

.knowledge-reader-info {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr .55fr;
    gap: 0;
    margin: 2px 0 0;
    padding: 11px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.knowledge-reader-info > div {
    display: flex;
    min-height: 38px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 0 14px;
    border-right: 1px solid var(--line);
}

.knowledge-reader-info > div:first-child {
    padding-left: 0;
}

.knowledge-reader-info > div:last-child {
    border-right: 0;
}

.knowledge-reader-info > div > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.knowledge-reader-info > div:first-child {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.knowledge-rendered-content {
    width: 100%;
    max-width: none;
    min-height: 110px;
    margin: 0;
    padding: 22px 12px;
    color: var(--ink);
    line-height: 1.7;
}

.knowledge-rendered-content h2,
.knowledge-rendered-content h3,
.knowledge-rendered-content h4 {
    margin: 1.5em 0 .55em;
    line-height: 1.3;
}

.knowledge-rendered-content p,
.knowledge-rendered-content ul,
.knowledge-rendered-content ol {
    margin: .8em 0;
}

.knowledge-rendered-content table {
    width: 100%;
    border-collapse: collapse;
}

.knowledge-rendered-content th,
.knowledge-rendered-content td {
    padding: 9px;
    border: 1px solid var(--line);
    text-align: left;
}

.knowledge-rendered-content figure {
    margin: 18px 0;
}

.knowledge-rendered-content figure img {
    display: block;
    max-width: 100%;
    max-height: 620px;
    border-radius: 6px;
    object-fit: contain;
}

.knowledge-rendered-content figcaption {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.knowledge-checklist {
    display: grid;
    gap: 7px;
    margin: 12px 0;
}

.knowledge-checklist label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.knowledge-code {
    overflow: hidden;
    margin: 14px 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #0b1020;
    color: #e2e8f0;
}

.knowledge-code > span {
    display: block;
    padding: 7px 12px;
    border-bottom: 1px solid #273149;
    color: #93c5fd;
    font-size: 10px;
    text-transform: uppercase;
}

.knowledge-code pre {
    margin: 0;
    padding: 14px;
    overflow-x: auto;
    white-space: pre-wrap;
}

.knowledge-callout {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 10px;
    margin: 14px 0;
    padding: 14px;
    border-left: 4px solid var(--brand);
    border-radius: 6px;
    background: var(--soft);
}

.knowledge-callout p {
    margin: 0;
}

.knowledge-callout.success { border-left-color: var(--good); }
.knowledge-callout.warning { border-left-color: var(--warn); }
.knowledge-callout.danger { border-left-color: var(--danger); }

.knowledge-file-block {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    text-decoration: none;
}

.knowledge-reader-attachments {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 16px 12px 4px;
    border-top: 1px solid var(--line);
}

.knowledge-reader-attachments > div {
    display: grid;
    gap: 7px;
}

.knowledge-reader-attachments a {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    text-decoration: none;
}

.knowledge-reader > .dialog-actions {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.knowledge-revision-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 14px;
    min-height: 520px;
}

.knowledge-revisions-list {
    display: grid;
    align-content: start;
    gap: 7px;
    max-height: 65vh;
    overflow-y: auto;
}

.knowledge-revisions-list article {
    display: grid;
    gap: 9px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.knowledge-revisions-list article > div:first-child {
    display: grid;
    gap: 3px;
}

.knowledge-revisions-list article > div:last-child {
    display: flex;
    gap: 5px;
}

.knowledge-revisions-list span,
.knowledge-revisions-list small {
    color: var(--muted);
    font-size: 11px;
}

.knowledge-revision-preview {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 7px;
    overflow: auto;
}

.knowledge-revision-compare {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.knowledge-revision-compare > section {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.knowledge-compare-selected {
    display: grid;
    place-items: center;
    align-content: center;
    min-height: 300px;
    gap: 9px;
    color: var(--muted);
    text-align: center;
}

.knowledge-compare-selected i {
    color: var(--brand);
    font-size: 30px;
}

html[data-theme="dark"] .knowledge-card,
html[data-theme="dark"] .knowledge-editor-block {
    border-color: #2a303b;
    background: #14171d;
}

@media (max-width: 980px) {
    .knowledge-layout { grid-template-columns: 1fr; }
    .knowledge-sidebar { position: static; }
    .knowledge-sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .knowledge-reader-info { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
    .knowledge-toolbar,
    .knowledge-articles,
    .knowledge-reader-info,
    .knowledge-revision-layout,
    .knowledge-revision-compare { grid-template-columns: 1fr; }
    .knowledge-sidebar nav { display: flex; overflow-x: auto; }
    .knowledge-sidebar nav button { min-width: 180px; }
    .knowledge-editor-dialog,
    .knowledge-preview-dialog,
    .knowledge-revisions-dialog { width: calc(100vw - 12px); max-height: calc(100vh - 12px); }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
}

button:hover {
    border-color: var(--brand);
}

.primary,
.login-card button[type="submit"] {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.primary:hover,
.login-card button[type="submit"]:hover {
    background: var(--brand-dark);
}

.danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.danger:hover {
    background: #8f1b13;
    border-color: #8f1b13;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(34, 84, 216, .12), rgba(15, 139, 95, .10)),
        var(--bg);
}

.login-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 24px 70px rgba(23, 32, 51, .12);
}

.login-card h1 {
    margin: 18px 0 8px;
    font-size: 28px;
}

.login-card p {
    margin: 0 0 22px;
    color: var(--muted);
}

.login-card form,
.dialog-form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: #fff;
    color: var(--ink);
}

select[multiple] {
    min-height: 132px;
    padding: 8px;
}

select[multiple] option {
    padding: 7px 8px;
    border-radius: 6px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(34, 84, 216, .14);
    border-color: var(--brand);
}

textarea {
    resize: vertical;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
    letter-spacing: .02em;
}

.brand-mark.large {
    width: 58px;
    height: 58px;
    font-size: 20px;
}

.brand-logo {
    width: 54px;
    height: 42px;
    object-fit: contain;
    padding: 4px;
    border-radius: 8px;
    background: #fff;
}

.login-logo {
    display: block;
    width: min(220px, 100%);
    height: auto;
    margin-bottom: 18px;
}

.error {
    padding: 10px 12px;
    border-radius: 8px;
    background: #fff0ee;
    color: var(--danger);
    border: 1px solid #ffd2cc;
    margin-bottom: 14px;
}

.app-body {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    background: #101828;
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand span {
    display: block;
    margin-top: 4px;
    color: #b8c0d0;
    font-size: 13px;
}

.sidebar nav {
    display: grid;
    gap: 6px;
}

.nav-link {
    color: #d7deea;
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 8px;
}

.nav-link:hover,
.nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, .10);
}

.logout-form {
    margin-top: auto;
}

.logout-form button {
    width: 100%;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    border-color: rgba(255, 255, 255, .16);
}

.mobile-menu-button,
.mobile-menu-close,
.mobile-menu-backdrop {
    display: none;
}

.main {
    min-width: 0;
    padding: 24px;
}

.topbar,
.page-heading,
.panel-header,
.toolbar,
.dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar {
    padding: 14px 0 28px;
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 5px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    font-weight: 800;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 30px;
}

h2 {
    font-size: 18px;
}

.page-heading {
    margin-bottom: 20px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.summary-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.summary-card {
    padding: 18px;
}

.summary-card span {
    display: block;
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
}

.summary-card strong {
    display: block;
    margin-top: 8px;
    font-size: 32px;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
    gap: 18px;
}

.panel {
    overflow: hidden;
}

.panel-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.panel-header span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

td.actions {
    display: flex;
    gap: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 800;
    background: var(--soft);
    color: var(--brand-dark);
}

.badge.good {
    background: #e9f8f1;
    color: var(--good);
}

.badge.warn {
    background: #fff6e7;
    color: var(--warn);
}

.badge.danger {
    background: #fee2e2;
    color: var(--danger);
}

.badge.done {
    background: #edf0f5;
    color: #475467;
}

.vehicle-list {
    display: grid;
    gap: 10px;
    padding: 16px;
}

.tickets-panel .section-heading {
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--line);
}

.panel > .section-heading {
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.tickets-panel .section-heading h2,
.panel > .section-heading h2 {
    margin: 0 0 4px;
}

.tickets-panel .section-heading p,
.panel > .section-heading p {
    margin: 0;
    color: var(--muted);
}

.tickets-table th:nth-child(2),
.tickets-table td:nth-child(2) {
    min-width: 320px;
    white-space: normal;
}

.ticket-row td {
    vertical-align: top;
}

.ticket-row td:first-child span,
.ticket-main span,
.ticket-meta span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
}

.ticket-main {
    display: grid;
    gap: 4px;
}

.ticket-main p {
    margin: 4px 0 0;
    color: var(--muted);
    line-height: 1.45;
    white-space: normal;
}

.ticket-meta {
    display: grid;
    gap: 3px;
}

.ticket-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    min-width: 300px;
    white-space: normal;
}

.ticket-actions button {
    min-height: 32px;
    padding: 6px 9px;
    white-space: nowrap;
}

.tickets-table th:last-child,
.tickets-table td:last-child {
    width: 320px;
}

.tickets-table th,
.tickets-table td {
    vertical-align: top;
}

#ptDeskApprovalTable td {
    vertical-align: middle;
}

#ptDeskApprovalTable select {
    min-width: 190px;
}

#ptDeskApprovalTable td.actions {
    display: table-cell;
    white-space: nowrap;
}

.ticket-preview {
    display: grid;
    gap: 10px;
}

.ticket-preview div {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.ticket-preview strong {
    color: var(--muted);
}

.ticket-preview span {
    white-space: pre-wrap;
}

.history-list {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.history-list article {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.history-list article span {
    color: var(--muted);
    font-size: 12px;
}

.pt-desk-grid {
    display: grid;
    grid-template-columns: minmax(320px, .85fr) minmax(0, 1.15fr);
    gap: 18px;
    align-items: start;
}

.news-list {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.news-card {
    display: grid;
    gap: 9px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.news-card div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.news-card span,
.news-card p {
    color: var(--muted);
}

.news-card p {
    margin: 0;
    line-height: 1.45;
}

.vehicle {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    display: grid;
    gap: 8px;
}

.vehicle-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.muted {
    color: var(--muted);
}

.toolbar {
    margin-bottom: 14px;
}

.toolbar input {
    max-width: 520px;
}

.toolbar select {
    max-width: 260px;
}

dialog {
    border: 1px solid var(--line);
    border-radius: 8px;
    width: min(520px, calc(100% - 28px));
    padding: 0;
    box-shadow: 0 24px 70px rgba(23, 32, 51, .22);
}

#orderDialog {
    width: min(820px, calc(100% - 28px));
}

#databaseDialog {
    width: min(1080px, calc(100% - 28px));
}

#databasePreviewDialog {
    width: min(980px, calc(100% - 28px));
}

dialog::backdrop {
    background: rgba(16, 24, 40, .45);
}

.dialog-form {
    padding: 22px;
}

.dialog-form.wide {
    gap: 18px;
}

.dialog-actions {
    justify-content: flex-end;
}

.empty {
    padding: 22px;
    color: var(--muted);
}

.orders-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 18px;
    align-items: start;
}

.orders-board {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.order-column {
    min-width: 0;
    background: #eef3f8;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
}

.column-header span {
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #fff;
    color: var(--muted);
    font-weight: 800;
}

.order-cards {
    display: grid;
    gap: 10px;
    padding: 12px;
}

.order-card {
    display: grid;
    gap: 9px;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.order-card-top,
.order-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.order-card h3 {
    margin: 0;
    font-size: 17px;
}

.order-card p,
.order-card small {
    margin: 0;
    color: var(--muted);
    line-height: 1.35;
}

.service-report {
    padding: 9px 10px;
    border-radius: 8px;
    background: #f6f8fb;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.service-report strong {
    color: var(--ink);
}

.photo-links {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
}

.photo-links strong {
    width: 100%;
    font-size: 12px;
}

.photo-links a {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.order-meta {
    align-items: flex-start;
    color: var(--ink);
    font-size: 13px;
}

.order-meta span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.order-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 4px;
}

.order-actions button {
    padding: 8px 10px;
    font-size: 13px;
}

.calendar-panel {
    position: sticky;
    top: 20px;
}

.calendar-panel .panel-header {
    padding: 14px;
}

.calendar-panel .panel-header h2 {
    text-align: center;
}

.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
    padding: 12px 12px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}

.calendar-grid {
    gap: 6px;
    padding: 12px;
}

.calendar-day {
    min-height: 82px;
    display: grid;
    align-content: start;
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.calendar-day strong {
    font-size: 13px;
}

.calendar-day span,
.calendar-day small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-radius: 6px;
    padding: 3px 5px;
    background: var(--soft);
    color: var(--brand-dark);
    font-size: 11px;
    font-weight: 800;
}

.calendar-day.has-orders {
    border-color: rgba(34, 84, 216, .36);
    box-shadow: inset 0 0 0 1px rgba(34, 84, 216, .08);
}

.muted-day {
    background: transparent;
    border-color: transparent;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.span-2 {
    grid-column: 1 / -1;
}

.technicians-field {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.technicians-field legend {
    padding: 0 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.checkbox-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 9px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
}

.checkbox-card input {
    width: auto;
    grid-row: span 2;
}

.checkbox-card small {
    color: var(--muted);
    font-weight: 400;
}

.carrier-list {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.carrier-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.carrier-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.carrier-header h2 {
    margin-bottom: 5px;
}

.carrier-header p {
    margin: 0;
    color: var(--muted);
}

.carrier-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    color: var(--muted);
}

.carrier-details span,
.bases-list span {
    overflow-wrap: anywhere;
}

.carrier-details strong,
.bases-list strong {
    color: var(--ink);
}

.bases-list {
    display: grid;
    gap: 7px;
    padding: 12px;
    border-radius: 8px;
    background: #f6f8fb;
}

.bases-fields {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
}

.base-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.direction-table-wrap {
    overflow-x: auto;
    margin-bottom: 10px;
}

.direction-table-wrap table {
    min-width: 860px;
}

.direction-table-wrap th,
.direction-table-wrap td {
    padding: 8px;
}

.preview-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.preview-heading p {
    margin: 6px 0 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.detail-grid div,
.admin-row {
    display: grid;
    gap: 5px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.detail-grid span {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.admin-section {
    padding-bottom: 14px;
}

.inline-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 10px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
}

.admin-list {
    display: grid;
    gap: 8px;
    padding: 14px;
}

.admin-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

#databaseDialog {
    width: min(70vw, calc(100% - 28px));
    max-width: none;
}

#databaseDialog .dialog-form {
    max-height: 86vh;
    overflow: auto;
}

#databaseDialog h2 {
    position: sticky;
    top: -22px;
    z-index: 3;
    margin: 0;
    padding: 0 0 14px;
    background: var(--panel);
}

.admin-section {
    min-height: 0;
}

.admin-section .admin-list {
    max-height: 260px;
    overflow: auto;
}

.compact-order-card h3,
.compact-order-card p {
    margin: 0;
}

.orders-archive-panel {
    margin-top: 18px;
}

.history-list p {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.35;
}

dialog#databaseDialog {
    width: 70vw !important;
    max-width: none !important;
}

dialog#databasePreviewDialog {
    width: 70vw !important;
    max-width: none !important;
    max-height: 86vh;
    overflow: hidden;
}

dialog#databasePreviewDialog .dialog-form {
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

dialog#databasePreviewDialog .preview-heading {
    flex: 0 0 auto;
    margin: -22px -22px 0;
    padding: 22px 22px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 18px rgba(15, 23, 42, .1);
}

dialog#databasePreviewDialog .direction-table-wrap {
    flex: 1 1 auto;
    overflow: auto;
    margin-top: 0;
    min-height: 0;
}

dialog#databasePreviewDialog .direction-table-wrap table {
    border-collapse: separate;
    border-spacing: 0;
}

dialog#databasePreviewDialog .direction-table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f8fafc;
    box-shadow: 0 1px 0 var(--line), 0 8px 14px rgba(15, 23, 42, .06);
}

dialog#databasePreviewDialog .direction-table-wrap thead,
dialog#databasePreviewDialog .direction-table-wrap thead tr {
    background: #f8fafc;
}

html[data-theme="dark"] dialog#databasePreviewDialog .direction-table-wrap thead,
html[data-theme="dark"] dialog#databasePreviewDialog .direction-table-wrap thead tr,
html[data-theme="dark"] dialog#databasePreviewDialog .direction-table-wrap thead th {
    background: #171b22;
}

dialog#databaseDialog .dialog-form {
    max-height: 86vh;
    overflow: auto;
}

dialog#databaseDialog h2 {
    position: sticky;
    top: -22px;
    z-index: 5;
    background: var(--panel);
    padding-bottom: 14px;
}

.orders-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#ordersSummary.summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
    #databaseDialog {
        width: min(96vw, calc(100% - 18px)) !important;
    }

    #databasePreviewDialog {
        width: min(96vw, calc(100% - 18px)) !important;
    }

    .app-body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 50;
        width: min(330px, 88vw);
        padding: 18px;
        gap: 20px;
        box-shadow: 24px 0 60px rgba(16, 24, 40, .32);
        transform: translateX(-105%);
        transition: transform .22s ease;
        overflow-y: auto;
    }

    body.menu-open .sidebar {
        transform: translateX(0);
    }

    .mobile-menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 45;
        background: rgba(16, 24, 40, .46);
    }

    body.menu-open .mobile-menu-backdrop {
        display: block;
    }

    .mobile-menu-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 9px 12px;
        background: var(--brand);
        color: #fff;
        border-color: var(--brand);
        white-space: nowrap;
    }

    .mobile-menu-close {
        display: inline-flex;
        margin-left: auto;
        padding: 7px 9px;
        background: rgba(255, 255, 255, .08);
        color: #fff;
        border-color: rgba(255, 255, 255, .16);
        font-size: 12px;
    }

    .brand {
        gap: 10px;
    }

    .brand-logo {
        width: 46px;
        height: 34px;
        padding: 3px;
    }

    .brand strong {
        font-size: 15px;
    }

    .brand span {
        margin-top: 2px;
        font-size: 11px;
    }

    .sidebar nav {
        display: grid;
        gap: 8px;
    }

    .nav-link {
        padding: 12px 13px;
        border-radius: 8px;
        background: rgba(255, 255, 255, .06);
        border: 1px solid rgba(255, 255, 255, .08);
    }

    .logout-form {
        margin-top: 0;
    }

    .logout-form button {
        width: 100%;
        padding: 10px 12px;
        font-size: 14px;
    }

    .main {
        padding: 18px;
    }

    .topbar {
        padding: 10px 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        margin-bottom: 14px;
        justify-content: flex-start;
    }

    .summary-grid,
    .split,
    .orders-layout,
    .orders-board,
    .admin-grid,
    .pt-desk-grid {
        grid-template-columns: 1fr;
    }

    .inline-form {
        grid-template-columns: 1fr;
    }

    .page-heading,
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar input,
    .toolbar select {
        max-width: none;
    }

    .calendar-panel {
        position: static;
    }
}

@media (max-width: 560px) {
    .main {
        padding: 16px;
    }

    .brand {
        max-width: none;
    }

    .brand span {
        display: block;
    }

    .topbar {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 10px;
    }

    .topbar > span {
        grid-column: 2;
        font-size: 13px;
    }

    th,
    td {
        padding: 11px 12px;
    }

    .form-grid,
    .checkbox-grid,
    .carrier-details,
    .base-row,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .carrier-header {
        flex-direction: column;
    }

    .calendar-day {
        min-height: 68px;
        padding: 6px;
    }
}

/* Apex/shadcn inspired application polish */
:root {
    --bg: #f7f8fb;
    --panel: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #1d4ed8;
    --brand-dark: #1e40af;
    --soft: #eff6ff;
    --good: #047857;
    --warn: #b45309;
    --danger: #dc2626;
    --sidebar: #ffffff;
    --sidebar-ink: #0f172a;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --shadow-soft: 0 8px 24px rgba(15, 23, 42, .06);
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(29, 78, 216, .09), transparent 32rem),
        linear-gradient(180deg, #fbfcff 0%, var(--bg) 28rem);
}

button,
.button-link,
input,
select,
textarea {
    transition: border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

button,
.button-link {
    min-height: 38px;
    border-radius: 8px;
    font-weight: 700;
    box-shadow: 0 1px 1px rgba(15, 23, 42, .04);
}

button:hover,
.button-link:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

input,
select,
textarea {
    min-height: 42px;
    border-color: #dbe3ef;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}

.app-body {
    grid-template-columns: 284px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--sidebar);
    color: var(--sidebar-ink);
    border-right: 1px solid var(--line);
    padding: 18px 16px;
    gap: 18px;
}

.brand {
    min-height: 64px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.brand-logo {
    width: 56px;
    height: 44px;
    border: 1px solid var(--line);
    box-shadow: 0 2px 10px rgba(15, 23, 42, .06);
}

.brand strong {
    color: #0b1220;
    letter-spacing: .02em;
}

.brand span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
}

.sidebar nav {
    gap: 18px;
}

.nav-section {
    display: grid;
    gap: 6px;
}

.nav-section p {
    margin: 0 0 3px;
    padding: 0 10px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.nav-link {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: center;
    min-height: 42px;
    color: #475569;
    padding: 5px 10px 5px 5px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 750;
}

.nav-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 15px;
}

.nav-link:hover {
    color: var(--ink);
    background: #f8fafc;
    border-color: var(--line);
}

.nav-link.active {
    color: var(--brand-dark);
    background: var(--soft);
    border-color: #bfdbfe;
    box-shadow: 0 8px 22px rgba(29, 78, 216, .10);
}

.nav-link.active .nav-icon {
    background: var(--brand);
    color: #fff;
}

.logout-form button {
    background: #fff;
    color: #475569;
    border-color: var(--line);
}

.logout-form button:hover {
    color: var(--danger);
    border-color: #fecaca;
    background: #fff7f7;
}

.main {
    padding: 22px 28px 34px;
}

.topbar {
    min-height: 64px;
    margin: 0 0 24px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .86);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    backdrop-filter: blur(14px);
}

.topbar strong {
    color: var(--ink);
}

.topbar > span {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
}

.page-heading {
    min-height: 58px;
    margin-bottom: 18px;
}

.eyebrow {
    color: #526178;
    letter-spacing: .1em;
}

h1 {
    color: #07111f;
    font-size: clamp(26px, 3vw, 36px);
    line-height: 1.08;
    letter-spacing: 0;
}

h2 {
    color: #0f172a;
}

.summary-card,
.panel,
.order-column,
.calendar-panel,
.carrier-card,
.admin-card,
dialog {
    border-color: var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .96);
    box-shadow: var(--shadow-soft);
}

.summary-card {
    position: relative;
    overflow: hidden;
}

.summary-card::after {
    content: none;
    display: none;
    position: absolute;
    right: 16px;
    top: 16px;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(29, 78, 216, .18), rgba(29, 78, 216, .04));
}

.summary-card strong {
    color: #07111f;
    font-size: 34px;
    letter-spacing: -.02em;
}

.panel-header,
.column-header {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.toolbar {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

table {
    background: #fff;
}

th {
    background: #f8fafc;
    color: #526178;
    font-size: 11px;
}

td {
    color: #1e293b;
}

tbody tr:hover {
    background: #f8fbff;
}

td.actions,
.order-actions,
.row-actions {
    gap: 7px;
}

td.actions button,
.order-actions button,
.row-actions button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.badge {
    border: 1px solid rgba(29, 78, 216, .12);
}

.order-column {
    background: #f8fafc;
}

.order-card,
.vehicle,
.checkbox-card,
.carrier-card,
.admin-row {
    border-color: #e2e8f0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.order-card:hover,
.carrier-card:hover,
.vehicle:hover,
.admin-row:hover {
    border-color: #bfdbfe;
    box-shadow: var(--shadow-soft);
}

.calendar-day {
    border-color: #dbe3ef;
}

.calendar-day.has-orders {
    background: #f8fbff;
}

dialog {
    box-shadow: 0 30px 90px rgba(15, 23, 42, .24);
}

dialog::backdrop {
    background: rgba(15, 23, 42, .42);
    backdrop-filter: blur(3px);
}

.login-body {
    background:
        radial-gradient(circle at 18% 15%, rgba(29, 78, 216, .16), transparent 28rem),
        radial-gradient(circle at 82% 78%, rgba(2, 132, 199, .10), transparent 24rem),
        #f8fafc;
}

.login-card {
    border-color: var(--line);
    box-shadow: 0 26px 80px rgba(15, 23, 42, .14);
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        height: auto;
        background: #fff;
        color: var(--ink);
        border-right: 1px solid var(--line);
    }

    .mobile-menu-button {
        width: 42px;
        min-width: 42px;
        padding: 0;
        border-radius: 8px;
        font-size: 20px;
    }

    .mobile-menu-close {
        width: 34px;
        min-width: 34px;
        height: 34px;
        padding: 0;
        background: #f8fafc;
        color: var(--ink);
        border-color: var(--line);
        font-size: 20px;
    }

    .mobile-menu-backdrop {
        backdrop-filter: blur(3px);
    }

    .nav-link {
        background: transparent;
        border: 1px solid transparent;
    }

    .main {
        padding: 14px;
    }

    .topbar {
        margin-bottom: 16px;
    }
}

@media (max-width: 560px) {
    .page-heading {
        gap: 12px;
    }

    h1 {
        font-size: 27px;
    }

    .summary-card,
    .panel-header,
    .dialog-form {
        padding: 16px;
    }

    .toolbar {
        padding: 10px;
    }
}

/* Dark Apex-like shell */
:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --ink: #0b1220;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #009BF5;
    --brand-dark: #007fca;
    --soft: #e7f5ff;
    --sidebar: #07090d;
    --sidebar-panel: #12151b;
    --sidebar-line: #222631;
    --sidebar-muted: #7b8495;
    --sidebar-ink: #edf2f7;
    --shadow: 0 18px 44px rgba(15, 23, 42, .08);
    --shadow-soft: 0 8px 22px rgba(15, 23, 42, .06);
}

.app-body {
    grid-template-columns: 256px minmax(0, 1fr);
    background: #f4f6fb;
}

.sidebar {
    background: var(--sidebar);
    color: var(--sidebar-ink);
    border-right: 1px solid var(--sidebar-line);
    padding: 14px 12px;
    gap: 16px;
}

.brand {
    min-height: 48px;
    padding: 0 2px 12px;
    border: 0;
    border-bottom: 1px solid var(--sidebar-line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.brand-logo {
    width: 34px;
    height: 34px;
    padding: 3px;
    border: 0;
    border-radius: 8px;
    background: #fff;
}

.brand strong {
    color: #fff;
    font-size: 14px;
    letter-spacing: 0;
}

.brand span {
    color: var(--sidebar-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    line-height: 1.1;
    text-transform: uppercase;
}

.sidebar nav {
    gap: 18px;
    padding-top: 4px;
}

.nav-section {
    gap: 4px;
}

.nav-section p {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 6px;
    padding: 0 8px;
    color: #596273;
    font-size: 10px;
    letter-spacing: .11em;
}

.nav-section p::after {
    content: "\f107";
    font: var(--fa-font-solid);
    color: #3f4654;
    font-size: 10px;
}

.nav-link {
    grid-template-columns: 28px minmax(0, 1fr);
    min-height: 36px;
    padding: 4px 8px;
    border: 0;
    color: #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
}

.nav-icon {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: transparent;
    color: #8b95a6;
    font-size: 14px;
}

.nav-link:hover {
    color: #fff;
    background: var(--sidebar-panel);
    border-color: transparent;
    box-shadow: none;
}

.nav-link:hover .nav-icon {
    color: #e2e8f0;
}

.nav-link.active {
    color: var(--brand);
    background: #171a20;
    border-color: transparent;
    box-shadow: none;
}

.nav-link.active .nav-icon {
    background: transparent;
    color: var(--brand);
}

.logout-form {
    padding-top: 12px;
    border-top: 1px solid var(--sidebar-line);
}

.logout-form button {
    min-height: 42px;
    background: transparent;
    color: #dbe3ef;
    border: 0;
    border-radius: 8px;
    text-align: left;
}

.logout-form button::before {
    content: "\f2f5";
    margin-right: 10px;
    font: var(--fa-font-solid);
    color: #8b95a6;
}

.logout-form button:hover {
    background: #171a20;
    color: #fff;
    box-shadow: none;
    transform: none;
}

.main {
    padding: 0 24px 32px;
    background:
        radial-gradient(circle at 18% -12%, rgba(0, 155, 245, .12), transparent 24rem),
        #f4f6fb;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 60px;
    margin: 0 -24px 28px;
    padding: 10px 24px;
    border: 0;
    border-bottom: 1px solid #e7ebf2;
    border-radius: 0;
    background: rgba(255, 255, 255, .92);
    box-shadow: none;
    backdrop-filter: blur(16px);
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-left {
    flex: 1;
}

.topbar-search {
    width: min(360px, 48vw);
    min-height: 38px;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 0 10px;
    border: 1px solid #dfe5ee;
    border-radius: 8px;
    background: #fff;
    color: #94a3b8;
    font-weight: 500;
}

.topbar-search input {
    min-height: 34px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.topbar-search input:focus {
    outline: 0;
}

.topbar-search span {
    padding: 2px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
}

.topbar-search input[readonly] {
    cursor: pointer;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.global-search-dialog {
    width: min(680px, calc(100vw - 32px));
    max-width: none;
    max-height: min(720px, calc(100vh - 64px));
    margin: 10vh auto auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid #dbe3ee;
    border-radius: 10px;
    background: #fff;
    color: #101828;
    box-shadow: 0 28px 90px rgba(15, 23, 42, .28);
}

.global-search-dialog::backdrop {
    background: rgba(15, 23, 42, .54);
    backdrop-filter: blur(3px);
}

.global-search-shell {
    display: grid;
    grid-template-rows: auto minmax(120px, 1fr) auto;
    max-height: min(720px, calc(100vh - 64px));
}

.global-search-input-row {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 0 18px;
    border-bottom: 1px solid #e5eaf1;
    color: #64748b;
}

.global-search-input-row > i {
    color: #009bf5;
    font-size: 18px;
}

.global-search-input-row input {
    width: 100%;
    min-height: 62px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font-size: 16px;
    font-weight: 650;
}

.global-search-input-row input:focus {
    outline: 0;
}

.global-search-input-row kbd,
.global-search-footer kbd {
    min-width: 24px;
    padding: 3px 6px;
    border: 1px solid #dce3ec;
    border-bottom-width: 2px;
    border-radius: 5px;
    background: #f8fafc;
    color: #64748b;
    font: 700 11px/1.2 inherit;
    text-align: center;
}

.global-search-results {
    min-height: 180px;
    max-height: min(560px, calc(100vh - 190px));
    padding: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.global-search-group + .global-search-group {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #edf1f6;
}

.global-search-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px 5px;
    color: #64748b;
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.global-search-group-title span {
    min-width: 22px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #eef7ff;
    color: #007bc2;
    text-align: center;
}

.global-search-result {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 11px;
    min-height: 56px;
    padding: 7px 10px;
    border-radius: 7px;
    color: inherit;
    text-decoration: none;
}

.global-search-result:hover,
.global-search-result.is-active {
    background: #edf7ff;
}

.global-search-result-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: #e7f5ff;
    color: #0089d8;
}

.global-search-result-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.global-search-result-copy strong,
.global-search-result-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.global-search-result-copy strong {
    font-size: 13px;
}

.global-search-result-copy small {
    color: #66758c;
    font-size: 12px;
}

.global-search-enter {
    color: #94a3b8;
    font-size: 11px;
    opacity: 0;
}

.global-search-result.is-active .global-search-enter {
    opacity: 1;
}

.global-search-message {
    min-height: 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px;
    color: #64748b;
    text-align: center;
}

.global-search-message > i {
    margin-bottom: 4px;
    color: #009bf5;
    font-size: 24px;
}

.global-search-message strong {
    color: #27364c;
}

.global-search-message span {
    font-size: 13px;
}

.global-search-footer {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 18px;
    border-top: 1px solid #e5eaf1;
    color: #718096;
    font-size: 11px;
}

.global-search-footer span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.global-search-footer span:last-child {
    margin-left: auto;
}

.icon-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    box-shadow: none;
}

.icon-button:hover {
    background: #f1f5f9;
    color: #0f172a;
    transform: none;
    box-shadow: none;
}

.notifications-menu {
    position: relative;
}

.notification-button {
    position: relative;
}

.notification-dot {
    position: absolute;
    top: 2px;
    right: 1px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--panel);
}

.notifications-popover {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: min(360px, calc(100vw - 28px));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .18);
    z-index: 80;
}

.notifications-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.notifications-head button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.notifications-list {
    max-height: 390px;
    overflow-y: auto;
}

.notification-item {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 8px;
    gap: 10px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    color: inherit;
    text-decoration: none;
}

.notification-item:hover {
    background: rgba(0, 155, 245, .07);
}

.notification-item.is-read {
    opacity: .68;
}

.notification-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(0, 155, 245, .12);
    color: var(--brand);
}

.notification-content strong,
.notification-content span,
.notification-content small {
    display: block;
}

.notification-content strong {
    overflow: hidden;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-content span {
    margin-top: 3px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-content small {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.notification-unread {
    width: 8px;
    height: 8px;
    margin-top: 12px;
    border-radius: 999px;
    background: var(--brand);
}

.notifications-empty {
    margin: 0;
    padding: 22px 16px;
    color: var(--muted);
    text-align: center;
}

.user-chip {
    display: grid;
    grid-template-columns: 36px minmax(0, auto);
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding-left: 10px;
    border-left: 1px solid #e2e8f0;
}

.user-chip > span {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #07110d;
    color: var(--brand);
    font-size: 13px;
    font-weight: 900;
}

.user-chip strong,
.user-chip small {
    display: block;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip strong {
    color: #0f172a;
    font-size: 13px;
}

.user-chip small {
    color: #64748b;
    font-size: 11px;
    text-transform: capitalize;
}

.page-heading {
    align-items: flex-end;
}

.page-heading .primary,
.primary {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #fff;
}

.page-heading .primary:hover,
.primary:hover {
    background: #1e40af;
    border-color: #1e40af;
}

.summary-card,
.panel,
.order-column,
.calendar-panel,
.carrier-card,
.admin-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.summary-card::after {
    display: none;
}

.summary-card strong {
    color: #0f172a;
}

.panel-header,
.column-header {
    background: #fff;
}

.order-column {
    background: #f8fafc;
}

.mobile-menu-close {
    display: none;
}

@media (max-width: 900px) {
    .app-body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        width: min(286px, 86vw);
        height: 100vh;
        background: var(--sidebar);
        color: var(--sidebar-ink);
        box-shadow: 22px 0 70px rgba(0, 0, 0, .38);
    }

    .brand {
        padding-right: 0;
    }

    .mobile-menu-close {
        display: grid;
        place-items: center;
        margin-left: auto;
        background: #171a20;
        color: #dbe3ef;
        border: 1px solid var(--sidebar-line);
    }

    .main {
        padding: 0 14px 24px;
    }

    .topbar {
        margin: 0 -14px 18px;
        padding: 10px 14px;
    }

    .topbar-search {
        width: 100%;
    }

    .topbar-actions {
        gap: 8px;
    }

    .user-chip div,
    .topbar-search span {
        display: none;
    }

    .user-chip {
        grid-template-columns: 34px;
        padding-left: 8px;
    }
}

@media (max-width: 560px) {
    .topbar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .topbar-left,
    .topbar-actions {
        width: 100%;
    }

    .topbar-actions {
        justify-content: flex-end;
    }

    .notifications-menu {
        position: static;
    }

    .notifications-popover {
        left: 14px;
        right: 14px;
        width: auto;
    }
}

.metric-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 8px 14px;
    align-items: start;
}

.metric-card > span,
.metric-card > strong {
    grid-column: 1;
}

.metric-icon {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(0, 155, 245, .12);
    color: var(--brand);
    font-size: 20px;
}

.metric-assigned .metric-icon {
    background: rgba(22, 163, 74, .12);
    color: #16a34a;
}

.metric-free .metric-icon {
    background: rgba(245, 158, 11, .14);
    color: #f59e0b;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #090b10;
    --panel: #14171d;
    --ink: #f8fafc;
    --muted: #94a3b8;
    --line: #262b35;
    --soft: rgba(0, 155, 245, .14);
    --shadow: 0 18px 44px rgba(0, 0, 0, .28);
    --shadow-soft: 0 8px 22px rgba(0, 0, 0, .22);
}

html[data-theme="dark"] body,
html[data-theme="dark"] .app-body {
    background: #090b10;
}

html[data-theme="dark"] .main {
    background:
        radial-gradient(circle at 18% -12%, rgba(0, 155, 245, .16), transparent 24rem),
        #090b10;
}

html[data-theme="dark"] .topbar {
    background: rgba(9, 11, 16, .88);
    border-bottom-color: #222631;
}

html[data-theme="dark"] .topbar-search,
html[data-theme="dark"] .topbar > span,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] button,
html[data-theme="dark"] .button-link {
    background: #14171d;
    border-color: #2a303b;
    color: #e2e8f0;
}

html[data-theme="dark"] .topbar-search input {
    background: transparent;
}

html[data-theme="dark"] .topbar-search span {
    border-color: #2a303b;
    color: #94a3b8;
}

html[data-theme="dark"] .global-search-dialog {
    border-color: #2a303b;
    background: #11141a;
    color: #f8fafc;
    box-shadow: 0 30px 100px rgba(0, 0, 0, .62);
}

html[data-theme="dark"] .global-search-input-row,
html[data-theme="dark"] .global-search-footer,
html[data-theme="dark"] .global-search-group + .global-search-group {
    border-color: #272c36;
}

html[data-theme="dark"] .global-search-input-row input {
    background: transparent;
    color: #f8fafc;
}

html[data-theme="dark"] .global-search-input-row kbd,
html[data-theme="dark"] .global-search-footer kbd {
    border-color: #343b48;
    background: #191d25;
    color: #9daabd;
}

html[data-theme="dark"] .global-search-group-title,
html[data-theme="dark"] .global-search-result-copy small,
html[data-theme="dark"] .global-search-footer,
html[data-theme="dark"] .global-search-message {
    color: #91a0b5;
}

html[data-theme="dark"] .global-search-group-title span {
    background: rgba(0, 155, 245, .14);
    color: #4bb9f8;
}

html[data-theme="dark"] .global-search-result:hover,
html[data-theme="dark"] .global-search-result.is-active {
    background: rgba(0, 155, 245, .12);
}

html[data-theme="dark"] .global-search-result-icon {
    background: rgba(0, 155, 245, .15);
    color: #29acf8;
}

html[data-theme="dark"] .global-search-message strong {
    color: #e8edf5;
}

html[data-theme="dark"] .icon-button {
    background: transparent;
    color: #94a3b8;
}

html[data-theme="dark"] .icon-button:hover {
    background: #171b22;
    color: #fff;
}

html[data-theme="dark"] .notifications-popover {
    background: #11141a;
    border-color: #262b35;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .42);
}

html[data-theme="dark"] .notification-item:hover {
    background: rgba(0, 155, 245, .10);
}

html[data-theme="dark"] .notification-icon {
    background: rgba(0, 155, 245, .16);
}

html[data-theme="dark"] .user-chip {
    border-left-color: #2a303b;
}

html[data-theme="dark"] .user-chip > span {
    background: rgba(0, 155, 245, .16);
    color: var(--brand);
}

html[data-theme="dark"] .user-chip strong,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] .summary-card strong {
    color: #f8fafc;
}

html[data-theme="dark"] .page-heading .primary,
html[data-theme="dark"] .primary {
    background: var(--brand);
    border-color: var(--brand);
}

html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .order-column,
html[data-theme="dark"] .calendar-panel,
html[data-theme="dark"] .carrier-card,
html[data-theme="dark"] .admin-card,
html[data-theme="dark"] dialog,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .order-card,
html[data-theme="dark"] .vehicle,
html[data-theme="dark"] .news-card,
html[data-theme="dark"] .checkbox-card,
html[data-theme="dark"] .admin-row,
html[data-theme="dark"] .bases-list,
html[data-theme="dark"] .base-row,
html[data-theme="dark"] .detail-grid div,
html[data-theme="dark"] .direction-table-wrap,
html[data-theme="dark"] .technicians-field,
html[data-theme="dark"] .inline-form {
    background: #14171d;
    border-color: #262b35;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .03);
}

html[data-theme="dark"] .panel-header,
html[data-theme="dark"] .column-header,
html[data-theme="dark"] th {
    background: #171b22;
}

html[data-theme="dark"] table,
html[data-theme="dark"] .calendar-day,
html[data-theme="dark"] .muted-day {
    background: #14171d;
}

html[data-theme="dark"] td,
html[data-theme="dark"] .order-meta,
html[data-theme="dark"] .carrier-details strong,
html[data-theme="dark"] .bases-list strong,
html[data-theme="dark"] .service-report strong {
    color: #e2e8f0;
}

html[data-theme="dark"] tbody tr:hover {
    background: #171d26;
}

html[data-theme="dark"] .order-column {
    background: #11141a;
}

html[data-theme="dark"] .service-report {
    background: #111827;
}

html[data-theme="dark"] .calendar-day.has-orders {
    background: #101722;
    border-color: rgba(0, 155, 245, .42);
    box-shadow: inset 0 0 0 1px rgba(0, 155, 245, .12);
}

html[data-theme="dark"] .calendar-day span,
html[data-theme="dark"] .calendar-day small,
html[data-theme="dark"] .photo-links a {
    background: rgba(0, 155, 245, .14);
    color: #7dd3fc;
}

html[data-theme="dark"] .column-header span {
    background: #0f131a;
    color: #cbd5e1;
}

html[data-theme="dark"] .badge.done {
    background: #1f2937;
    color: #cbd5e1;
}

html[data-theme="dark"] .badge.danger {
    background: rgba(220, 38, 38, .14);
    color: #fca5a5;
}

html[data-theme="dark"] .login-body {
    background:
        radial-gradient(circle at 18% 15%, rgba(0, 155, 245, .18), transparent 28rem),
        #090b10;
}

html[data-theme="dark"] .login-card {
    background: #14171d;
    border-color: #262b35;
}

@media (max-width: 700px) {
    .ticket-actions {
        min-width: 220px;
    }

    .ticket-preview div {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

.brand-logo {
    width: 112px;
    height: 44px;
    object-fit: contain;
    padding: 4px 6px;
    background: #fff;
}

.login-logo {
    width: min(240px, 100%);
}

.sidebar .brand {
    min-height: 70px;
    justify-content: center;
    padding: 0 0 16px;
    position: relative;
}

.sidebar .brand-logo {
    width: 104px;
    height: auto;
    max-height: 40px;
    padding: 0;
    border-radius: 0;
    background: transparent;
    object-fit: contain;
}

.sidebar .brand .mobile-menu-close {
    position: absolute;
    right: 0;
    top: 0;
}

.nav-link-disabled {
    cursor: default;
    opacity: 0.42;
}

.nav-link-disabled:hover {
    background: transparent;
    color: inherit;
}

.permission-picker {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    max-height: 360px;
    overflow-y: auto;
}

.permission-picker fieldset {
    display: grid;
    align-content: start;
    gap: 7px;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.permission-picker legend {
    padding: 0 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.permission-picker label {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 7px;
    font-size: 13px;
    line-height: 1.3;
}

.permission-picker input {
    margin: 1px 0 0;
}

.entity-activity-dialog {
    width: min(760px, calc(100vw - 32px));
    max-width: 760px;
    max-height: min(860px, calc(100vh - 32px));
    padding: 0;
    overflow: hidden;
}

/* Customer orders */
.customer-order-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.customer-order-summary .metric-card > div {
    grid-column: 1;
    grid-row: 1 / span 2;
}

.customer-order-summary .metric-card .metric-icon {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.compact-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.compact-toolbar input {
    width: min(360px, 44vw);
}

.customer-order-actions {
    flex-wrap: nowrap;
}

.catalog-admin-list {
    display: grid;
}

.catalog-admin-item {
    display: grid;
    grid-template-columns: 42px minmax(220px, 1fr) 110px minmax(170px, .5fr) auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
}

.catalog-admin-item:first-child {
    border-top: 0;
}

.catalog-product-icon {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 7px;
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 12%, var(--panel));
    flex: 0 0 auto;
}

.catalog-product-main,
.catalog-admin-item > div {
    display: grid;
    gap: 4px;
}

.catalog-admin-item span,
.catalog-admin-item small {
    color: var(--muted);
}

.catalog-product-dialog,
.customer-order-dialog,
.customer-order-preview-dialog {
    width: min(1040px, calc(100vw - 40px));
    max-width: 1040px;
    max-height: calc(100vh - 40px);
}

.dialog-heading,
.section-title-row,
.selected-product-title,
.order-preview-item-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.dialog-heading h2,
.section-title-row h3,
.order-product-picker h3,
.order-cart h3 {
    margin: 0;
}

.dialog-heading .eyebrow {
    display: block;
    margin-bottom: 5px;
}

.form-grid.three-columns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.catalog-builder-section {
    display: grid;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.section-title-row p {
    margin: 4px 0 0;
    color: var(--muted);
}

.builder-rows {
    display: grid;
    gap: 8px;
}

.builder-row {
    display: grid;
    gap: 8px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
}

.catalog-parameter-row {
    grid-template-columns: 1fr 1.2fr 130px 115px 1fr 1.2fr 1.4fr 42px;
}

.catalog-rule-row {
    grid-template-columns: 1.2fr 130px 1fr 100px 1fr 145px 100px 42px;
}

.builder-row input,
.builder-row select,
.builder-row textarea {
    min-width: 0;
}

.order-builder-layout {
    display: grid;
    grid-template-columns: minmax(320px, .8fr) minmax(420px, 1.2fr);
    gap: 18px;
    align-items: start;
}

.order-product-picker,
.order-cart {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.selected-product-info {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: color-mix(in srgb, var(--brand) 4%, var(--panel));
}

.selected-product-title {
    justify-content: flex-start;
}

.selected-product-title p {
    margin: 3px 0 0;
    color: var(--muted);
}

.dynamic-product-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.dynamic-product-fields label,
.customer-order-meta label {
    display: grid;
    gap: 6px;
}

.dynamic-product-fields label:has(textarea),
.dynamic-product-fields label:has([type="file"]) {
    grid-column: 1 / -1;
}

.item-quote {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    min-height: 48px;
    padding: 10px 12px;
    border-radius: 7px;
    background: color-mix(in srgb, var(--brand) 10%, var(--panel));
}

.item-quote > div {
    display: grid;
    gap: 3px;
}

.item-quote span,
.order-cart-item span,
.order-totals span,
.order-preview-meta span,
.order-preview-note > span {
    color: var(--muted);
}

.order-cart-items {
    display: grid;
    gap: 8px;
}

.order-cart-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto 38px;
    gap: 12px;
    align-items: center;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.order-cart-item > div {
    display: grid;
    gap: 3px;
}

.order-line-values {
    display: grid;
    grid-template-columns: repeat(3, minmax(118px, 1fr));
    gap: 0;
    min-width: 420px;
}

.order-line-values span {
    display: grid;
    gap: 4px;
    padding: 0 14px;
    border-left: 1px solid var(--line);
}

.order-line-values small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.order-line-values strong {
    color: var(--text);
    white-space: nowrap;
}

.order-line-values .order-line-gross strong {
    color: var(--brand);
}

.order-line-values.is-individual {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
    color: var(--muted);
}

.order-line-values.is-individual i {
    color: var(--brand);
}

.order-totals {
    display: grid;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.order-totals > div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.order-totals .order-total-main {
    padding-top: 9px;
    border-top: 1px solid var(--line);
    font-size: 18px;
}

.order-preview-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.order-preview-meta > div,
.order-preview-note {
    display: grid;
    gap: 5px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.order-detail-sidebar .order-preview-meta > div {
    padding: 10px 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
}

.order-detail-sidebar .order-preview-meta > div:last-child {
    border-bottom: 0;
}

.order-preview-note p {
    margin: 0;
}

.order-preview-items,
.linked-work-orders,
.order-status-history {
    display: grid;
    gap: 9px;
    margin-top: 18px;
}

.order-preview-item {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.order-product-name > span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-product-name b {
    padding: 2px 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    color: var(--brand);
    font-size: 11px;
}

.order-preview-item-heading > div {
    display: grid;
    gap: 4px;
}

.order-preview-item-heading span {
    color: var(--muted);
}

.order-preview-item dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 18px;
    margin: 12px 0 0;
}

.order-preview-item dl > div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding-top: 6px;
    border-top: 1px solid var(--line);
}

.order-preview-item dt {
    color: var(--muted);
}

.preview-totals {
    margin: 0;
    width: 100%;
}

.individual-price-summary {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center;
    gap: 8px !important;
    color: var(--muted);
}

.individual-price-summary i {
    color: var(--brand);
}

.linked-work-orders a,
.order-status-history > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    text-decoration: none;
}

.form-error {
    color: var(--danger) !important;
}

html[data-theme="dark"] .builder-row,
html[data-theme="dark"] .order-product-picker,
html[data-theme="dark"] .order-cart,
html[data-theme="dark"] .selected-product-info {
    background: #15181f;
    border-color: #2a303b;
}

@media (max-width: 1100px) {
    .catalog-parameter-row,
    .catalog-rule-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .catalog-parameter-row .icon-button,
    .catalog-rule-row .icon-button {
        justify-self: end;
    }

    .catalog-admin-item {
        grid-template-columns: 42px minmax(180px, 1fr) auto;
    }

    .catalog-admin-item > :nth-child(4),
    .catalog-admin-item > :nth-child(5) {
        grid-column: 2 / -1;
    }
}

@media (max-width: 820px) {
    .customer-order-summary,
    .form-grid.three-columns,
    .order-builder-layout,
    .order-preview-meta,
    .order-preview-item dl,
    .dynamic-product-fields {
        grid-template-columns: 1fr;
    }

    .compact-toolbar,
    .order-list-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .compact-toolbar input {
        width: 100%;
    }

    .catalog-admin-item {
        grid-template-columns: 38px 1fr;
    }

    .catalog-admin-item > :not(:first-child):not(:nth-child(2)) {
        grid-column: 2;
    }
}

@media (max-width: 560px) {
    .catalog-product-dialog,
    .customer-order-dialog,
    .customer-order-preview-dialog {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
    }

    .catalog-parameter-row,
    .catalog-rule-row {
        grid-template-columns: 1fr;
    }

    .order-cart-item {
        grid-template-columns: 34px 1fr 36px;
    }

    .order-cart-item .order-line-values {
        grid-column: 2;
        min-width: 0;
        text-align: left;
    }

    .item-quote {
        grid-template-columns: 1fr;
    }
}

.entity-activity-shell {
    display: grid;
    grid-template-rows: auto auto minmax(180px, 1fr) auto auto;
    max-height: min(860px, calc(100vh - 32px));
}

.entity-activity-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
}

.entity-activity-head h2,
.entity-activity-head p {
    margin: 0;
}

.entity-relations {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
}

.entity-relations-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.entity-relation-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    text-decoration: none;
}

.entity-relation-chip small {
    color: var(--muted);
}

.entity-timeline {
    min-height: 220px;
    padding: 8px 22px 18px;
    overflow-y: auto;
}

.entity-event {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
    position: relative;
    padding: 14px 0;
}

.entity-event:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 16px;
    top: 46px;
    bottom: -4px;
    width: 1px;
    background: var(--line);
}

.entity-event-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: rgba(0, 155, 245, 0.12);
    color: var(--brand);
    z-index: 1;
}

.entity-event-body {
    min-width: 0;
    padding: 1px 0;
}

.entity-event-body p {
    margin: 8px 0 0;
    line-height: 1.55;
}

.entity-event-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.entity-event-meta span {
    color: var(--muted);
    font-size: 12px;
}

.comment-visibility {
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--soft);
}

.comment-visibility.customer_visible {
    color: var(--brand);
    background: rgba(0, 155, 245, 0.12);
}

.activity-change {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 9px;
    color: var(--muted);
    font-size: 13px;
}

.activity-change strong {
    color: var(--ink);
}

.activity-attachments {
    display: grid;
    gap: 6px;
    margin-top: 10px;
}

.activity-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.activity-attachment a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--brand);
    text-decoration: none;
}

.activity-attachment a small {
    color: var(--muted);
}

.entity-event-actions {
    display: flex;
    gap: 7px;
    margin-top: 10px;
}

.entity-event-actions button {
    padding: 6px 9px;
    font-size: 12px;
}

.entity-comment-form,
.entity-attachment-form {
    display: grid;
    gap: 12px;
    padding: 16px 22px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.entity-comment-form textarea {
    resize: vertical;
    min-height: 84px;
}

.entity-attachment-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    padding-top: 12px;
}

html[data-theme="dark"] .entity-activity-head,
html[data-theme="dark"] .entity-comment-form,
html[data-theme="dark"] .entity-attachment-form {
    background: #12151b;
}

.automation-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.automation-summary-card {
    min-height: 104px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.automation-summary-card > div {
    display: grid;
    gap: 8px;
}

.automation-summary-card > div span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.automation-summary-card > div strong {
    color: var(--ink);
    font-size: 28px;
}

.automation-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(310px, .8fr);
    gap: 16px;
    align-items: start;
}

.automation-panel-head {
    gap: 18px;
}

.automation-panel-head p,
.automation-runs-panel .panel-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.automation-panel-head select {
    width: auto;
    min-width: 130px;
}

.automation-rules,
.automation-runs {
    display: grid;
}

.automation-rule {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    padding: 18px 20px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.automation-rule.is-enabled {
    box-shadow: inset 3px 0 0 var(--brand);
}

.automation-rule-main {
    min-width: 0;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 13px;
}

.automation-rule-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--soft);
    color: var(--brand);
}

.automation-rule-copy {
    min-width: 0;
}

.automation-rule-title {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.automation-rule-title strong {
    color: var(--ink);
    font-size: 15px;
}

.automation-rule-copy > p {
    margin: 5px 0 11px;
    color: var(--muted);
    font-size: 13px;
}

.automation-flow-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 12px;
}

.automation-flow-preview span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
}

.automation-flow-preview b {
    color: var(--brand);
    font-size: 10px;
}

.automation-flow-preview > i {
    color: #94a3b8;
    font-size: 10px;
}

.automation-rule-meta {
    min-width: 158px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    color: var(--muted);
    font-size: 11px;
}

.automation-rule-actions {
    display: flex;
    gap: 5px;
    margin-top: 7px;
}

.automation-rule-actions button {
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
}

.automation-runs-panel {
    position: sticky;
    top: 78px;
}

.automation-runs {
    max-height: 590px;
    overflow-y: auto;
}

.automation-run {
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-top: 1px solid var(--line);
}

.automation-run > div {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.automation-run strong,
.automation-run small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.automation-run strong {
    color: var(--ink);
    font-size: 12px;
}

.automation-run small {
    color: var(--muted);
    font-size: 10px;
}

.automation-run > p {
    grid-column: 2 / -1;
    margin: 0;
    color: #ef4444;
    font-size: 11px;
}

.automation-run-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #94a3b8;
}

.automation-run-dot.success { background: #10b981; }
.automation-run-dot.failed { background: #ef4444; }
.automation-run-dot.partial { background: #f59e0b; }
.automation-run-dot.running { background: var(--brand); }

.automation-empty {
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.automation-empty > i {
    color: var(--brand);
    font-size: 28px;
}

.automation-empty > span {
    max-width: 390px;
}

.automation-dialog {
    width: min(920px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100vh - 40px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
}

.automation-dialog::backdrop {
    background: rgba(4, 8, 15, .68);
    backdrop-filter: blur(3px);
}

.automation-form {
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 22px;
}

.automation-builder-section {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.automation-builder-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.automation-builder-head > div {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 3px 9px;
}

.automation-builder-head h3,
.automation-builder-head p {
    margin: 0;
}

.automation-builder-head h3 {
    color: var(--ink);
    font-size: 14px;
}

.automation-builder-head p {
    grid-column: 2;
    color: var(--muted);
    font-size: 11px;
}

.automation-step {
    grid-row: 1 / 3;
    padding: 5px 7px;
    border-radius: 5px;
    background: rgba(245, 158, 11, .14);
    color: #d97706;
    font-size: 10px;
    font-weight: 900;
}

.automation-step.action {
    background: var(--soft);
    color: var(--brand);
}

.automation-condition-list,
.automation-action-list {
    display: grid;
    gap: 9px;
}

.automation-condition-row {
    display: grid;
    grid-template-columns: minmax(160px, 1.1fr) minmax(145px, .8fr) minmax(130px, 1fr) 36px;
    gap: 8px;
    align-items: end;
}

.automation-condition-row > button,
.automation-action-top > button {
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
}

.automation-action-row {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
}

.automation-action-top {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 36px;
    gap: 8px;
    align-items: center;
    padding: 9px;
    border-bottom: 1px solid var(--line);
}

.automation-action-handle {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: var(--soft);
    color: var(--brand);
}

.automation-action-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
}

.automation-action-fields .span-2 {
    grid-column: 1 / -1;
}

.automation-action-fields select[multiple] {
    min-height: 92px;
}

.automation-options {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    padding: 4px 0;
}

@media (max-width: 1050px) {
    .automation-layout {
        grid-template-columns: 1fr;
    }

    .automation-runs-panel {
        position: static;
    }
}

@media (max-width: 760px) {
    .automation-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .automation-rule {
        grid-template-columns: 1fr;
    }

    .automation-rule-meta {
        align-items: flex-start;
        padding-left: 55px;
    }

    .automation-condition-row,
    .automation-action-fields {
        grid-template-columns: 1fr;
    }

    .automation-condition-row > button {
        justify-self: end;
    }

    .automation-action-fields .span-2 {
        grid-column: auto;
    }
}

@media (max-width: 560px) {
    .global-search-dialog {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 24px);
        margin-top: 12px;
    }

    .global-search-shell {
        max-height: calc(100vh - 24px);
    }

    .global-search-input-row {
        min-height: 58px;
        padding: 0 13px;
    }

    .global-search-input-row input {
        min-height: 56px;
        font-size: 14px;
    }

    .global-search-results {
        max-height: calc(100vh - 132px);
    }

    .global-search-footer {
        display: none;
    }

    .entity-activity-dialog {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
    }

    .entity-activity-shell {
        max-height: calc(100vh - 16px);
    }

    .entity-activity-head,
    .entity-timeline,
    .entity-comment-form,
    .entity-attachment-form {
        padding-left: 14px;
        padding-right: 14px;
    }

    .entity-attachment-form {
        grid-template-columns: 1fr;
    }

    .permission-picker {
        grid-template-columns: 1fr;
    }
}

/* PT Desk workspace UX */
.app-body {
    grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
    padding: 12px 10px;
    gap: 10px;
}

.sidebar .brand {
    min-height: 58px;
    padding-bottom: 10px;
}

.sidebar .brand-logo {
    width: 96px;
    max-height: 36px;
}

.sidebar nav {
    gap: 12px;
    padding-top: 2px;
}

.nav-section {
    gap: 2px;
}

.nav-section p {
    margin-bottom: 3px;
    padding: 0 9px;
    font-size: 9px;
}

.nav-link {
    min-height: 33px;
    padding: 3px 8px;
    font-size: 13px;
}

.main {
    min-width: 0;
}

.page-heading {
    min-height: 48px;
    margin-bottom: 14px;
    align-items: center;
}

.page-heading h1 {
    margin: 2px 0 0;
    font-size: 27px;
    line-height: 1.15;
    letter-spacing: 0;
}

.page-heading p:not(.eyebrow) {
    max-width: 720px;
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.page-heading .primary {
    min-height: 36px;
    padding: 8px 13px;
}

.module-tabs {
    display: flex;
    gap: 18px;
    min-height: 39px;
    margin: -2px 0 12px;
    padding: 0 2px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
}

.module-tabs a {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 0 2px 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
    text-decoration: none;
}

.module-tabs a:hover,
.module-tabs a.active {
    color: var(--ink);
}

.module-tabs a.active::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: var(--brand);
}

.toolbar,
.task-toolbar,
.project-toolbar,
.knowledge-toolbar,
.automation-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    box-shadow: none;
}

.toolbar input,
.toolbar select,
.task-toolbar input,
.task-toolbar select,
.project-toolbar input,
.project-toolbar select,
.knowledge-toolbar input,
.knowledge-toolbar select,
.automation-filters input,
.automation-filters select {
    min-height: 34px;
    height: 34px;
    border-radius: 6px;
    font-size: 12px;
}

.toolbar input:first-child,
.task-toolbar input:first-child,
.project-toolbar input:first-child,
.knowledge-toolbar input:first-child,
.automation-filters input:first-child {
    flex: 1 1 320px;
}

.summary-grid {
    gap: 10px;
    margin-bottom: 12px;
}

.summary-card,
.metric-card {
    min-height: 82px;
    padding: 13px 14px;
    border-radius: 7px;
}

.panel,
.order-column,
.calendar-panel,
.carrier-card,
.admin-card {
    border-radius: 7px;
    box-shadow: none;
}

.panel > .section-heading,
.panel-heading,
.panel-header {
    min-height: 54px;
    padding: 12px 14px;
}

.panel > .section-heading h2,
.panel-heading h2,
.panel-header h2 {
    font-size: 15px;
}

.panel > .section-heading p,
.panel-heading p {
    margin-top: 3px;
    font-size: 12px;
}

.table-wrap {
    overflow: auto;
}

table {
    font-size: 12px;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 9px 12px;
    background: var(--surface);
    font-size: 10px;
}

td {
    padding: 10px 12px;
    vertical-align: middle;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 43px;
    padding: 7px 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
}

.table-pagination > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-pagination button {
    width: 30px;
    min-width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 6px;
}

.table-pagination strong {
    min-width: 46px;
    color: var(--ink);
    text-align: center;
}

.tickets-table th:nth-child(2),
.tickets-table td:nth-child(2) {
    min-width: 200px;
}

.tickets-table th:last-child,
.tickets-table td:last-child {
    width: 160px;
}

.ticket-actions {
    min-width: 145px;
    gap: 5px;
}

.ticket-actions button,
.ticket-actions .button-link {
    min-height: 29px;
    padding: 5px 7px;
    font-size: 11px;
}

.detail-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 11px;
}

.detail-breadcrumbs i {
    font-size: 8px;
}

.entity-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 14px;
    align-items: start;
}

.entity-detail-main,
.entity-detail-sidebar {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.entity-detail-sidebar {
    position: sticky;
    top: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
}

.entity-detail-sidebar .task-detail-meta,
.entity-detail-sidebar .project-detail-summary,
.entity-detail-sidebar .order-preview-meta {
    grid-template-columns: 1fr;
    gap: 0;
}

.entity-detail-sidebar .task-detail-meta > div,
.entity-detail-sidebar .project-detail-summary > div,
.entity-detail-sidebar .order-preview-meta > div {
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}

.project-detail-sidebar {
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.project-sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 15px;
    border-bottom: 1px solid var(--line);
}

.project-sidebar-heading > span,
.project-sidebar-caption,
.project-sidebar-label > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.project-sidebar-heading .badge {
    flex: 0 0 auto;
    padding: 4px 9px;
}

.entity-detail-sidebar .project-detail-summary {
    display: grid;
    gap: 0;
    margin: 0;
}

.entity-detail-sidebar .project-detail-summary > .project-summary-item {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 0;
    padding: 12px 15px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
}

.project-summary-item > i {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 6px;
    background: color-mix(in srgb, var(--brand) 10%, transparent);
    color: var(--brand);
    font-size: 12px;
}

.project-summary-item > div {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.project-summary-item strong {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-sidebar-section {
    display: grid;
    gap: 10px;
    padding: 14px 15px;
    border-bottom: 1px solid var(--line);
}

.project-sidebar-section:last-child {
    border-bottom: 0;
}

.project-sidebar-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.project-sidebar-label > strong {
    color: var(--brand);
    font-size: 12px;
}

.project-sidebar-section .project-progress {
    gap: 0;
}

.project-sidebar-section .project-progress > strong {
    display: none;
}

.project-sidebar-section .project-progress > div {
    height: 6px;
}

.project-sidebar-section .task-tags {
    gap: 6px;
}

.order-detail-layout {
    grid-template-columns: minmax(0, 1fr) 230px;
    gap: 20px;
}

.order-detail-main {
    gap: 4px;
}

.order-detail-sidebar {
    padding: 14px;
}

.order-detail-sidebar .preview-totals {
    margin-top: 4px;
}

.order-status-history > div {
    display: grid;
    grid-template-columns: 155px minmax(0, 1fr) 160px;
    align-items: center;
}

.order-status-history > div > :last-child {
    text-align: right;
}

.admin-tabs {
    gap: 14px;
}

.admin-tabs a {
    gap: 7px;
}

.admin-tabs a i {
    font-size: 11px;
}

.admin-module-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.admin-module-card {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto 12px;
    align-items: center;
    gap: 12px;
    min-height: 94px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    color: var(--ink);
    text-decoration: none;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.admin-module-card:hover {
    border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
    background: color-mix(in srgb, var(--brand) 4%, var(--panel));
    transform: translateY(-1px);
}

.admin-module-card > span {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: var(--soft);
    color: var(--brand);
}

.admin-module-card h2,
.admin-module-card p {
    margin: 0;
}

.admin-module-card h2 {
    font-size: 14px;
}

.admin-module-card p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.admin-module-card > strong {
    min-width: 28px;
    color: var(--ink);
    font-size: 18px;
    text-align: right;
}

.admin-module-card > i {
    color: var(--muted);
    font-size: 10px;
}

[data-admin-page] > .admin-section {
    max-width: 1180px;
}

[data-admin-page] .inline-form {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

[data-admin-page] .admin-list {
    max-height: none;
}

html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .task-toolbar,
html[data-theme="dark"] .project-toolbar,
html[data-theme="dark"] .knowledge-toolbar,
html[data-theme="dark"] .automation-filters {
    background: var(--panel);
}

@media (max-width: 900px) {
    .knowledge-card {
        grid-template-columns: 1fr;
    }

    .knowledge-card-footer {
        align-items: center;
        flex-direction: row;
        justify-content: flex-start;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .entity-detail-layout {
        grid-template-columns: 1fr;
    }

    .entity-detail-sidebar {
        position: static;
        grid-row: 1;
    }

    .order-preview-item-heading {
        flex-direction: column;
    }

    .order-preview-item-heading .order-line-values {
        width: 100%;
        min-width: 0;
    }

    .admin-module-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-body {
        grid-template-columns: 1fr;
    }

    .toolbar,
    .task-toolbar,
    .project-toolbar,
    .knowledge-toolbar,
    .automation-filters {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar input:first-child,
    .task-toolbar input:first-child,
    .project-toolbar input:first-child,
    .knowledge-toolbar input:first-child,
    .automation-filters input:first-child {
        flex-basis: auto;
        width: 100%;
    }

    .admin-module-grid {
        grid-template-columns: 1fr;
    }
}

/* Visual polish pass */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.sidebar nav {
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: #303642 transparent;
}

.sidebar nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar nav::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #303642;
}

.logout-form {
    flex: 0 0 auto;
    margin-top: 0;
}

.carrier-surface {
    min-width: 0;
}

.carrier-list {
    gap: 10px;
    padding: 0;
}

.carrier-card {
    padding: 15px 16px;
    border-radius: 7px;
}

.carrier-card + .carrier-card {
    margin-top: 0;
}

.bases-list {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
}

.warehouse-table {
    table-layout: auto;
    font-size: 11px;
}

.warehouse-table th:nth-child(1),
.warehouse-table td:nth-child(1) {
    width: 112px;
    white-space: nowrap;
}

.warehouse-table th:nth-child(2),
.warehouse-table td:nth-child(2) {
    width: 90px;
}

.warehouse-table th:nth-child(4),
.warehouse-table td:nth-child(4),
.warehouse-table th:nth-child(5),
.warehouse-table td:nth-child(5) {
    width: 90px;
}

.warehouse-table th:nth-child(6),
.warehouse-table td:nth-child(6) {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.warehouse-table th:last-child,
.warehouse-table td:last-child {
    width: 180px;
}

.warehouse-table td.actions {
    display: table-cell;
    white-space: nowrap;
}

.warehouse-table td.actions button {
    min-height: 29px;
    padding: 5px 7px;
    font-size: 11px;
}

.warehouse-table td.actions button + button {
    margin-left: 4px;
}

.orders-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 14px;
}

.calendar-grid {
    gap: 5px;
    padding: 10px;
}

.calendar-day {
    min-height: 64px;
}

.calendar-panel .panel-header {
    gap: 8px;
}

.calendar-panel .panel-header h2 {
    font-size: 14px;
    white-space: nowrap;
}

.calendar-panel .panel-header button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 12px;
}

.admin-section {
    overflow: hidden;
    padding-bottom: 0;
}

.admin-section .panel-header {
    border-bottom: 1px solid var(--line);
}

.admin-section .panel-header h2,
.admin-section .panel-header p {
    margin: 0;
}

.admin-section .panel-header p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

[data-admin-page] .inline-form {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    align-items: end;
    gap: 9px;
}

[data-admin-page] .inline-form > button:last-child {
    justify-self: start;
}

[data-admin-page] .admin-list {
    gap: 0;
    padding: 0;
}

[data-admin-page] .admin-row {
    min-height: 66px;
    padding: 11px 14px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

[data-admin-page] .admin-row:last-child {
    border-bottom: 0;
}

.admin-row-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.admin-row-copy > strong {
    color: var(--ink);
    font-size: 13px;
}

.admin-row-copy > span {
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-row-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.admin-row-tags em {
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--brand);
    font-size: 9px;
    font-style: normal;
    font-weight: 800;
}

.icon-text-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.danger-subtle {
    color: #ef4444;
}

.danger-subtle:hover {
    border-color: rgba(239, 68, 68, .45);
    background: rgba(239, 68, 68, .08);
}

.role-permissions-dialog {
    width: min(920px, calc(100vw - 32px));
    max-width: 920px;
}

.customer-order-quote-dialog {
    width: min(520px, calc(100vw - 24px));
    max-width: 520px;
}

.dialog-lead {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.manual-quote-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
}

.manual-quote-summary > div {
    display: grid;
    gap: 5px;
    padding: 12px;
    border-right: 1px solid var(--line);
}

.manual-quote-summary > div:last-child {
    border-right: 0;
}

.manual-quote-summary span {
    color: var(--muted);
    font-size: 11px;
}

.manual-quote-summary strong {
    white-space: nowrap;
}

.manual-quote-summary > div:last-child strong {
    color: var(--brand);
}

@media (max-width: 520px) {
    .manual-quote-summary {
        grid-template-columns: 1fr;
    }

    .manual-quote-summary > div {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
}

.role-edit-basics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.permission-picker-edit {
    max-height: min(470px, 55vh);
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
}

.permission-picker-edit fieldset {
    min-width: 0;
}

@media (max-width: 620px) {
    .role-edit-basics {
        grid-template-columns: 1fr;
    }
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--brand) 70%, white);
    outline-offset: 2px;
}

html[data-theme="dark"] .carrier-card,
html[data-theme="dark"] .bases-list {
    background: var(--panel);
}

html[data-theme="dark"] [data-admin-page] .admin-row {
    background: transparent;
    box-shadow: none;
}

@media (max-width: 1200px) {
    [data-admin-page] .inline-form {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        height: auto;
        overflow-y: auto;
    }

    .sidebar nav {
        overflow: visible;
    }

    [data-admin-page] .inline-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    [data-admin-page] .inline-form {
        grid-template-columns: 1fr;
    }

    .carrier-details {
        grid-template-columns: 1fr;
    }

    .admin-row-copy > span {
        white-space: normal;
    }
}

/* Orders calendar page and final layout alignment */
[data-admin-page],
[data-admin-page] > .admin-section {
    width: 100%;
    max-width: none;
}

.customer-catalog-admin {
    width: 100%;
    margin-top: 14px;
}

.catalog-product-icon {
    overflow: hidden;
    font-size: 16px;
    line-height: 1;
}

.catalog-product-icon i {
    display: block;
    width: 1em;
    line-height: 1;
    text-align: center;
}

.catalog-admin-item .table-actions {
    justify-content: flex-end;
}

.orders-calendar-page {
    position: static;
    width: 100%;
}

.orders-calendar-page .panel-header {
    min-height: 62px;
    padding: 13px 16px;
}

.orders-calendar-page .panel-header h2 {
    font-size: 17px;
}

.orders-calendar-page .calendar-weekdays {
    padding: 14px 14px 4px;
}

.orders-calendar-page .calendar-grid {
    gap: 7px;
    padding: 10px 14px 14px;
}

.orders-calendar-page .calendar-day {
    width: 100%;
    min-width: 0;
    min-height: 112px;
    padding: 10px;
    align-content: start;
    justify-items: stretch;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.orders-calendar-page .calendar-day:hover {
    border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
    background: color-mix(in srgb, var(--brand) 5%, var(--panel));
}

.orders-calendar-page .calendar-day strong {
    font-size: 14px;
}

.calendar-day-dialog {
    width: min(760px, calc(100vw - 32px));
    max-width: 760px;
}

.calendar-day-orders {
    display: grid;
    gap: 9px;
}

.calendar-order-item {
    display: grid;
    gap: 10px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
}

.calendar-order-heading,
.calendar-order-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calendar-order-heading {
    justify-content: space-between;
}

.calendar-order-heading > div {
    display: grid;
    gap: 3px;
}

.calendar-order-heading span,
.calendar-order-meta,
.calendar-order-item p,
.calendar-day-empty span {
    color: var(--muted);
}

.calendar-order-meta {
    flex-wrap: wrap;
    font-size: 12px;
}

.calendar-order-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.calendar-order-item p {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
}

.calendar-day-empty {
    display: grid;
    place-items: center;
    gap: 7px;
    min-height: 180px;
    padding: 24px;
    text-align: center;
}

.calendar-day-empty i {
    color: var(--brand);
    font-size: 28px;
}

html[data-theme="dark"] .calendar-order-item {
    background: #15181f;
}

@media (max-width: 760px) {
    .orders-calendar-page .calendar-grid {
        gap: 3px;
        padding: 7px;
    }

    .orders-calendar-page .calendar-day {
        min-height: 72px;
        padding: 6px;
    }

    .orders-calendar-page .calendar-day span,
    .orders-calendar-page .calendar-day small {
        padding: 2px 3px;
        font-size: 9px;
    }

    .calendar-order-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
    }
}
