* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
}

a {
    color: #2563eb;
    text-decoration: none;
}

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

.sidebar {
    width: 260px;
    background: #111827;
    color: #fff;
    padding: 24px;
}

.logo {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 30px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav a {
    color: #fff;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,.04);
}

.nav a:hover {
    background: rgba(255,255,255,.12);
}

.content {
    flex: 1;
    padding: 30px;
}

.card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 25px rgba(0,0,0,.05);
    margin-bottom: 24px;
}

.card-header,
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

h1, h2 {
    margin-top: 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 18px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

input,
select,
textarea,
button {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    font-size: 15px;
}

textarea {
    resize: vertical;
}

button,
.btn {
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    display: inline-block;
    text-align: center;
    padding: 12px 18px;
    border-radius: 12px;
}

.btn-secondary {
    background: #374151;
}

.alert {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 8px 25px rgba(0,0,0,.05);
}

.stat-card span {
    display: block;
    color: #6b7280;
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 28px;
}

.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge.open { background: #dbeafe; color: #1d4ed8; }
.badge.pending { background: #fef3c7; color: #b45309; }
.badge.answered { background: #dcfce7; color: #15803d; }
.badge.closed { background: #e5e7eb; color: #374151; }

.badge.low { background: #e0f2fe; color: #0369a1; }
.badge.medium { background: #ede9fe; color: #6d28d9; }
.badge.high { background: #fee2e2; color: #b91c1c; }
.badge.urgent { background: #fecaca; color: #7f1d1d; }

.ticket-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 14px;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 16px;
}

.message.internal {
    background: #fff7ed;
    border-color: #fdba74;
}

.message-head {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.message-head span,
.message-head small {
    color: #6b7280;
}

.internal-tag {
    display: inline-block;
    margin-bottom: 10px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #fb923c;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.logs {
    padding-left: 18px;
}

.auth-wrap {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    max-width: 440px;
    width: 100%;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: auto;
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .ticket-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .content {
        padding: 18px;
    }

    .form-grid,
    .meta-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}