:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --accent: #0ea5e9;
    --purple: #8b5cf6;
    --teal: #0d9488;
    --orange: #ea580c;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

.nav {
    width: 250px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 17px;
    padding: 4px 10px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 14px;
}

.nav-section { display: flex; flex-direction: column; gap: 8px; flex: 1; }

.nav-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    padding: 0 10px;
}

.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
    font-weight: 500;
    text-decoration: none;
}

.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--primary-light); color: var(--primary-dark); }

.nav-footer {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-user { padding: 0 4px; font-size: 13px; }
.nav-user strong { display: block; }

.content { flex: 1; min-width: 0; padding: 28px 36px; max-width: 1280px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.grid { display: grid; gap: 16px; }
.grid.stat-cards { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.template-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.settings-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat-card { padding: 16px 18px; }
.stat-card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 30px; font-weight: 700; margin-top: 4px; }

button, .btn {
    background: var(--primary);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

button:not(:disabled):hover, .btn:not(:disabled):hover { background: var(--primary-dark); }
button:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-block { width: 100%; margin-top: 6px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-primary:not(:disabled):active { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:not(:disabled):hover { background: var(--primary-light); border-color: #bfdbfe; }
.btn-secondary:not(:disabled):active { background: var(--primary-light); border-color: var(--primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:not(:disabled):hover { background: #b91c1c; border-color: #b91c1c; }
.btn-danger:not(:disabled):active { background: #991b1b; border-color: #991b1b; }

.btn:focus-visible, .tab-btn:focus-visible, .close-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.form-control, .input,
input[type=text], input[type=password], input[type=email], input[type=datetime-local], input[type=search], input[type=date], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    background: var(--surface);
    color: var(--text);
    box-sizing: border-box;
}

select.form-control,
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 12px;
    padding-right: 36px;
    -webkit-text-fill-color: var(--text);
}

select.form-control option,
select option {
    color: var(--text);
    background: var(--surface);
}

select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

textarea { min-height: 96px; resize: vertical; }

label { font-weight: 600; font-size: 13px; display: block; margin-bottom: 5px; }

.w-auto { width: auto; display: inline-block; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: #f8fafc; }
table.inner-table { margin: 6px 0; }
table.inner-table th { font-size: 11px; }
.detail-row td { background: #fcfcfd; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: var(--success); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-info { background: #e0f2fe; color: var(--info); }
.badge-accent { background: #e0f2fe; color: var(--accent); }
.badge-purple { background: #ede9fe; color: var(--purple); }
.badge-teal { background: #ccfbf1; color: var(--teal); }
.badge-orange { background: #ffedd5; color: var(--orange); }
.badge-muted { background: #f1f5f9; color: var(--muted); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }

/* ---------- Forms ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .field { margin-bottom: 0; }

.field { margin-bottom: 14px; }

/* ---------- Login ---------- */

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(160deg, #eef2ff 0%, var(--bg) 55%, #e0f2fe 100%);
}

.login-card {
    width: 380px;
    padding: 36px 34px 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .09);
}

.login-card h1 { text-align: center; margin-bottom: 4px; font-size: 20px; }

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 6px 14px rgba(37, 99, 235, .28);
}

.login-sub { text-align: center; margin-bottom: 20px; }

.login-card .form-control:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.pw-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-weight: 400;
    font-size: 12px;
    cursor: pointer;
}

.pw-toggle input { width: auto; }

.error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
}

.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; }
.success-text { color: var(--success); font-size: 13px; margin-top: 10px; }
.validation-message { color: var(--danger); font-size: 12px; }

/* ---------- Wizard ---------- */

.stepper { display: flex; gap: 6px; margin-bottom: 18px; }
.step { display: flex; align-items: center; gap: 8px; flex: 1; }
.step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.step.active .step-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.done .step-num { background: var(--success); border-color: var(--success); color: #fff; }
.step.active .step-label { color: var(--primary-dark); }
.step-label { font-size: 12px; font-weight: 600; color: var(--muted); }

.wizard-card { padding: 24px; }
.wizard-nav { display: flex; justify-content: space-between; margin-top: 22px; }

/* ---------- Target / check / pick options ---------- */

.target-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.target-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    background: var(--surface);
}
.target-option.selected { border-color: var(--primary); background: var(--primary-light); }
.target-option strong { display: block; font-size: 13px; }
.target-option small { color: var(--muted); font-size: 12px; }
.target-option input { margin-top: 2px; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 12px; }
.check-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    background: var(--surface);
    font-weight: 500;
    font-size: 13px;
}
.check-option small { color: var(--muted); margin-left: auto; }
.check-option:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }

.pick-list { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: grid; gap: 4px; background: var(--surface); margin-top: 8px; }

.info-box { background: var(--primary-light); border: 1px solid #bfdbfe; color: var(--primary-dark); border-radius: 8px; padding: 12px 14px; margin-top: 12px; }
.success-box { background: #dcfce7; border: 1px solid #bbf7d0; color: var(--success); border-radius: 8px; padding: 12px 14px; margin-top: 12px; }
.error-box { background: #fee2e2; border: 1px solid #fecaca; color: var(--danger); border-radius: 8px; padding: 12px 14px; }

.radio-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.review-list { display: flex; flex-direction: column; gap: 10px; }
.review-row { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.review-row .muted { flex-shrink: 0; }
.review-row > span:last-child { text-align: right; }

.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

.steps-list { padding-left: 20px; }
.steps-list li { margin-bottom: 8px; line-height: 1.4; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; padding: 12px 14px; }
.toolbar .form-control { width: 220px; }

.meter { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; min-width: 120px; }
.meter-fill { height: 100%; background: var(--success); border-radius: 999px; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .4);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 50;
}
.modal { width: 560px; max-width: 100%; max-height: 80vh; overflow: auto; }

/* ---------- Detail Modal ---------- */
.detail-modal {
    max-width: 900px;
    width: 100%;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.detail-title-block {
    flex: 1;
    min-width: 0;
}

.detail-title-block h2 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.detail-message {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0;
    transition: background .15s, color .15s, border-color .15s;
    flex-shrink: 0;
}

.close-btn:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

.detail-body-single {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.detail-body-multi {
    margin-bottom: 24px;
}

.detail-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.detail-section h3 {
    margin: 0 0 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.detail-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-row .muted {
    flex-shrink: 0;
    min-width: 140px;
}

.detail-row > span:last-child {
    text-align: right;
    word-break: break-word;
}

.text-danger {
    color: var(--danger);
    font-weight: 500;
}

.detail-timeline {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
    min-height: 40px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -24px;
    top: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--border);
    border: 3px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border);
    z-index: 1;
    transition: background .2s, border-color .2s;
}

.timeline-item.completed .timeline-marker {
    background: var(--success);
    border-color: var(--success);
}

.timeline-item.pending .timeline-marker {
    background: var(--surface);
    border-color: var(--muted);
}

.timeline-content {
    padding-left: 4px;
}

.timeline-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text);
}

.timeline-time {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.timeline-item.completed .timeline-label {
    color: var(--text);
}

.timeline-item.pending .timeline-label {
    color: var(--muted);
}

.detail-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    .detail-body-single {
        grid-template-columns: 1fr;
    }

    .detail-grid-2 {
        grid-template-columns: 1fr;
    }

    .detail-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .close-btn {
        align-self: flex-end;
    }
}

/* ---------- Group Recipient Acknowledgement ---------- */
.detail-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 32px;
}

.detail-grid-2 .detail-row {
    padding-bottom: 8px;
}

.detail-grid-2 .detail-row:last-child {
    border-bottom: 1px solid var(--border);
}

.ack-note {
    font-size: 12px;
    margin: -6px 0 14px;
    line-height: 1.5;
}

.table-scroll {
    max-height: 340px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.recipient-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.recipient-table th,
.recipient-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    white-space: nowrap;
}

.recipient-table th {
    position: sticky;
    top: 0;
    background: var(--bg);
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    z-index: 1;
}

.recipient-table tbody tr:last-child td {
    border-bottom: none;
}

.recipient-table tbody tr:hover td {
    background: #f8fafc;
}

/* ---------- Force Update Modal ---------- */

.force-update-modal {
    width: 560px;
    max-width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(15, 23, 42, .25);
    overflow: hidden;
    animation: modalIn .15s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.force-update-modal .modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.force-update-modal .header-content {
    display: flex;
    align-items: center;
    gap: 14px;
}

.force-update-modal .icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-dark);
    flex-shrink: 0;
}

.force-update-modal .icon-circle svg {
    width: 22px;
    height: 22px;
}

.force-update-modal .header-text h3 {
    margin: 0 0 2px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.force-update-modal .header-text p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.force-update-modal .close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    transition: background .15s, color .15s, border-color .15s;
}

.force-update-modal .close-btn:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

.force-update-modal .modal-body {
    padding: 20px 24px;
    flex: 1 1 auto;
    overflow-y: auto;
}

.force-update-modal .info-panel {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.force-update-modal .info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 0;
}

.force-update-modal .info-row:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.force-update-modal .info-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

.force-update-modal .info-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    word-break: break-word;
}

.force-update-modal .status-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.force-update-modal .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
}

.force-update-modal .status-dot.online {
    background: var(--success);
}

.force-update-modal .status-dot.offline {
    background: var(--muted);
}

.force-update-modal .status-dot.idle {
    background: var(--warning);
}

.force-update-modal .message-box {
    background: var(--primary-light);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--primary-dark);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.offline-warning {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 12px 14px;
    color: #92400e;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.offline-warning svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--warning);
}

.force-update-modal .error-inline {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
}

.force-update-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}

.force-update-modal .modal-footer .btn {
    min-width: 110px;
    padding: 10px 18px;
    font-size: 14px;
}

@media (max-width: 600px) {
    .force-update-modal .modal-header,
    .force-update-modal .modal-body,
    .force-update-modal .modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    .force-update-modal .info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    .force-update-modal .info-value {
        text-align: left;
    }
    .force-update-modal .modal-footer {
        flex-direction: column-reverse;
    }
    .force-update-modal .modal-footer .btn {
        width: 100%;
    }
}

/* ---------- Chat ---------- */

/* Direct / Groups switch. The bar has a fixed height because the layout below it subtracts it
   from the viewport, matching how .chat-layout already accounts for the page header. */
.chat-tabs {
    display: flex; align-items: center; gap: 6px;
    height: 46px; box-sizing: border-box; padding: 0 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.chat-tab {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 14px;
    border: 1px solid var(--border); border-radius: 999px;
    background: transparent; color: var(--text);
    font: inherit; font-size: 13px; cursor: pointer;
}
.chat-tab:hover { background: var(--bg); }
.chat-tab.active { background: var(--primary-light); border-color: var(--primary); font-weight: 600; }

.chat-tabs ~ .chat-layout { height: calc(100vh - 104px); }

.chat-layout { display: flex; height: calc(100vh - 58px); overflow: hidden; }

.chat-panel {
    display: flex; flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface);
}
.chat-panel:last-child { border-right: 0; }
.chat-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.chat-panel-header h2 { font-size: 15px; margin: 0; }

.chat-conversations { width: 260px; flex-shrink: 0; }
.chat-thread { flex: 1; min-width: 0; }
.chat-online { width: 220px; flex-shrink: 0; }

.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.chat-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.chat-item:hover { background: var(--bg); }
.chat-item.active { background: var(--primary-light); }
.chat-item-peer { font-weight: 600; }
.chat-item-meta { display: flex; align-items: center; gap: 6px; }
.chat-item-text { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }

.chat-thread-header {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.chat-messages {
    flex: 1; overflow-y: auto; padding: 12px 14px;
    display: flex; flex-direction: column; gap: 8px;
}
.chat-message { padding: 8px 10px; border-radius: 8px; max-width: 80%; }
.chat-message.mine { align-self: flex-end; background: var(--primary-light); }
.chat-message-sender { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.chat-message-body { font-size: 14px; }
.chat-message-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 11px; }

.chat-composer {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 12px; border-top: 1px solid var(--border);
}
.chat-kind {
    width: 90px; padding: 6px;
    background: var(--surface); color: var(--text);
}
.chat-kind:hover,
.chat-kind:focus { border-color: var(--primary); background: var(--surface); color: var(--text); }
.chat-input {
    flex: 1; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px;
}
.chat-composer .btn {
    padding: 8px 14px; background: var(--primary); color: #fff;
}
.chat-composer .btn:hover { background: var(--primary-dark); color: #fff; }
.chat-composer .btn:disabled { background: #94a3b8; color: #fff; cursor: not-allowed; }

@media (max-width: 900px) {
    .chat-layout { flex-direction: column; }
    .chat-panel { width: 100% !important; }
}

/* ---------- Groups ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.picker-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.group-meta dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.group-meta dd { margin: 0 0 12px; font-size: 14px; }

@media (max-width: 900px) {
    .content { padding: 22px 20px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .toolbar .form-control { width: 100%; }
    .modal { max-height: 90vh; }
}

@media (max-width: 600px) {
    .content { padding: 18px 14px; }
    .check-grid { grid-template-columns: 1fr; }
    .check-option { flex-wrap: wrap; }
    .card { padding: 14px; }
    .empty-state { padding: 40px 12px; }
    .picker-foot { flex-direction: column; align-items: stretch; }
}

/* ---------- Agent Updates: tab strip + releases ---------- */

.tab-strip {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    margin: 10px 0 18px;
    border-bottom: 1px solid var(--border);
}

.tab-strip .tab-btn {
    appearance: none;
    -webkit-appearance: none;
    padding: 9px 16px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 8px 8px 0 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.tab-strip .tab-btn:not(:disabled):hover {
    background: var(--bg);
    color: var(--text);
}

.tab-strip .tab-btn:not(:disabled):active {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.tab-strip .tab-btn.active,
.tab-strip .tab-btn.active:not(:disabled):hover,
.tab-strip .tab-btn.active:not(:disabled):active {
    background: transparent;
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }

/* Releases toolbar */
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

.releases-toolbar .release-search {
    flex: 1 1 240px;
    min-width: 180px;
    width: auto;
}

.releases-toolbar .release-status {
    flex: 0 0 auto;
    width: auto;
}

/* Releases table */
table.release-table {
    table-layout: fixed;
    width: 100%;
    min-width: 1140px;
}

.release-table col.col-version { width: 88px; }
.release-table col.col-date { width: 116px; }
.release-table col.col-sha { width: 132px; }
.release-table col.col-package { width: 164px; }
.release-table col.col-status { width: 92px; }
.release-table col.col-created { width: 136px; }
.release-table col.col-actions { width: 248px; }

.release-table th,
.release-table td {
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.release-table .col-actions-head { text-align: right; }

.release-table .package-col { white-space: normal; }

.release-table .package-link {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.release-table .package-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.release-table .package-size {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

.release-table .release-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.release-table .release-actions .btn {
    width: 100%;
    white-space: nowrap;
}

.upload-progress {
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.upload-progress > span {
    display: block;
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
    transition: width .15s ease-out;
}

/* ---------- Agent Updates: shared helpers ---------- */

.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; }

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 6px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    vertical-align: -2px;
    animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Force update: progress, timing and stale-state UI ---------- */

.force-update-modal .progress-section {
    margin-bottom: 14px;
}

.force-update-modal .progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.force-update-modal .progress-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.force-update-modal .progress-percent {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-dark);
    font-variant-numeric: tabular-nums;
}

/* Determinate track (real percentage reported by the agent/updater). */
.force-update-modal .fu-progress {
    height: 10px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.force-update-modal .fu-progress-bar {
    display: block;
    height: 100%;
    min-width: 2px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 999px;
    transition: width .25s ease-out;
}

/* Indeterminate track: shown when no real percentage is available yet. */
.force-update-modal .fu-progress-indeterminate {
    position: relative;
    height: 10px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.force-update-modal .fu-progress-indeterminate-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: fuIndeterminate 1.4s ease-in-out infinite;
}

@keyframes fuIndeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

.force-update-modal .progress-bytes {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.force-update-modal .timing-section {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.force-update-modal .timing-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 3px 0;
}

.force-update-modal .timing-row:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.force-update-modal .timing-label {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

.force-update-modal .timing-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.force-update-modal .warning-inline {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 10px 12px;
    color: #92400e;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.force-update-modal .warning-inline svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--warning);
}

.force-update-modal .modal-footer .muted {
    margin-right: auto;
    font-size: 13px;
}

.latest-version { color: var(--muted); font-size: 13px; }
.latest-version strong { color: var(--text); }

.error-card { border-color: #fecaca; background: #fef2f2; }

.form-success { color: var(--success); font-size: 13px; }
.form-error { color: var(--danger); font-size: 13px; }

@media (max-width: 760px) {
    .releases-toolbar .release-search,
    .releases-toolbar .release-status {
        flex: 1 1 100%;
        width: 100%;
    }

    .toolbar-actions {
        width: 100%;
        margin-left: 0;
    }

    .toolbar-actions .btn { flex: 1 1 auto; }
}