/* ==========================================================
   Enterprise additions (loaded after style.css)
   ========================================================== */
:root { --warn-bg: #fff7e6; --warn-fg: #92400e; --private-bg: #fffbeb; --private-border: #fcd34d; --focus: #2563eb; }
:root[data-theme="dark"] { --warn-bg: #3a2a0f; --warn-fg: #fcd34d; --private-bg: #2a2412; --private-border: #a16207; --focus: #60a5fa; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--brand); color: #fff; padding: 8px 12px; border-radius: 6px; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.text-muted { color: var(--text-muted); }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 12px; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 8px 0 10px; }

/* Layout grids */
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-3-1 { grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); }
.grid-cols-1-2 { grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); }
@media (max-width: 1000px) { .grid-cols-3, .grid-cols-3-1, .grid-cols-1-2 { grid-template-columns: 1fr; } }

/* Alerts */
.alert-warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--private-border); }
a.alert-warn:hover { text-decoration: none; filter: brightness(0.98); }

/* Top bar */
.topbar { gap: 16px; position: sticky; top: 0; z-index: 20; }
.global-search { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; color: var(--text-muted); }
.global-search input { flex: 1; border: 0; background: transparent; color: var(--text); padding: 8px 0; font-size: 13px; outline: none; }
.bell { position: relative; display: inline-flex; color: var(--text-muted); padding: 4px; }
.bell:hover { color: var(--text); text-decoration: none; }
.bell-count { position: absolute; top: -4px; right: -6px; background: var(--bad); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700; padding: 1px 5px; line-height: 1.4; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.user-chip:hover { text-decoration: none; }
.user-chip-text { display: flex; flex-direction: column; line-height: 1.2; font-size: 13px; }
.user-chip-text small { color: var(--text-muted); font-size: 11px; }
.avatar { width: 30px; height: 30px; border-radius: 999px; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.link-button:hover { text-decoration: underline; }
.app-footer { display: flex; justify-content: space-between; gap: 12px; padding: 12px 24px; color: var(--text-muted); font-size: 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.sidebar .brand { display: block; text-decoration: none; }

/* Lists, filters, pagination */
.table-wrap { overflow-x: auto; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap table.data-table { margin: 0; }
.card .table-wrap { border: 0; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; padding: 12px; }
.filter-bar .form-control { width: auto; min-width: 140px; flex: 0 1 auto; }
.filter-bar input[type=search] { flex: 1 1 220px; }
.inline-search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-search .form-control { width: auto; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; }
.sort-link { color: inherit; white-space: nowrap; }
.pagination { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); font-size: 12.5px; }
.pagination .current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .disabled { color: var(--text-muted); opacity: .6; }
.pagination .page-info { border: 0; background: none; color: var(--text-muted); }
.row-actions { white-space: nowrap; }
.row-actions > * + * { margin-left: 8px; }
tr.row-alert td { background: color-mix(in srgb, var(--bad) 8%, transparent); }
tr.row-muted td { opacity: .6; }
.badge-stack { display: flex; flex-wrap: wrap; gap: 4px; }

/* SLA / status pills */
.sla-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.sla-ok { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.sla-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn-fg); }
.sla-bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.sla-done { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge-private { background: var(--private-bg); color: var(--warn-fg); border: 1px solid var(--private-border); }

/* Request detail */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .page-title { margin: 2px 0 8px; }
.breadcrumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.head-badges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 12px 0 0; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-word; }
.thread { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.thread-item { padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg); }
.thread-item.is-staff { border-left: 3px solid var(--brand); }
.thread-item.is-private { background: var(--private-bg); border-color: var(--private-border); border-left: 3px solid var(--private-border); }
.thread-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.reply-form { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.reply-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.attachment-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 4px; }
.attachment-list a { display: inline-flex; gap: 6px; align-items: center; }
.timeline { list-style: none; padding: 0; margin: 12px 0 0 6px; border-left: 2px solid var(--border); }
.timeline li { padding: 6px 0 6px 14px; position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 12px; width: 10px; height: 10px; border-radius: 999px; background: var(--brand); }
details > summary { cursor: pointer; }
.card-highlight { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent); }
.csat-card { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.csat-card .form-control { flex: 1 1 240px; width: auto; }
.csat-stars { display: inline-flex; flex-direction: row-reverse; }
.csat-stars input { position: absolute; opacity: 0; width: 1px; }
.csat-stars label { font-size: 26px; color: var(--border); cursor: pointer; padding: 0 2px; }
.csat-stars input:checked ~ label, .csat-stars label:hover, .csat-stars label:hover ~ label { color: #f59e0b; }
.csat-stars input:focus-visible + label { outline: 2px solid var(--focus); }

/* Forms */
.btn-block { width: 100%; }
.checkbox { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.form-inline-stack { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-inline-stack .form-group { margin: 0; flex: 1 1 200px; }
.otp-input { font-size: 20px; letter-spacing: 4px; text-align: center; font-variant-numeric: tabular-nums; }
.btn:disabled, .form-control:disabled { opacity: .65; cursor: not-allowed; }

/* Profile / MFA */
.mfa-setup { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.qr-box { background: #fff; padding: 10px; border-radius: 8px; border: 1px solid var(--border); min-width: 188px; min-height: 188px; }
.secret-key { display: block; margin-top: 4px; font-size: 15px; letter-spacing: 1px; word-break: break-all; }
.steps { padding-left: 18px; font-size: 13px; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.recovery-codes code { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; text-align: center; font-size: 14px; }

/* Knowledge base */
.kb-hero { margin-bottom: 16px; }
.kb-search { display: flex; gap: 8px; flex-wrap: wrap; }
.kb-search .form-control { flex: 1 1 260px; width: auto; }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.kb-card { display: flex; flex-direction: column; gap: 6px; color: var(--text); }
.kb-card:hover { text-decoration: none; border-color: var(--brand); }
.kb-excerpt { color: var(--text-muted); font-size: 13px; }
.kb-body { font-size: 14.5px; line-height: 1.65; }
.kb-vote { display: flex; gap: 8px; align-items: center; }
.link-list { padding-left: 18px; margin: 8px 0 0; }
.link-list li { margin-bottom: 6px; }
.result-list { list-style: none; padding: 0; margin: 8px 0 0; }
.result-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.result-list li:last-child { border-bottom: 0; }

/* Notifications */
.notif-list { padding: 0; overflow: hidden; }
.notif-item { margin: 0; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: 0; }
.notif-button { width: 100%; text-align: left; background: none; border: 0; padding: 12px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; color: var(--text); font: inherit; }
.notif-button:hover { background: var(--bg); }
.notif-item.unread .notif-button { border-left: 3px solid var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); }
.notif-item.unread .notif-title { font-weight: 700; }
.notif-body { color: var(--text-muted); font-size: 13px; }

/* Approvals */
.approval-list { display: flex; flex-direction: column; gap: 14px; }
.approval-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.approval-form .form-control { flex: 1 1 260px; width: auto; }

/* Admin */
.admin-card { display: block; color: var(--text); }
.admin-card:hover { text-decoration: none; border-color: var(--brand); }
.admin-card p { margin: 6px 0 0; }
.row-menu summary { color: var(--brand); }
.row-menu-body { margin-top: 8px; min-width: 240px; }
.row-menu-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.checklist { list-style: none; padding: 0; margin: 12px 0 0; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist li > div { min-width: 0; overflow-wrap: anywhere; }
.card { min-width: 0; }
.check-icon { width: 24px; height: 24px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 700; }
.checklist li.ok .check-icon { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.checklist li.fail .check-icon { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }

/* Sign-in pages (dark-mode safe) */
.login-card { background: var(--card-bg); color: var(--text); max-width: 400px; }
.login-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; margin-bottom: 6px; color: var(--brand); }
.login-wrap { flex-direction: column; gap: 14px; padding: 16px; }
.login-footer { color: rgba(255, 255, 255, .75); font-size: 12px; margin: 0; }
.demo-hint { margin-top: 18px; padding: 10px; background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; }

/* Mobile: sidebar becomes a horizontal scroller */
@media (max-width: 760px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 0; position: sticky; top: 0; z-index: 30; }
    .sidebar .brand { display: none; }
    .sidebar nav { display: flex; }
    .sidebar nav a { min-width: 76px; border-left: 0; border-bottom: 3px solid transparent; }
    .sidebar nav a.active { border-bottom-color: var(--sidebar-accent); }
    .topbar { flex-wrap: wrap; padding: 10px 16px; position: static; }
    .topbar .app-title { display: none; }
    .global-search { order: 3; max-width: none; flex-basis: 100%; }
    .user-chip-text { display: none; }
    .content { padding: 16px; }
    .kv { grid-template-columns: 1fr; gap: 2px; }
    .kv dt { margin-top: 8px; }
    .card > table.data-table, .main > .content > table.data-table { display: block; overflow-x: auto; }
}

@media print {
    .sidebar, .topbar, .app-footer, .reply-form, form { display: none !important; }
    .content { padding: 0; }
    .card { box-shadow: none; }
}
