:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --ink: #1f2937;
    --muted: #6b7280;
    --primary: #0f766e;
    --primary-2: #115e59;
    --danger: #b91c1c;
    --line: #e5e7eb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--ink);
}

header {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 14px 20px;
    position: sticky;
    top: 0;
}

h1 {
    margin: 0 0 8px;
    font-size: 1.2rem;
}

nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

nav a {
    text-decoration: none;
    color: var(--primary-2);
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}

main {
    padding: 18px;
    max-width: 1200px;
    margin: 0 auto;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
}

.card strong {
    display: block;
    font-size: 1.5rem;
}

.card span {
    color: var(--muted);
}

.form-box {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 18px;
}

form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
}

input,
select,
button {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.95rem;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
}

button:hover {
    background: var(--primary-2);
}

.danger {
    background: var(--danger);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #f8fafc;
}

.actions {
    display: grid;
    gap: 6px;
    min-width: 140px;
}

.inline-form {
    display: block;
}

.flash-list {
    list-style: none;
    padding: 0;
}

.flash-list li {
    background: #ecfeff;
    border: 1px solid #99f6e4;
    color: #134e4a;
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.chat-toggle {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: auto;
    padding: 10px 14px;
    border-radius: 999px;
    z-index: 30;
    box-shadow: 0 6px 20px rgba(15, 118, 110, 0.25);
}

.chat-widget {
    position: fixed;
    right: 18px;
    bottom: 66px;
    width: min(360px, calc(100vw - 24px));
    background: #ffffff;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(2, 8, 23, 0.15);
    z-index: 40;
    overflow: hidden;
}

.chat-widget.hidden {
    display: none;
}

.chat-head {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: grid;
}

.chat-head small {
    color: #64748b;
}

.chat-messages {
    max-height: 260px;
    overflow-y: auto;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.chat-line {
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.35;
}

.chat-line.user {
    background: #e0f2fe;
    justify-self: end;
    max-width: 90%;
}

.chat-line.bot {
    background: #f1f5f9;
    justify-self: start;
    max-width: 95%;
}

.chat-form {
    border-top: 1px solid #e2e8f0;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.chat-form input {
    min-width: 0;
}

.pager {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.pager-actions {
    display: flex;
    gap: 8px;
}

.pager-actions a {
    text-decoration: none;
    color: var(--primary-2);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px 10px;
    background: #f8fafc;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-hot {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-warm {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-cold {
    background: #e2e8f0;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.meta {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 0.75rem;
}

@media (max-width: 820px) {
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead {
        display: none;
    }

    tr {
        border-bottom: 1px solid var(--line);
        margin-bottom: 12px;
        background: var(--card);
        border-radius: 8px;
        padding: 6px;
    }

    td {
        border: none;
        padding: 6px 8px;
    }

    .chat-widget {
        right: 10px;
        left: 10px;
        width: auto;
    }
}