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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f3f4f8;
    color: #1c1e26;
}

/* ---------- Auth pages ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}
.auth-box {
    background: #fff;
    padding: 2.5rem;
    border-radius: 16px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-box h1 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.muted { color: #6b7280; font-size: 0.9rem; margin-bottom: 1.25rem; }
.auth-box form label { display: block; font-size: 0.85rem; font-weight: 600; margin: 0.75rem 0 0.3rem; }
.auth-box input, .auth-box select {
    width: 100%; padding: 0.6rem 0.75rem; border: 1px solid #d1d5db;
    border-radius: 8px; font-size: 0.95rem;
}
.auth-box button, .btn {
    width: 100%; margin-top: 1.25rem; padding: 0.7rem;
    background: #4f46e5; color: #fff; border: none; border-radius: 8px;
    font-size: 1rem; font-weight: 600; cursor: pointer; text-align: center;
    text-decoration: none; display: inline-block;
}
.auth-box button:hover, .btn:hover { background: #4338ca; }

.alert { padding: 0.7rem 0.9rem; border-radius: 8px; font-size: 0.9rem; margin-bottom: 1rem; }
.alert-error { background: #fee2e2; color: #b91c1c; }
.alert-success { background: #dcfce7; color: #166534; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px; background: #1c1e26; color: #fff;
    display: flex; flex-direction: column; padding: 1.25rem 1rem;
    position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 1.15rem; font-weight: 700; margin-bottom: 1.5rem; padding: 0 0.5rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.sidebar nav a {
    color: #cbd5e1; text-decoration: none; padding: 0.65rem 0.75rem;
    border-radius: 8px; font-size: 0.92rem;
}
.sidebar nav a:hover { background: #2a2d3a; color: #fff; }
.sidebar nav a.active { background: #4f46e5; color: #fff; }
.sidebar-footer { border-top: 1px solid #333646; padding-top: 1rem; }
.user-chip { font-size: 0.85rem; color: #9ca3af; margin-bottom: 0.5rem; padding: 0 0.5rem; }
.logout-link { display: block; padding: 0.6rem 0.75rem; color: #f87171; text-decoration: none; font-size: 0.9rem; }
.logout-link:hover { background: #2a2d3a; border-radius: 8px; }

.content { flex: 1; padding: 2rem 2.5rem; overflow-x: auto; }
.page-head { margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.6rem; }
.section-title { font-size: 1.15rem; margin: 1.75rem 0 0.75rem; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat-card { background: #fff; border-radius: 12px; padding: 1.1rem 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.stat-label { font-size: 0.8rem; color: #6b7280; margin-bottom: 0.4rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #1c1e26; }

/* ---------- Filter bar ---------- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end;
    background: #fff; padding: 1rem; border-radius: 12px; margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.filter-bar .field { display: flex; flex-direction: column; gap: 0.3rem; }
.filter-bar label { font-size: 0.78rem; color: #6b7280; font-weight: 600; }
.filter-bar input, .filter-bar select {
    padding: 0.5rem 0.65rem; border: 1px solid #d1d5db; border-radius: 8px; font-size: 0.9rem;
}
.filter-bar button {
    padding: 0.55rem 1.1rem; background: #4f46e5; color: #fff; border: none;
    border-radius: 8px; font-weight: 600; cursor: pointer;
}
.filter-bar button:hover { background: #4338ca; }
.btn-ghost { padding: 0.55rem 1rem; color: #4f46e5; text-decoration: none; font-size: 0.9rem; }

/* ---------- Table ---------- */
.table-wrap { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
    text-align: left; background: #f9fafb; color: #6b7280; font-weight: 600;
    padding: 0.7rem 1rem; border-bottom: 1px solid #e5e7eb; white-space: nowrap;
}
tbody td { padding: 0.65rem 1rem; border-bottom: 1px solid #f1f2f4; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }
.msg-cell { white-space: normal; max-width: 320px; }
.empty { text-align: center; color: #9ca3af; padding: 1.5rem; }

.badge { padding: 0.2rem 0.55rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-a2p { background: #e0e7ff; color: #4338ca; }
.badge-p2p { background: #fef3c7; color: #92400e; }
.badge-delivered { background: #dcfce7; color: #166534; }
.badge-failed { background: #fee2e2; color: #b91c1c; }

/* ---------- Pagination ---------- */
.pagination {
    display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; font-size: 0.9rem;
}
.pagination a { color: #4f46e5; text-decoration: none; font-weight: 600; }
.pagination span { color: #6b7280; }

@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; overflow-x: auto; }
    .sidebar nav { flex-direction: row; }
    .brand, .sidebar-footer { display: none; }
    .content { padding: 1.25rem; }
}
