:root {
    --green:       #7cb109;
    --green-dark:  #5c8506;
    --blue:        #1f282f;
    --blue-light:  #2f3d47;
    --red:         #ae160b;
    --orange:      #f0a500;
    --bg:          #f5f7f9;
    --text:        #1f282f;
    --text-muted:  #5a6872;
    --border:      #e1e6ea;
    --radius:      8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Manrope', -apple-system, 'Segoe UI', sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* HEADER */
.site-header {
    background: var(--blue);
    color: #fff;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
}

.logo-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 3px 8px;
    background: var(--green);
    border-radius: 4px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 6px;
    color: rgba(255,255,255,.75);
    font-weight: 500;
    transition: all .15s;
}

.main-nav a:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}

.main-nav .btn-logout {
    color: rgba(255,255,255,.6);
    margin-left: 8px;
}
.main-nav .btn-logout:hover {
    color: #fff;
    background: var(--red);
}

/* BOUTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}

.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }

.btn-outline {
    background: #fff;
    color: var(--blue);
    border-color: var(--border);
}
.btn-outline:hover { border-color: var(--blue); }

.btn-block { width: 100%; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

/* AUTH */
.auth-wrap {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.auth-card h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 6px;
}

.auth-sub {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-card label {
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    margin-top: 10px;
}

.auth-card input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
}
.auth-card input:focus { border-color: var(--green); }
.auth-card .btn { margin-top: 20px; }

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}
.alert-error {
    background: #fde8e6;
    color: var(--red);
    border: 1px solid #f5c6c1;
}

/* PAGE HEAD */
.page-head {
    padding: 32px 0 24px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.page-head-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.page-head h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 4px;
}

.page-head p { color: var(--text-muted); font-size: 14px; }

/* KPI */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    padding: 24px 0;
}

.kpi {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}

.kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--blue);
}

.kpi-value.green  { color: var(--green-dark); }
.kpi-value.red    { color: var(--red); }
.kpi-value.orange { color: var(--orange); }

/* SECTION */
.section { padding: 8px 0 40px; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-head h2 { font-size: 16px; font-weight: 700; color: var(--blue); }
.section-head a { font-size: 13px; color: var(--green-dark); font-weight: 600; }

/* TABLE */
.table-wrap {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
}

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

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }

.table .ref {
    font-weight: 700;
    color: var(--blue);
    font-size: 13px;
}

.table .title {
    color: var(--text);
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table .muted {
    color: var(--text-muted);
    font-size: 13px;
}

/* BADGES */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.prio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.prio-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* EMPTY */
.empty {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
}
.empty h3 { font-size: 16px; color: var(--blue); margin-bottom: 6px; }
.empty p { color: var(--text-muted); font-size: 14px; }

/* FOOTER */
.site-footer {
    padding: 24px 0;
    font-size: 13px;
    color: var(--text-muted);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.logo-img {
    height: 32px;
    width: auto;
    display: block;
    border-radius: 6px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ═══ TICKET — DÉTAIL ═══ */

.breadcrumb {
    padding: 20px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}
.breadcrumb a:hover { color: var(--green-dark); }
.breadcrumb span { margin: 0 6px; }

.ticket-head {
    padding: 16px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.ticket-head-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.ticket-head .ticket-ref {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .05em;
    margin-bottom: 4px;
}

.ticket-head h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 8px;
}

.ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}
.ticket-meta strong { color: var(--blue); font-weight: 600; }

.ticket-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    padding-bottom: 40px;
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    font-size: 13px;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.description {
    font-size: 14px;
    color: var(--text);
}

.thread-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.thread-head h2 { margin-bottom: 0; }

.message {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.message:last-child { border-bottom: 0; }

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
}
.message-avatar.client { background: var(--blue); }
.message-avatar.agent  { background: var(--green); }

.message-body { flex: 1; min-width: 0; }

.message-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    flex-wrap: wrap;
}

.message-author { font-weight: 700; color: var(--blue); }

.message-role {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef1f3;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.message-role.agent {
    background: #eaf5d0;
    color: var(--green-dark);
}

.message-time {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
}

.message-content {
    font-size: 14px;
    color: var(--text);
}

.reply-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.info-row:last-child { border-bottom: 0; }
.info-row .label { color: var(--text-muted); }
.info-row .value { color: var(--blue); font-weight: 600; text-align: right; }

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

.aside-float {
    position: sticky;
    top: 80px;
    align-self: start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.reply-card {
    border-top: 3px solid var(--green);
    margin-top: 24px;
}

.sidebar {
align-self: start;
}

.site-header.is-guest .header-inner {
    justify-content: center;
}
.site-header.is-logged .header-inner {
    justify-content: space-between;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}

.filter-input,
.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    background: #fff;
    color: var(--text);
    outline: none;
}

.filter-input { flex: 1; min-width: 200px; }
.filter-select { min-width: 160px; }

.filter-input:focus,
.filter-select:focus {
    border-color: var(--green);
}
