:root {
    --green: #25D366;
    --green-dark: #128C7E;
    --green-light: #dcfce7;
    --blue: #3b82f6;
    --blue-light: #dbeafe;
    --red: #ef4444;
    --red-light: #fee2e2;
    --yellow: #f59e0b;
    --yellow-light: #fef3c7;
    --teal: #14b8a6;
    --teal-light: #ccfbf1;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --navbar: #128C7E;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
small { color: var(--text-muted); font-size: 12px; display: block; margin-top: 3px; }

/* Navbar */
.navbar {
    background: var(--navbar);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: 60px;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    margin-right: 1rem;
}
.nav-links {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
}
.nav-links a {
    color: rgba(255,255,255,0.85);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    transition: all 0.2s;
    text-decoration: none;
}
.nav-links a:hover, .nav-links a.active {
    background: rgba(255,255,255,0.2);
    color: white;
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
}
.btn-logout {
    background: rgba(255,255,255,0.15);
    color: white !important;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    border: 1px solid rgba(255,255,255,0.3);
    cursor: pointer;
    text-decoration: none !important;
}
.btn-logout:hover { background: rgba(255,0,0,0.3); }

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--text); }
.page-header p { color: var(--text-muted); margin-top: 4px; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    border-left: 4px solid;
}
.stat-card.green { border-color: var(--green); }
.stat-card.blue { border-color: var(--blue); }
.stat-card.teal { border-color: var(--teal); }
.stat-card.red { border-color: var(--red); }
.stat-icon { font-size: 28px; }
.stat-num { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Cards */
.form-card, .table-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.form-card h3, .table-card h3 { font-size: 16px; margin-bottom: 1rem; color: var(--text); }

/* Quick Actions */
.quick-actions { background: white; border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.quick-actions h3 { margin-bottom: 1rem; }
.action-buttons { display: flex; gap: 12px; flex-wrap: wrap; }

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 1rem; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: white;
    transition: border-color 0.2s;
    font-family: inherit;
    width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn:hover { opacity: 0.88; text-decoration: none; }
.btn-primary { background: var(--green-dark); color: white; }
.btn-success { background: var(--green); color: white; }
.btn-info { background: var(--blue); color: white; }
.btn-warning { background: var(--yellow); color: white; }
.btn-danger { background: var(--red); color: white; }
.btn-full { width: 100%; justify-content: center; }
.btn-large { padding: 12px 24px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.alert-success { background: var(--green-light); color: #166534; border: 1px solid #86efac; }
.alert-error { background: var(--red-light); color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: var(--yellow-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: var(--blue-light); color: #1e40af; border: 1px solid #93c5fd; }

/* Table */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 12px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    background: #f8fafc;
    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}
.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:hover td { background: #f9fafb; }
.empty-row { text-align: center; color: var(--text-muted); padding: 2rem !important; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-sent { background: var(--green-light); color: #166534; }
.badge-failed { background: var(--red-light); color: #991b1b; }
.badge-pending { background: var(--yellow-light); color: #92400e; }
.badge-approved { background: var(--green-light); color: #166534; }
.badge-rejected { background: var(--red-light); color: #991b1b; }
.badge-completed { background: var(--blue-light); color: #1e40af; }
.badge-running { background: var(--yellow-light); color: #92400e; }
.badge-group { background: #f3f4f6; color: #374151; }

/* Search form */
.search-form { display: flex; gap: 8px; }
.search-form input { padding: 7px 12px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 14px; width: 250px; }

/* Template Preview */
.template-preview {
    background: #f8fdf9;
    border: 1.5px solid #86efac;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 1rem 0;
}
.preview-label { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; }
.preview-body { font-size: 14px; color: var(--text); line-height: 1.6; }

/* Form sections */
.form-section { border-top: 1px solid var(--border); padding-top: 1.25rem; margin-top: 1.25rem; }
.form-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.form-section h3 { font-size: 15px; font-weight: 700; margin-bottom: 1rem; color: var(--green-dark); }
.form-section h4 { font-size: 13px; font-weight: 600; margin-bottom: 0.75rem; }

/* Radio/Checkbox groups */
.radio-group { display: flex; flex-direction: column; gap: 10px; }
.radio-group label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: normal; }
.radio-group input { width: auto; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 1rem; }
.tab-btn {
    padding: 8px 18px;
    border: 1.5px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
}
.tab-btn.active { background: var(--green-dark); color: white; border-color: var(--green-dark); }

/* Filter form */
.filter-form .form-row { align-items: flex-end; }

/* Login page */
.login-page {
    background: linear-gradient(135deg, #128C7E 0%, #075E54 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-container {
    background: white;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.wa-icon {
    width: 72px;
    height: 72px;
    background: var(--green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: white;
}
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.login-form { margin-top: 1.5rem; }
.login-hint { text-align: center; margin-top: 1rem; font-size: 12px; color: var(--text-muted); }

/* ─── AUTH PAGES ─────────────────────────────────────────── */
.auth-page { background: linear-gradient(135deg,#128C7E 0%,#075E54 100%); min-height:100vh; display:flex; align-items:center; justify-content:center; padding:1rem; }
.auth-card { background:white; border-radius:16px; padding:2.5rem; width:100%; max-width:520px; box-shadow:0 20px 60px rgba(0,0,0,0.3); }
.auth-logo { text-align:center; margin-bottom:1.75rem; }
.wa-icon-big { width:72px; height:72px; background:var(--green); border-radius:50%; display:flex; align-items:center; justify-content:center; margin:0 auto 1rem; }
.auth-logo h1 { font-size:22px; font-weight:700; }
.auth-logo p  { color:var(--text-muted); font-size:13px; margin-top:4px; }
.auth-form    { margin-top:1.25rem; }
.auth-switch  { text-align:center; margin-top:1rem; font-size:13px; color:var(--text-muted); }
.req { color:var(--red); }

/* ─── PLAN BADGES ────────────────────────────────────────── */
.plan-badge   { display:inline-block; padding:2px 8px; border-radius:4px; font-size:11px; font-weight:700; }
.plan-trial   { background:#fef3c7; color:#92400e; }
.plan-basic   { background:#dbeafe; color:#1d4ed8; }
.plan-pro     { background:#dcfce7; color:#15803d; }
.plan-enterprise { background:#ede9fe; color:#5b21b6; }

/* ─── SETTINGS PAGE ──────────────────────────────────────── */
.webhook-box { background:#f8fafc; border:1px solid var(--border); border-radius:12px; padding:1.25rem; }
.webhook-section { margin-bottom:1.25rem; }
.wh-label { font-size:12px; font-weight:700; color:var(--text-muted); text-transform:uppercase; letter-spacing:.5px; display:block; margin-bottom:6px; }
.wh-url-row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.wh-url-row code { flex:1; background:white; border:1.5px solid var(--border); border-radius:8px; padding:9px 14px; font-size:12.5px; word-break:break-all; min-width:0; }
.copy-btn { padding:8px 14px; background:var(--green-dark); color:white; border:none; border-radius:7px; font-size:12px; font-weight:600; cursor:pointer; white-space:nowrap; }
.copy-btn:hover { opacity:.88; }
.webhook-steps { background:white; border-radius:8px; padding:12px 16px; margin:1rem 0; font-size:13px; }
.webhook-steps ol { padding-left:1.25rem; margin-top:6px; line-height:2; color:var(--text-muted); }
.info-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:12px; }
.info-item { background:#f8fafc; border-radius:8px; padding:12px 14px; }
.info-item span { display:block; font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:var(--text-muted); margin-bottom:4px; }
.info-item strong { font-size:14px; }

/* ─── NAVBAR COMPANY ─────────────────────────────────────── */
.nav-company { font-size:13px; color:rgba(255,255,255,.9); max-width:140px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ─── MISC ───────────────────────────────────────────────── */
.btn-outline { background:white; color:var(--text); border:1.5px solid var(--border); padding:8px 16px; border-radius:8px; font-size:13px; font-weight:600; cursor:pointer; text-decoration:none; display:inline-flex; align-items:center; gap:5px; transition:all .2s; }
.btn-outline:hover { border-color:var(--green-dark); color:var(--green-dark); text-decoration:none; }
