:root {
    --font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --color-white: #fff;
    --spacing: .25rem;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-extrabold: 800;
    --default-font-family: var(--font-sans);
    --default-mono-font-family: var(--font-mono);
    --tilio-primary: oklch(64.6% .222 41.116);
    --tilio-primary-dark: oklch(55.3% .195 38.402);
    --tilio-bg: #f4f7fb;
    --tilio-ink: #111827;
    --tilio-muted: #6b7280;
    --sidebar: #0f172a;
    --bs-primary: oklch(64.6% .222 41.116);
    --bs-primary-rgb: 234, 88, 12;
    --bs-link-color: oklch(64.6% .222 41.116);
    --bs-link-color-rgb: 234, 88, 12;
    --bs-link-hover-color: oklch(55.3% .195 38.402);
    --bs-link-hover-color-rgb: 194, 65, 12;
    --bs-focus-ring-color: oklch(64.6% .222 41.116 / 25%);
    --bs-body-font-family: var(--default-font-family);
    --bs-font-sans-serif: var(--font-sans);
    --bs-font-monospace: var(--font-mono);
    --bs-body-font-weight: var(--font-weight-normal);
}

html, body {
    min-height: 100%;
    font-family: var(--default-font-family);
    font-weight: var(--font-weight-normal);
}

body {
    color: var(--tilio-ink);
    background: var(--tilio-bg);
}

code, kbd, samp, pre {
    font-family: var(--default-mono-font-family);
}

a { color: var(--tilio-primary); }

.btn-primary {
    --bs-btn-bg: var(--tilio-primary);
    --bs-btn-border-color: var(--tilio-primary);
    --bs-btn-hover-bg: var(--tilio-primary-dark);
    --bs-btn-hover-border-color: var(--tilio-primary-dark);
    --bs-btn-active-bg: var(--tilio-primary-dark);
    --bs-btn-active-border-color: var(--tilio-primary-dark);
    --bs-btn-disabled-bg: var(--tilio-primary);
    --bs-btn-disabled-border-color: var(--tilio-primary);
    background: var(--tilio-primary);
    border-color: var(--tilio-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--tilio-primary-dark);
    border-color: var(--tilio-primary-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--tilio-primary);
    --bs-btn-border-color: var(--tilio-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--tilio-primary);
    --bs-btn-hover-border-color: var(--tilio-primary);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--tilio-primary);
    --bs-btn-active-border-color: var(--tilio-primary);
    --bs-btn-disabled-color: var(--tilio-primary);
    --bs-btn-disabled-border-color: var(--tilio-primary);
}

.pagination {
    --bs-pagination-active-bg: var(--tilio-primary);
    --bs-pagination-active-border-color: var(--tilio-primary);
    --bs-pagination-hover-color: var(--tilio-primary-dark);
    --bs-pagination-focus-color: var(--tilio-primary-dark);
    --bs-pagination-focus-box-shadow: 0 0 0 0.25rem oklch(64.6% .222 41.116 / 25%);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--tilio-primary);
    box-shadow: 0 0 0 0.25rem oklch(64.6% .222 41.116 / 25%);
}

.nav-link {
    --bs-nav-link-hover-color: var(--tilio-primary);
}

.nav-tabs {
    --bs-nav-tabs-link-active-color: var(--tilio-primary);
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--tilio-primary);
    color: #fff;
    flex-shrink: 0;
}

.brand-mark svg {
    width: 26px;
    height: 26px;
    display: block;
}

.brand-mark-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.brand-mark-sm svg {
    width: 18px;
    height: 18px;
}

.guest-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.guest-wrap { width: 100%; max-width: 440px; }
.guest-card { border-radius: 16px; }

.admin-shell {
    min-height: 100vh;
    display: flex;
}

.admin-sidebar {
    width: 240px;
    background: var(--sidebar);
    color: #e5e7eb;
    padding: 1.25rem 1rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.sidebar-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidebar-nav a,
.sidebar-profile a,
.sidebar-logout {
    color: #cbd5e1;
    text-decoration: none;
    padding: .6rem .75rem;
    border-radius: 8px;
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
}
.sidebar-nav a:hover,
.sidebar-nav a:focus,
.sidebar-profile a:hover,
.sidebar-profile a:focus,
.sidebar-logout:hover,
.sidebar-logout:focus {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.sidebar-profile {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,.12);
}
.sidebar-profile-meta {
    padding: .25rem .75rem .65rem;
}
.sidebar-profile-name {
    color: #fff;
    font-weight: var(--font-weight-semibold);
}
.sidebar-profile-role {
    color: #94a3b8;
    font-size: .8rem;
}

.offcanvas-body .sidebar-profile {
    color: var(--tilio-ink);
}
.offcanvas-body .sidebar-profile-name { color: var(--tilio-ink); }
.offcanvas-body .sidebar-profile-role { color: var(--tilio-muted); }
.offcanvas-body .sidebar-profile a,
.offcanvas-body .sidebar-logout {
    color: var(--tilio-ink);
}

.admin-main { flex: 1; min-width: 0; }
.admin-topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: .85rem 1.25rem;
    display: flex;
    align-items: center;
}
.admin-content { padding: 1.5rem; }

.stat-card { border-radius: 14px; }
.stat-label { color: var(--tilio-muted); font-size: .82rem; }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.stat-blue { border-left: 4px solid var(--tilio-primary) !important; }
.stat-open { border-left: 4px solid #2563eb !important; }
.stat-progress { border-left: 4px solid #7c3aed !important; }
.stat-waiting { border-left: 4px solid #d97706 !important; }
.stat-ready { border-left: 4px solid #0891b2 !important; }
.stat-reopened { border-left: 4px solid #db2777 !important; }
.stat-resolved { border-left: 4px solid #059669 !important; }
.stat-closed { border-left: 4px solid #6b7280 !important; }
.stat-urgent { border-left: 4px solid #dc2626 !important; }

.badge-status-open { background: #dbeafe; color: #1d4ed8; }
.badge-status-progress { background: #ede9fe; color: #6d28d9; }
.badge-status-waiting { background: #fef3c7; color: #b45309; }
.badge-status-ready { background: #cffafe; color: #0e7490; }
.badge-status-reopened { background: #fce7f3; color: #be185d; }
.badge-status-resolved { background: #d1fae5; color: #047857; }
.badge-status-closed { background: #e5e7eb; color: #374151; }
.badge-priority-low { background: #f3f4f6; color: #4b5563; }
.badge-priority-medium { background: #dbeafe; color: #1d4ed8; }
.badge-priority-high { background: #ffedd5; color: #c2410c; }
.badge-priority-urgent { background: #fee2e2; color: #b91c1c; }
.badge-internal { background: #fde68a; color: #92400e; }

.thread-card {
    margin-bottom: 1rem;
}
.thread-card-description {
    border-left: 4px solid var(--tilio-primary) !important;
}
.thread-card-internal {
    background: #fffbeb;
    border: 1px solid #fde68a !important;
}
.thread-tabs {
    margin-top: 1.25rem;
}
.thread-tabs .nav-tabs .nav-link {
    font-weight: var(--font-weight-medium);
}
.thread-tabs .thread-card:last-child {
    margin-bottom: 0;
}
.thread-body { white-space: pre-wrap; }
.thread-actions .btn { min-width: 4.5rem; }
.thread-attachments { display: flex; flex-direction: column; gap: .5rem; }
.thread-attachment {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .875rem;
}
.thread-image-link {
    display: block;
    max-width: 100%;
}
.thread-image {
    display: block;
    max-width: min(100%, 420px);
    max-height: 320px;
    width: auto;
    height: auto;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    object-fit: contain;
    background: #f8fafc;
}

.detail-list dt { font-size: .75rem; text-transform: uppercase; color: var(--tilio-muted); margin-top: .75rem; }
.detail-list dd { margin-bottom: 0; }

.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li { padding: .65rem 0; border-bottom: 1px solid #eef2f7; }
.history-list li:last-child { border-bottom: 0; }

.report-hours { min-width: 7.5rem; }
.report-meter {
    height: 6px;
    margin-top: .35rem;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}
.report-meter > span {
    display: block;
    height: 100%;
    background: var(--tilio-primary);
    border-radius: 999px;
}

.card { border-radius: 14px; }
.table > :not(caption) > * > * { background: transparent; }

@media (max-width: 991.98px) {
    .admin-sidebar { display: none; }
    .admin-content { padding: 1rem; }
}
