:root {
    --wa-green: #25D366;
    --wa-dark: #075E54;
    --wa-light-bg: #ECE5DD;
    --wa-bubble: #FFFFFF;
    --surface: #F7F8FA;
    --border: #E4E7EC;
    --text: #101828;
    --muted: #667085;
    --accent: #128C7E;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Sora', sans-serif;
    background: var(--surface);
    color: var(--text);
    min-height: 100vh;
}

/* ── Navbar ── */
.navbar-custom {
    background: #FFFFFF;
    border-bottom: 2px solid var(--wa-green);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

.navbar-brand-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.navbar-logo {
    width: 36px;
    height: 36px;
    background: var(--wa-green);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
}

.navbar-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    line-height: 1.1;
}

.navbar-subtitle {
    font-size: 0.7rem;
    color: var(--muted);
    font-family: 'IBM Plex Mono', monospace;
}

.nav-link-custom {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    transition: all .15s;
}

.nav-link-custom:hover,
.nav-link-custom.active {
    color: var(--accent);
    background: rgba(18, 140, 126, .08);
}

/* ── Stats bar ── */
.stats-bar {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    overflow-x: auto;
}

.stat-chip {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem 1.1rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.83rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}

.stat-chip:hover {
    border-color: var(--wa-green);
}

.stat-chip.active {
    border-color: var(--wa-green);
    background: rgba(37, 211, 102, .08);
}

.stat-chip .count {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: 1rem;
}

/* ── Toolbar ── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem 1rem;
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-wrap .bi {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 0.9rem;
}

.search-input {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem 0.5rem 2.2rem;
    font-family: 'Sora', sans-serif;
    font-size: 0.85rem;
    width: 100%;
    background: white;
    transition: border-color .15s;
}

.search-input:focus {
    outline: none;
    border-color: var(--wa-green);
}

.btn-new {
    background: var(--wa-green);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.1rem;
    font-family: 'Sora', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: background .15s;
    text-decoration: none;
}

.btn-new:hover {
    background: var(--wa-dark);
    color: white;
}

/* ── Template Grid ── */
.templates-grid {
    padding: 0 1.5rem 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

.tpl-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.tpl-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, .1);
    transform: translateY(-2px);
}

.tpl-card-header {
    padding: 0.9rem 1rem 0.75rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.tpl-name {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
}

.tpl-lang {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 2px;
}

.tpl-badges {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.badge-sm {
    font-size: 0.68rem;
    padding: 0.25em 0.55em;
    border-radius: 5px;
    font-weight: 600;
}

.tpl-preview-wrap {
    padding: 0.75rem 1rem;
    flex: 1;
    background: var(--wa-light-bg);
}

/* WhatsApp bubble */
.wa-bubble {
    background: var(--wa-bubble);
    border-radius: 0 10px 10px 10px;
    padding: 0.6rem 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
    max-width: 100%;
    font-size: 0.8rem;
    line-height: 1.5;
}

.wa-header-text {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.wa-header-media {
    background: #f0f0f0;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    color: #888;
    font-size: 0.75rem;
    margin-bottom: 0.4rem;
}

.wa-body {
    color: #111;
    word-break: break-word;
}

.wa-footer {
    color: #888;
    font-size: 0.72rem;
    margin-top: 0.4rem;
    border-top: 1px solid #eee;
    padding-top: 0.3rem;
}

.wa-buttons {
    margin-top: 0.4rem;
    border-top: 1px solid #eee;
    padding-top: 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.wa-btn {
    color: #0a85d1;
    font-size: 0.77rem;
    font-weight: 600;
    text-align: center;
    padding: 0.2rem;
    border-top: 1px solid #eee;
}

.wa-btn:first-child {
    border-top: none;
}

.wa-var {
    background: rgba(18, 140, 126, .12);
    color: var(--accent);
    border-radius: 3px;
    padding: 0 3px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78em;
}

.tpl-card-footer {
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    font-size: 0.74rem;
    color: var(--muted);
}

.tpl-actions {
    display: flex;
    gap: 6px;
}

.tpl-action-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all .15s;
}

.tpl-action-btn:hover {
    background: #f0f0f0;
}

.tpl-action-btn.danger:hover {
    background: #fee2e2;
    border-color: #f87171;
    color: #dc2626;
}

/* ── Empty state ── */
.empty-state {
    grid-column: 1/-1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--muted);
}

.empty-state .icon {
    font-size: 3rem;
    color: var(--border);
    margin-bottom: 1rem;
}

/* ── Loading ── */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, .7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.loading-overlay.show {
    display: flex;
}

/* ── Delete modal ── */
.modal-title-mono {
    font-family: 'IBM Plex Mono', monospace;
}

/* ── Toast ── */
.toast-container-custom {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
}

/* ── Rejected reason ── */
.rejected-reason {
    background: #fff3f3;
    border-left: 3px solid #dc2626;
    padding: 0.3rem 0.6rem;
    font-size: 0.72rem;
    color: #dc2626;
    border-radius: 0 4px 4px 0;
    margin-top: 4px;
}