/* ============================================================
   MARTEX PRO SAAS - Admin Panel Styles
   ============================================================ */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --green: #16a34a;
    --green-bg: #dcfce7;
    --orange: #d97706;
    --orange-bg: #fef3c7;
    --red: #dc2626;
    --red-bg: #fee2e2;
    --blue: #2563eb;
    --blue-bg: #dbeafe;
    --purple: #8b5cf6;
    --purple-bg: #f3e8ff;
    --ink: #0f172a;
    --ink-soft: #334155;
    --muted: #64748b;
    --faint: #94a3b8;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --surface: #fff;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
    --shadow-md: 0 8px 30px rgba(15,23,42,.08);
    --shadow-lg: 0 24px 70px rgba(15,23,42,.18);
    --radius: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
code { background: var(--bg); padding: 2px 8px; border-radius: 6px; font-size: .8rem; font-family: "SF Mono", Menlo, Consolas, monospace; }

/* ===================== Shell ===================== */
.saas-shell { display: flex; min-height: 100vh; }
.saas-sidebar {
    width: 240px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column;
    flex-shrink: 0; position: sticky; top: 0; height: 100vh;
}
.saas-logo { display: flex; align-items: center; gap: 12px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.06); }
.logo-mark {
    width: 42px; height: 42px; border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 1rem;
}
.logo-name { font-size: 1rem; font-weight: 800; color: #fff; letter-spacing: .3px; }
.logo-sub { font-size: .65rem; font-weight: 600; color: #6366f1; letter-spacing: 1px; margin-top: 2px; }
.saas-nav { flex: 1; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.saas-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 10px;
    color: #94a3b8; font-size: .88rem; font-weight: 500;
    transition: all .15s;
}
.saas-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.saas-nav a.active { background: linear-gradient(135deg, rgba(99,102,241,.3), rgba(139,92,246,.3)); color: #fff; }
.saas-nav a i { width: 18px; text-align: center; }
.saas-nav .nav-cta {
    margin-top: 12px; background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff !important; justify-content: center; font-weight: 700;
}
.saas-user {
    display: flex; align-items: center; gap: 10px;
    padding: 16px; border-top: 1px solid rgba(255,255,255,.06);
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .85rem;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: .82rem; font-weight: 700; color: #fff; line-height: 1.2; }
.user-role { font-size: .7rem; color: #94a3b8; }
.logout-btn { color: #94a3b8; font-size: 1rem; padding: 8px; border-radius: 8px; }
.logout-btn:hover { background: rgba(220,38,38,.15); color: #fca5a5; }

.saas-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.saas-topbar {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 18px 30px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40;
}
.saas-topbar h1 { font-size: 1.2rem; font-weight: 700; }

.saas-content { padding: 26px 30px; max-width: 1400px; width: 100%; }

/* ===================== Buttons ===================== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px; border-radius: 9px;
    font-size: .85rem; font-weight: 600;
    border: 1px solid var(--border); background: var(--surface); color: var(--ink);
    cursor: pointer; transition: all .15s; text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.95); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-sm { padding: 6px 12px; font-size: .78rem; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-link { color: var(--primary); font-weight: 600; font-size: .85rem; display: inline-flex; align-items: center; gap: 6px; }

/* ===================== Flash messages ===================== */
.flash {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px; border-radius: 12px; margin-bottom: 20px;
    font-size: .9rem; font-weight: 500;
}
.flash button { margin-left: auto; background: none; border: none; font-size: 1.2rem; color: inherit; cursor: pointer; opacity: .6; }
.flash-success { background: var(--green-bg); color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: var(--red-bg); color: #991b1b; border: 1px solid #fecaca; }

/* ===================== Cards & layout ===================== */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    overflow: hidden; margin-bottom: 20px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card-head h3 i { color: var(--primary); }

.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 26px;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow-sm);
}
.stat-icon {
    width: 42px; height: 42px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; margin-bottom: 14px;
}
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.orange { background: var(--orange-bg); color: var(--orange); }
.stat-icon.red { background: var(--red-bg); color: var(--red); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }
.stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.stat-value .unit { font-size: .9rem; font-weight: 600; color: var(--muted); }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* ===================== Tables ===================== */
.saas-table { width: 100%; border-collapse: collapse; }
.saas-table th {
    text-align: left; padding: 12px 18px; background: var(--bg);
    font-size: .72rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
}
.saas-table td {
    padding: 14px 18px; border-bottom: 1px solid #f1f5f9;
    font-size: .88rem;
}
.saas-table tr:last-child td { border-bottom: none; }
.saas-table tr:hover td { background: var(--bg); }

/* ===================== Badges ===================== */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: 20px;
    font-size: .72rem; font-weight: 700;
}
.badge-active { background: var(--green-bg); color: #166534; }
.badge-suspended { background: var(--red-bg); color: #991b1b; }
.badge-pending { background: var(--orange-bg); color: #92400e; }
.badge-cancelled, .badge-archived { background: #f1f5f9; color: #475569; }
.badge-plan { background: var(--blue-bg); color: var(--blue); }

.external-link { color: var(--primary); display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: .82rem; }
.external-link i { font-size: .7rem; opacity: .7; }
.external-link:hover { text-decoration: underline; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--faint); }
.empty-state i { font-size: 2.4rem; color: #cbd5e1; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ===================== Login ===================== */
.saas-login-body {
    background: radial-gradient(circle at top left, #4f46e5, #0f172a 65%);
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.saas-login-wrap { width: 100%; max-width: 420px; }
.saas-login-box {
    background: var(--surface); border-radius: 20px;
    padding: 44px 38px; box-shadow: var(--shadow-lg);
}
.saas-login-header { text-align: center; margin-bottom: 30px; }
.login-mark {
    width: 54px; height: 54px; border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.4rem; font-weight: 800;
    margin: 0 auto 16px;
}
.saas-login-header h1 { font-size: 1.6rem; font-weight: 800; }
.saas-login-header p { color: var(--muted); font-size: .8rem; letter-spacing: 1.5px; margin-top: 4px; font-weight: 600; }
.saas-login-error {
    padding: 13px 16px; border-radius: 10px; margin-bottom: 20px;
    background: var(--red-bg); color: #991b1b; border: 1px solid #fecaca;
    font-size: .87rem; display: flex; align-items: center; gap: 10px;
}

/* ===================== Forms ===================== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; font-size: .8rem; font-weight: 600;
    color: var(--ink-soft); margin-bottom: 6px;
}
.form-group input, .form-group select {
    width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
    border-radius: 10px; font-size: .92rem; font-family: inherit;
    transition: all .15s;
}
.form-group input:focus, .form-group select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-group .hint { display: block; font-size: .72rem; color: var(--muted); margin-top: 6px; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: none; }
.input-suffix .suffix {
    display: flex; align-items: center; padding: 0 14px;
    background: var(--bg); border: 1.5px solid var(--border);
    border-left: none; border-top-right-radius: 10px; border-bottom-right-radius: 10px;
    font-size: .85rem; color: var(--muted); font-weight: 600;
}

.saas-form .form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.saas-form .form-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 18px; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* ===================== Tenant detail ===================== */
.tenant-header { margin-bottom: 22px; }
.tenant-title h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.tenant-sub { display: flex; align-items: center; gap: 14px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 960px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-list { padding: 8px 0; }
.detail-row { display: flex; justify-content: space-between; padding: 11px 22px; border-bottom: 1px solid #f1f5f9; font-size: .88rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row span { color: var(--muted); font-weight: 500; }
.detail-row strong { color: var(--ink); font-weight: 700; }
.detail-row code { font-size: .78rem; }

.action-grid { display: flex; flex-wrap: wrap; gap: 12px; padding: 18px 22px; }
.action-grid form { display: flex; gap: 6px; align-items: center; }
.action-grid select {
    padding: 9px 14px; border: 1px solid var(--border); border-radius: 9px;
    font-size: .85rem; background: var(--surface); cursor: pointer;
}

/* ===================== Plans ===================== */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.plan-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.plan-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.plan-name { font-size: 1.1rem; font-weight: 800; }
.plan-slug { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; font-weight: 600; }
.plan-price { font-size: 1.4rem; font-weight: 800; color: var(--primary); text-align: right; }
.plan-price span { font-size: .7rem; color: var(--muted); font-weight: 600; }
.plan-body { border-top: 1px solid var(--border); padding-top: 14px; }
.plan-stat { font-size: .85rem; color: var(--ink-soft); }
.plan-stat span { font-weight: 800; color: var(--ink); font-size: 1.1rem; margin-right: 4px; }
.plan-note { font-size: .78rem; color: var(--muted); margin-top: 8px; }

/* ===================== Created panel ===================== */
.created-panel {
    display: flex; gap: 20px; padding: 24px;
    background: linear-gradient(135deg, #ecfdf3, #f0fdf4);
    border: 1px solid #bbf7d0; border-radius: var(--radius);
    margin-bottom: 24px;
}
.created-icon { font-size: 2.5rem; color: var(--green); }
.created-body { flex: 1; }
.created-body h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 12px; color: #166534; }
.created-body p { margin-bottom: 8px; font-size: .88rem; color: var(--ink-soft); }
.created-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ===================== Section hints ===================== */
.section-hint {
    display: flex; align-items: center; gap: 8px;
    font-size: .82rem; color: var(--muted);
    padding: 10px 14px; background: var(--blue-bg);
    border-radius: 8px; margin-bottom: 16px;
}
.section-hint i { color: var(--blue); }
