/* ===================================================================
   PKC Support Desk — panel styles.

   Layered on top of the INSPINIA theme already in /assets, never
   replacing it: the shell, grid and components come from the theme,
   and everything here is the desk's own vocabulary — ticket badges,
   the queue, the conversation and the SLA signals.

   Every rule is prefixed .sd- so nothing here can collide with the
   theme's own classes.
   =================================================================== */

:root {
    --sd-bg: #f6f7fb;
    --sd-surface: #ffffff;
    --sd-border: #e6e8f0;
    --sd-border-strong: #d4d7e3;
    --sd-text: #1e2434;
    --sd-muted: #6b7280;
    --sd-faint: #9aa1ad;

    --sd-primary: #4f46e5;
    --sd-primary-soft: #eef2ff;

    --sd-success: #059669;
    --sd-success-soft: #ecfdf5;
    --sd-warn: #d97706;
    --sd-warn-soft: #fffbeb;
    --sd-danger: #dc2626;
    --sd-danger-soft: #fef2f2;
    --sd-info: #0891b2;
    --sd-info-soft: #ecfeff;

    --sd-radius: 10px;
    --sd-radius-sm: 7px;
    --sd-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --sd-shadow-lg: 0 8px 24px rgba(16, 24, 40, .10);
}

html[data-bs-theme="dark"] {
    --sd-bg: #12151d;
    --sd-surface: #1a1e28;
    --sd-border: #2a3040;
    --sd-border-strong: #39415a;
    --sd-text: #e7eaf0;
    --sd-muted: #98a1b3;
    --sd-faint: #6d7688;

    --sd-primary-soft: #1e2140;
    --sd-success-soft: #11291f;
    --sd-warn-soft: #2b2113;
    --sd-danger-soft: #2d1618;
    --sd-info-soft: #10262b;

    --sd-shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --sd-shadow-lg: 0 8px 24px rgba(0, 0, 0, .45);
}

.sd-page {
    padding-block: 18px;
    color: var(--sd-text);
}

/* ── Shell touches ────────────────────────────────────────────── */

.sd-sidenav-title {
    padding: 14px 20px 6px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    opacity: .55;
}

.sd-sidenav-footer {
    padding: 10px 20px;
    font-size: .7rem;
    opacity: .6;
    display: flex;
    align-items: center;
    gap: 7px;
}

.sd-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--sd-success);
    display: inline-block;
}

.sd-nav-ext {
    margin-left: auto;
    font-size: .8rem;
    opacity: .5;
}

.sd-topsearch {
    position: relative;
    width: 340px;
}

.sd-topsearch i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sd-faint);
    font-size: 1rem;
}

.sd-topsearch .form-control {
    padding-left: 34px;
    height: 38px;
    border-radius: 20px;
    font-size: .82rem;
    background: var(--sd-bg);
    border-color: transparent;
}

.sd-topsearch .form-control:focus {
    background: var(--sd-surface);
    border-color: var(--sd-primary);
    box-shadow: none;
}

.sd-user-name { font-size: .82rem; font-weight: 600; line-height: 1.2; }
.sd-user-role { font-size: .68rem; color: var(--sd-muted); line-height: 1.2; }

.sd-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .02em;
    background: var(--sd-primary);
    flex-shrink: 0;
}

.sd-avatar-sm { width: 28px; height: 28px; font-size: .64rem; }
.sd-avatar-lg { width: 46px; height: 46px; font-size: .95rem; }
.sd-avatar-customer { background: #0891b2; }

.sd-bell-count {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--sd-danger);
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
}

/* ── Notifications ────────────────────────────────────────────── */

.sd-notify-menu { width: 340px; padding: 0; overflow: hidden; }

.sd-notify-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 14px;
    border-bottom: 1px solid var(--sd-border);
    font-size: .8rem;
    font-weight: 600;
}

.sd-notify-body { max-height: 380px; overflow-y: auto; }

.sd-notify-item {
    display: flex;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--sd-border);
    text-decoration: none;
    color: inherit;
}

.sd-notify-item:hover { background: var(--sd-bg); }
.sd-notify-item.unread { background: var(--sd-primary-soft); }
.sd-notify-item .t { font-size: .78rem; font-weight: 600; }
.sd-notify-item .b { font-size: .72rem; color: var(--sd-muted); }
.sd-notify-item .a { font-size: .66rem; color: var(--sd-faint); margin-top: 2px; }

.sd-notify-empty {
    padding: 28px 14px;
    text-align: center;
    color: var(--sd-faint);
    font-size: .78rem;
}

/* ── Page headers ─────────────────────────────────────────────── */

.sd-head {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.sd-head h1 {
    font-size: 1.22rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.25;
}

.sd-head .sd-sub {
    font-size: .78rem;
    color: var(--sd-muted);
    margin-top: 2px;
}

.sd-head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.sd-head-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--sd-radius);
    background: var(--sd-primary-soft);
    color: var(--sd-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.sd-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Cards ────────────────────────────────────────────────────── */

.sd-card {
    background: var(--sd-surface);
    border: 1px solid var(--sd-border);
    border-radius: var(--sd-radius);
    box-shadow: var(--sd-shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

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

.sd-card-head h2,
.sd-card-head h3 {
    font-size: .88rem;
    font-weight: 650;
    margin: 0;
}

.sd-card-body { padding: 16px; }
.sd-card-body.flush { padding: 0; }
.sd-card-foot {
    padding: 11px 16px;
    border-top: 1px solid var(--sd-border);
    background: var(--sd-bg);
}

/* ── Stat tiles ───────────────────────────────────────────────── */

.sd-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.sd-stat {
    background: var(--sd-surface);
    border: 1px solid var(--sd-border);
    border-radius: var(--sd-radius);
    box-shadow: var(--sd-shadow);
    padding: 14px 16px;
    display: block;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, transform .15s;
}

a.sd-stat:hover {
    border-color: var(--sd-primary);
    transform: translateY(-1px);
    color: inherit;
}

.sd-stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sd-stat-label {
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--sd-muted);
}

.sd-stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: var(--sd-primary-soft);
    color: var(--sd-primary);
}

.sd-stat-value { font-size: 1.62rem; font-weight: 700; line-height: 1; }
.sd-stat-note { font-size: .7rem; color: var(--sd-faint); margin-top: 5px; }

.sd-stat.is-danger .sd-stat-icon { background: var(--sd-danger-soft); color: var(--sd-danger); }
.sd-stat.is-danger .sd-stat-value { color: var(--sd-danger); }
.sd-stat.is-warn .sd-stat-icon { background: var(--sd-warn-soft); color: var(--sd-warn); }
.sd-stat.is-success .sd-stat-icon { background: var(--sd-success-soft); color: var(--sd-success); }
.sd-stat.is-info .sd-stat-icon { background: var(--sd-info-soft); color: var(--sd-info); }

/* ── Badges ───────────────────────────────────────────────────── */

.sd-badge,
.sd-pri,
.sd-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: .69rem;
    font-weight: 600;
    line-height: 1.55;
    white-space: nowrap;
}

.sd-badge-open       { background: var(--sd-info-soft);    color: var(--sd-info); }
.sd-badge-progress   { background: var(--sd-primary-soft); color: var(--sd-primary); }
.sd-badge-awaiting   { background: var(--sd-warn-soft);    color: var(--sd-warn); }
.sd-badge-hold       { background: #f1f3f7;                color: var(--sd-muted); }
.sd-badge-resolved   { background: var(--sd-success-soft); color: var(--sd-success); }
.sd-badge-closed     { background: #eef0f4;                color: var(--sd-faint); }
.sd-badge-reopened   { background: var(--sd-danger-soft);  color: var(--sd-danger); }

html[data-bs-theme="dark"] .sd-badge-hold,
html[data-bs-theme="dark"] .sd-badge-closed { background: #232838; }

.sd-pri::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.sd-pri-critical { background: var(--sd-danger-soft);  color: var(--sd-danger); }
.sd-pri-high     { background: var(--sd-warn-soft);    color: var(--sd-warn); }
.sd-pri-medium   { background: var(--sd-info-soft);    color: var(--sd-info); }
.sd-pri-low      { background: #f1f3f7;                color: var(--sd-muted); }

html[data-bs-theme="dark"] .sd-pri-low { background: #232838; }

.sd-chip {
    background: var(--sd-bg);
    color: var(--sd-muted);
    border: 1px solid var(--sd-border);
    font-weight: 500;
}

.sd-sla-ok   { color: var(--sd-muted); }
.sd-sla-warn { color: var(--sd-warn); font-weight: 600; }
.sd-sla-late { color: var(--sd-danger); font-weight: 700; }

/* ── Queue rail ───────────────────────────────────────────────── */

.sd-queue { display: grid; grid-template-columns: 208px 1fr; gap: 16px; align-items: start; }

/* A grid item's automatic minimum size is its content, so a wide table or a
   long chip strip would push the column — and the whole page — past the
   viewport instead of scrolling inside it. This is what lets them shrink. */
.sd-queue > * { min-width: 0; }

@media (max-width: 991px) {
    .sd-queue { grid-template-columns: 1fr; }
}

.sd-views {
    background: var(--sd-surface);
    border: 1px solid var(--sd-border);
    border-radius: var(--sd-radius);
    box-shadow: var(--sd-shadow);
    padding: 7px;
    position: sticky;
    top: 78px;
}

@media (max-width: 991px) {
    .sd-views { position: static; display: flex; gap: 6px; overflow-x: auto; }
}

.sd-view {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 11px;
    border-radius: var(--sd-radius-sm);
    font-size: .8rem;
    font-weight: 500;
    color: var(--sd-text);
    text-decoration: none;
    white-space: nowrap;
}

.sd-view:hover { background: var(--sd-bg); color: var(--sd-text); }

.sd-view.active {
    background: var(--sd-primary-soft);
    color: var(--sd-primary);
    font-weight: 650;
}

.sd-view i { font-size: 1rem; opacity: .75; }

.sd-view .n {
    margin-left: auto;
    font-size: .68rem;
    font-weight: 700;
    background: var(--sd-bg);
    color: var(--sd-muted);
    border-radius: 9px;
    padding: 1px 6px;
    min-width: 21px;
    text-align: center;
}

.sd-view.active .n { background: var(--sd-primary); color: #fff; }
.sd-view.is-danger .n { background: var(--sd-danger-soft); color: var(--sd-danger); }

/* ── Filters ──────────────────────────────────────────────────── */

.sd-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    align-items: end;
}

.sd-field label {
    display: block;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--sd-muted);
    margin-bottom: 4px;
}

.sd-field .form-control,
.sd-field .form-select {
    height: 36px;
    font-size: .82rem;
    border-radius: var(--sd-radius-sm);
    border-color: var(--sd-border-strong);
}

.sd-field textarea.form-control { height: auto; }

/* ── Tables ───────────────────────────────────────────────────── */

.sd-table { width: 100%; border-collapse: collapse; font-size: .82rem; }

.sd-table thead th {
    background: var(--sd-bg);
    border-bottom: 1px solid var(--sd-border);
    padding: 9px 12px;
    text-align: left;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--sd-muted);
    white-space: nowrap;
}

.sd-table thead th a { color: inherit; text-decoration: none; }
.sd-table thead th a:hover { color: var(--sd-primary); }

.sd-table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--sd-border);
    vertical-align: middle;
}

.sd-table tbody tr:last-child td { border-bottom: 0; }
.sd-table tbody tr:hover { background: var(--sd-bg); }
.sd-table tbody tr.is-overdue { box-shadow: inset 3px 0 0 var(--sd-danger); }
.sd-table tbody tr.is-unread { background: var(--sd-primary-soft); }

.sd-ticket-no {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .74rem;
    font-weight: 700;
    color: var(--sd-primary);
    text-decoration: none;
    /* A ticket number is one token — it is quoted on the phone and in
       e-mail, so it must never be broken across lines. */
    white-space: nowrap;
}

.sd-ticket-no:hover { text-decoration: underline; }

.sd-subject {
    color: var(--sd-text);
    font-weight: 550;
    text-decoration: none;
    display: block;
    max-width: 440px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sd-subject:hover { color: var(--sd-primary); }

.sd-meta { font-size: .69rem; color: var(--sd-faint); }
.sd-meta i { font-size: .8rem; vertical-align: -1px; }

/* Desktop column behaviour for the queue. Without these a long company name
   wraps onto four lines, which stretches the whole table past the viewport
   and pushes the last column out of sight. */
@media (min-width: 992px) {
    /* Measured at 1440: the row wants ~996px in a ~939px column, and Subject
       and Client are the two that give the width back cheapest — both keep
       their full text in a title attribute. */
    .sd-table-cards td.sd-cell-lead-last { max-width: 235px; }
    .sd-table-cards td.sd-cell-lead-last .sd-subject { max-width: 100%; }

    .sd-table-cards td[data-label="Client"] { max-width: 125px; }

    .sd-table-cards td[data-label="Client"] > div {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sd-table-cards td[data-label="SLA"],
    .sd-table-cards td[data-label="Activity"],
    .sd-table-cards td[data-label="Last seen"] { white-space: nowrap; }
}

/* Between the card breakpoint and a wide screen there is room for a table
   but not for every column, so the least critical one steps aside. It comes
   back on a wide monitor, and it is always present in card mode. */
@media (min-width: 992px) and (max-width: 1499px) {
    .sd-table .sd-col-wide { display: none; }
}

.sd-unread-dot {
    display: inline-block;
    min-width: 17px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--sd-danger);
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    text-align: center;
    line-height: 17px;
}

/* ── Empty state ──────────────────────────────────────────────── */

.sd-empty { padding: 52px 20px; text-align: center; color: var(--sd-muted); }
.sd-empty i { font-size: 2.6rem; color: var(--sd-faint); display: block; margin-bottom: 10px; }
.sd-empty h6 { font-size: .92rem; font-weight: 650; color: var(--sd-text); margin-bottom: 5px; }
.sd-empty p { font-size: .8rem; margin: 0; }

/* ── Ticket detail ────────────────────────────────────────────── */

.sd-detail { display: grid; grid-template-columns: 1fr 318px; gap: 16px; align-items: start; }
.sd-detail > * { min-width: 0; }

@media (max-width: 1199px) {
    .sd-detail { grid-template-columns: 1fr; }
}

.sd-ticket-head {
    background: var(--sd-surface);
    border: 1px solid var(--sd-border);
    border-radius: var(--sd-radius);
    box-shadow: var(--sd-shadow);
    padding: 16px;
    margin-bottom: 16px;
}

.sd-ticket-head h1 { font-size: 1.1rem; font-weight: 650; margin: 6px 0 9px; line-height: 1.4; }
.sd-ticket-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.sd-quickbar {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 13px;
    padding-top: 13px;
    border-top: 1px solid var(--sd-border);
}

/* ── Conversation ─────────────────────────────────────────────── */

.sd-thread { padding: 16px; max-height: 620px; overflow-y: auto; }

.sd-msg { display: flex; gap: 11px; margin-bottom: 16px; }
.sd-msg:last-child { margin-bottom: 0; }
.sd-msg-body { min-width: 0; flex: 1; }

.sd-msg-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.sd-msg-who { font-size: .8rem; font-weight: 650; }
.sd-msg-when { font-size: .68rem; color: var(--sd-faint); }

.sd-msg-tag {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 4px;
}

.sd-msg-tag.customer { background: var(--sd-info-soft); color: var(--sd-info); }
.sd-msg-tag.agent { background: var(--sd-primary-soft); color: var(--sd-primary); }
.sd-msg-tag.note { background: var(--sd-warn-soft); color: var(--sd-warn); }

.sd-msg-text {
    background: var(--sd-bg);
    border: 1px solid var(--sd-border);
    border-radius: var(--sd-radius-sm);
    padding: 10px 13px;
    font-size: .84rem;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.sd-msg.is-agent .sd-msg-text { background: var(--sd-primary-soft); border-color: transparent; }

.sd-msg.is-note .sd-msg-text {
    background: var(--sd-warn-soft);
    border-color: rgba(217, 119, 6, .28);
    border-left: 3px solid var(--sd-warn);
}

.sd-msg.is-system { justify-content: center; }

.sd-msg.is-system .sd-msg-text {
    background: transparent;
    border: 0;
    text-align: center;
    color: var(--sd-faint);
    font-size: .74rem;
    font-style: italic;
    padding: 3px 0;
}

.sd-msg.is-system .sd-msg-head { display: none; }

.sd-msg-files { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; }

.sd-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--sd-border);
    border-radius: var(--sd-radius-sm);
    background: var(--sd-surface);
    font-size: .74rem;
    color: var(--sd-text);
    text-decoration: none;
    max-width: 250px;
}

.sd-file:hover { border-color: var(--sd-primary); color: var(--sd-primary); }
.sd-file i { font-size: .95rem; color: var(--sd-muted); }
.sd-file .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-file .s { color: var(--sd-faint); font-size: .66rem; flex-shrink: 0; }

/* ── Composer ─────────────────────────────────────────────────── */

.sd-composer { border-top: 1px solid var(--sd-border); background: var(--sd-surface); }

.sd-composer-tabs { display: flex; gap: 2px; padding: 9px 16px 0; }

.sd-composer-tab {
    border: 0;
    background: transparent;
    padding: 7px 14px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--sd-muted);
    border-radius: var(--sd-radius-sm) var(--sd-radius-sm) 0 0;
    cursor: pointer;
}

.sd-composer-tab.active { background: var(--sd-primary-soft); color: var(--sd-primary); }
.sd-composer-tab.note-tab.active { background: var(--sd-warn-soft); color: var(--sd-warn); }

.sd-composer-body { padding: 11px 16px 16px; }

.sd-composer textarea {
    width: 100%;
    min-height: 104px;
    border: 1px solid var(--sd-border-strong);
    border-radius: var(--sd-radius-sm);
    padding: 11px 13px;
    font-size: .84rem;
    line-height: 1.6;
    resize: vertical;
    background: var(--sd-surface);
    color: var(--sd-text);
}

.sd-composer textarea:focus {
    outline: 0;
    border-color: var(--sd-primary);
    box-shadow: 0 0 0 3px var(--sd-primary-soft);
}

.sd-composer.note-mode textarea { background: var(--sd-warn-soft); border-color: rgba(217, 119, 6, .35); }

.sd-composer-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}

.sd-composer-hint { font-size: .7rem; color: var(--sd-faint); }
.sd-picked { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.sd-picked span {
    font-size: .7rem;
    background: var(--sd-bg);
    border: 1px solid var(--sd-border);
    border-radius: 5px;
    padding: 3px 8px;
}

/* ── Side panel ───────────────────────────────────────────────── */

.sd-side { position: sticky; top: 78px; }

@media (max-width: 1199px) {
    .sd-side { position: static; }
}

.sd-prop { padding: 9px 0; border-bottom: 1px solid var(--sd-border); }
.sd-prop:last-child { border-bottom: 0; }

.sd-prop-label {
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--sd-faint);
    margin-bottom: 4px;
}

.sd-prop-value { font-size: .82rem; font-weight: 500; overflow-wrap: anywhere; }

/* ── Activity rail ────────────────────────────────────────────── */

.sd-activity { padding: 4px 16px 16px; max-height: 420px; overflow-y: auto; }

.sd-event {
    position: relative;
    padding: 0 0 15px 26px;
    font-size: .76rem;
}

.sd-event::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 17px;
    bottom: 0;
    width: 1px;
    background: var(--sd-border);
}

.sd-event:last-child { padding-bottom: 0; }
.sd-event:last-child::before { display: none; }

.sd-event i {
    position: absolute;
    left: 0;
    top: 1px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--sd-bg);
    border: 1px solid var(--sd-border);
    color: var(--sd-muted);
    font-size: .58rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sd-event .w { font-weight: 600; }
.sd-event .t { color: var(--sd-faint); font-size: .68rem; display: block; margin-top: 1px; }
.sd-event .r { color: var(--sd-muted); font-size: .72rem; display: block; margin-top: 2px; }

/* ── Workload bars ────────────────────────────────────────────── */

.sd-load { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--sd-border); }
.sd-load:last-child { border-bottom: 0; }
.sd-load-name { font-size: .8rem; font-weight: 550; }
.sd-load-meta { font-size: .68rem; color: var(--sd-faint); }

.sd-load-bar {
    height: 5px;
    border-radius: 3px;
    background: var(--sd-border);
    overflow: hidden;
    margin-top: 5px;
}

.sd-load-bar span { display: block; height: 100%; background: var(--sd-primary); border-radius: 3px; }
.sd-load-bar.is-hot span { background: var(--sd-danger); }

/* ── Secret reveal ────────────────────────────────────────────── */

.sd-secret {
    background: var(--sd-warn-soft);
    border: 1px solid rgba(217, 119, 6, .35);
    border-radius: var(--sd-radius);
    padding: 15px 17px;
    margin-bottom: 16px;
}

.sd-secret h6 { font-size: .85rem; font-weight: 700; color: var(--sd-warn); margin-bottom: 4px; }
.sd-secret p { font-size: .78rem; color: var(--sd-muted); margin-bottom: 10px; }

.sd-secret-value {
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--sd-surface);
    border: 1px solid var(--sd-border-strong);
    border-radius: var(--sd-radius-sm);
    padding: 9px 12px;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .8rem;
    overflow-wrap: anywhere;
}

.sd-secret-value code { flex: 1; color: var(--sd-text); background: none; padding: 0; }

/* ── Trend chart ──────────────────────────────────────────────── */

.sd-trend {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 128px;
    padding-top: 8px;
}

.sd-trend-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.sd-trend-bars { display: flex; gap: 2px; align-items: flex-end; height: 100px; width: 100%; justify-content: center; }

.sd-trend-bars span {
    width: 7px;
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    display: block;
}

.sd-trend-bars .raised { background: var(--sd-primary); }
.sd-trend-bars .resolved { background: var(--sd-success); }

.sd-trend-label {
    font-size: .58rem;
    color: var(--sd-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.sd-legend { display: flex; gap: 14px; font-size: .7rem; color: var(--sd-muted); }
.sd-legend span { display: inline-flex; align-items: center; gap: 5px; }
.sd-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ── Toasts ───────────────────────────────────────────────────── */

.sd-toast-host {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sd-toast {
    background: var(--sd-surface);
    border: 1px solid var(--sd-border);
    border-left: 3px solid var(--sd-primary);
    border-radius: var(--sd-radius-sm);
    box-shadow: var(--sd-shadow-lg);
    padding: 11px 15px;
    font-size: .82rem;
    min-width: 250px;
    max-width: 380px;
    animation: sd-slide-in .2s ease-out;
}

.sd-toast.ok { border-left-color: var(--sd-success); }
.sd-toast.err { border-left-color: var(--sd-danger); }

@keyframes sd-slide-in {
    from { opacity: 0; transform: translateX(14px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sd-toast { animation: none; }
    a.sd-stat:hover { transform: none; }
}

/* ── Alerts ───────────────────────────────────────────────────── */

.sd-alert { border-radius: var(--sd-radius); font-size: .84rem; padding: 11px 15px; }
.sd-alert i { vertical-align: -2px; margin-right: 4px; }

/* ── Sign-in screen ───────────────────────────────────────────── */

.sd-auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--sd-bg);
}

@media (max-width: 991px) {
    .sd-auth { grid-template-columns: 1fr; }
    .sd-auth-art { display: none; }
}

.sd-auth-art {
    background: linear-gradient(140deg, #4f46e5 0%, #4338ca 46%, #312e81 100%);
    color: #fff;
    padding: 46px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.sd-auth-art h2 { font-size: 1.85rem; font-weight: 700; margin-bottom: 14px; line-height: 1.25; }
.sd-auth-art p { font-size: .94rem; opacity: .86; max-width: 400px; line-height: 1.65; }

.sd-auth-points { margin-top: 30px; display: flex; flex-direction: column; gap: 13px; }
.sd-auth-point { display: flex; gap: 11px; align-items: flex-start; font-size: .86rem; opacity: .92; }
.sd-auth-point i { font-size: 1.15rem; opacity: .85; margin-top: 1px; }

.sd-auth-form {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 34px 20px;
}

.sd-auth-box { width: 100%; max-width: 384px; }
.sd-auth-box h1 { font-size: 1.32rem; font-weight: 700; margin-bottom: 5px; }
.sd-auth-box .lead { font-size: .84rem; color: var(--sd-muted); margin-bottom: 22px; }

.sd-auth-box .form-label {
    font-size: .74rem;
    font-weight: 650;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--sd-muted);
    margin-bottom: 5px;
}

.sd-auth-box .form-control {
    height: 44px;
    border-radius: var(--sd-radius-sm);
    border-color: var(--sd-border-strong);
    font-size: .88rem;
}

.sd-auth-box .form-control:focus {
    border-color: var(--sd-primary);
    box-shadow: 0 0 0 3px var(--sd-primary-soft);
}

.sd-auth-box .btn-primary { height: 44px; border-radius: var(--sd-radius-sm); font-weight: 600; }

.sd-pw-wrap { position: relative; }

.sd-pw-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--sd-faint);
    padding: 4px;
    cursor: pointer;
}

.sd-pw-toggle:hover { color: var(--sd-primary); }

/* ── Utilities ────────────────────────────────────────────────── */

.sd-mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .76rem; }
.sd-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-scroll-x { overflow-x: auto; }
.sd-divider { height: 1px; background: var(--sd-border); margin: 14px 0; }

.sd-stars { color: #f59e0b; font-size: .74rem; letter-spacing: -1px; }
.sd-stars .off { color: var(--sd-border-strong); }

/* ===================================================================
   RESPONSIVE

   The desk is worked on a laptop, but the queue gets opened on a phone
   often enough that it has to hold up there. The breakpoints below are
   the ones where each layout actually breaks, not a stock set:

     1199px  the ticket detail loses room for its side panel
      991px  the queue rail turns into a scrolling chip strip
      767px  wide tables stop being tables and become cards
      575px  phone proper: the last two-column rows go single
   =================================================================== */

/* ── Tablet ───────────────────────────────────────────────────── */

@media (max-width: 991px) {
    .sd-page { padding-block: 14px; }

    .sd-head { gap: 10px; }
    .sd-head h1 { font-size: 1.1rem; }

    /* The rail is a horizontal strip here, so give it edge-to-edge room
       and hide the scrollbar that would otherwise sit under the chips. */
    .sd-views {
        margin-inline: -2px;
        padding: 6px;
        scrollbar-width: none;
    }

    .sd-views::-webkit-scrollbar { display: none; }
    .sd-view { flex: 0 0 auto; }

    .sd-thread { max-height: none; }
    .sd-activity { max-height: 320px; }
}

/* ── Wide tables become cards ─────────────────────────────────── */

/* 991 rather than 767: between those widths the sidenav is condensed but
   still takes room, and a nine-column queue squeezed into what is left
   wraps ticket numbers onto four lines. Cards read better well before a
   phone. */
@media (max-width: 991px) {

    /* A nine-column queue cannot be a table on a phone: it becomes one
       card per ticket, each cell labelled by its former column heading
       (the data-label attribute in the view). */
    .sd-table-cards thead { display: none; }

    .sd-table-cards,
    .sd-table-cards tbody,
    .sd-table-cards tr,
    .sd-table-cards td {
        display: block;
        width: 100%;
    }

    .sd-table-cards tr {
        border: 1px solid var(--sd-border);
        border-radius: var(--sd-radius);
        margin: 10px;
        /* The top gap lives on the card, not on its first cell, because
           which cell comes first differs per table. */
        padding: 9px 0 4px;
        background: var(--sd-surface);
    }

    .sd-table-cards tbody tr:hover { background: var(--sd-surface); }
    .sd-table-cards tbody tr.is-unread { background: var(--sd-primary-soft); }

    .sd-table-cards tbody tr.is-overdue {
        box-shadow: none;
        border-left: 3px solid var(--sd-danger);
    }

    .sd-table-cards tbody td {
        display: block;
        padding: 7px 13px;
        border-bottom: 0;
        text-align: left;
    }

    /* Label down the left, value down the right. A grid rather than a flex
       row because a cell often holds two stacked lines — a company name over
       its code — and those have to keep stacking, not sit side by side. */
    .sd-table-cards tbody td[data-label] {
        display: grid;
        grid-template-columns: minmax(0, 36%) minmax(0, 1fr);
        column-gap: 12px;
        align-items: start;
        text-align: right;
    }

    .sd-table-cards tbody td[data-label]::before {
        content: attr(data-label);
        grid-column: 1;
        grid-row: 1;
        font-size: .66rem;
        font-weight: 700;
        letter-spacing: .05em;
        text-transform: uppercase;
        color: var(--sd-faint);
        text-align: left;
        padding-top: 2px;
    }

    .sd-table-cards tbody td[data-label] > * {
        grid-column: 2;
        justify-self: end;
        max-width: 100%;
    }

    /* The opening cells are the ticket's identity — number and subject read
       as the card's heading, not as two more labelled fields. The last of
       them carries the rule that separates the heading from the detail. */
    .sd-table-cards tbody td.sd-cell-lead {
        display: block;
        padding: 2px 13px;
    }

    .sd-table-cards tbody td.sd-cell-lead-last {
        padding-bottom: 9px;
        border-bottom: 1px solid var(--sd-border);
        margin-bottom: 4px;
    }

    .sd-table-cards tbody td.sd-cell-lead::before { content: none; }

    /* The select box belongs to the whole card, so it is pinned to its
       top-right corner rather than given a row of its own. */
    .sd-table-cards tbody tr { position: relative; }

    .sd-table-cards tbody td.sd-cell-pick {
        position: absolute;
        top: 12px;
        right: 13px;
        width: auto;
        padding: 0;
    }

    /* Room for it on the line it actually overlaps. */
    .sd-table-cards tbody td.sd-cell-lead:first-of-type { padding-right: 44px; }

    .sd-table-cards tbody td.sd-cell-actions {
        text-align: right;
        border-top: 1px solid var(--sd-border);
        margin-top: 4px;
        padding-top: 9px;
    }

    .sd-table-cards tbody td.sd-cell-actions::before { content: none; }

    /* Columns that only earn their place in a wide grid. */
    .sd-table-cards tbody td.sd-cell-drop { display: none; }

    .sd-subject { max-width: none; white-space: normal; }

    /* Numeric report tables stay tables — a column of figures is easier
       to scan side by side than stacked — so they just scroll. */
    .sd-scroll-x { -webkit-overflow-scrolling: touch; }
}

/* ── Phone ────────────────────────────────────────────────────── */

@media (max-width: 575px) {
    .sd-page { padding-block: 12px; }

    .sd-head {
        flex-direction: column;
        align-items: stretch;
    }

    .sd-head-actions { width: 100%; }
    .sd-head-actions .btn { flex: 1 1 auto; }
    .sd-head-actions form { flex: 1 1 100%; }

    .sd-head-icon { width: 36px; height: 36px; font-size: 1.05rem; }
    .sd-head h1 { font-size: 1.02rem; }

    /* Two tiles across reads far better than one tall column of six. */
    .sd-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
    .sd-stat { padding: 11px 12px; }
    .sd-stat-value { font-size: 1.32rem; }
    .sd-stat-label { font-size: .64rem; }
    .sd-stat-note { font-size: .64rem; }

    .sd-filters { grid-template-columns: 1fr; }

    /* The search field is told to span two columns on desktop; there is
       only one column here, so that span has to be released. */
    .sd-filters .sd-field[style*="span 2"] { grid-column: auto !important; }

    .sd-card-head { flex-wrap: wrap; }
    .sd-card-body { padding: 13px; }

    /* The bulk-assign bar and the report date range both put a select and
       a button on one line; neither fits, so let them stack and fill. */
    .sd-card-head > div { width: 100%; }
    .sd-card-head .form-select { width: 100% !important; }
    .sd-head-actions form { flex-wrap: wrap; }
    .sd-head-actions form .sd-field { flex: 1 1 calc(50% - 4px); }
    .sd-head-actions .form-select { width: 100% !important; }

    .sd-ticket-head { padding: 13px; }
    .sd-ticket-head h1 { font-size: .98rem; }

    .sd-quickbar { gap: 6px; }
    .sd-quickbar .btn { flex: 1 1 calc(50% - 3px); }

    .sd-thread { padding: 13px; }
    .sd-msg { gap: 8px; }
    .sd-msg-text { font-size: .8rem; padding: 9px 11px; }
    .sd-file { max-width: 100%; }

    .sd-composer-tabs { padding: 8px 13px 0; }
    .sd-composer-tab { padding: 7px 10px; font-size: .74rem; }
    .sd-composer-body { padding: 10px 13px 13px; }

    /* Send has to stay reachable without hunting: the footer stacks and
       the action row goes full width. */
    .sd-composer-foot { flex-direction: column; align-items: stretch; }
    .sd-composer-foot > div { width: 100%; }
    .sd-composer-foot .form-select { width: 100% !important; }
    .sd-composer-foot .btn { flex: 1 1 auto; }

    .sd-notify-menu { width: calc(100vw - 24px); }

    .sd-toast-host { right: 12px; left: 12px; bottom: 12px; }
    .sd-toast { min-width: 0; max-width: none; }

    .sd-secret { padding: 13px; }
    .sd-secret-value { flex-wrap: wrap; font-size: .72rem; }

    .sd-trend { height: 104px; gap: 3px; }
    .sd-trend-bars { height: 80px; }
    .sd-trend-bars span { width: 5px; }

    /* Every other day only — fourteen labels do not fit across a phone. */
    .sd-trend-day:nth-child(even) .sd-trend-label { visibility: hidden; }

    .sd-auth-form { padding: 24px 16px; }
    .sd-auth-box h1 { font-size: 1.18rem; }

    .sd-table-cards tbody td[data-label]::before { flex-basis: 40%; }
}

/* ── Anything narrower than a phone ───────────────────────────── */

@media (max-width: 380px) {
    .sd-stats { grid-template-columns: 1fr; }
    .sd-quickbar .btn { flex: 1 1 100%; }
}
