@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --brand-primary:   #81A6C6;
    --brand-accent:    #AACDDC;
    --brand-cream:     #F3E3D0;
    --brand-taupe:     #D2C4B4;
    --brand-dark:      #4A6F8E;
    --brand-darker:    #3A5A73;
    --brand-light:     #E8F0F6;
    --brand-white:     #FFFFFF;
    --text-dark:       #2D3748;
    --text-body:       #4A5568;
    --text-muted:      #8A7A6A;
    --sidebar-width:   240px;
    --topbar-height:   58px;
    --radius:          .55rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body { font-family: 'Inter', sans-serif; background: var(--brand-cream); color: var(--text-dark); min-height: 100vh; margin: 0; }

a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand-darker); }

/* ── Layout ────────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width); height: 100vh; position: fixed; top: 0; left: 0; z-index: 100;
    background: var(--brand-darker); display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-brand {
    height: var(--topbar-height); display: flex; align-items: center; padding: 0 18px; gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.1); flex-shrink: 0;
}
.sidebar-brand .brand-icon {
    width: 34px; height: 34px; background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.sidebar-brand .brand-text { font-size: 1.1rem; font-weight: 700; letter-spacing: 1px; color: #fff; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar-nav .nav-section { margin-bottom: 20px; }
.sidebar-nav .nav-section-title {
    font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
    color: var(--brand-taupe); padding: 0 10px; margin-bottom: 6px;
}
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius);
    color: rgba(255,255,255,.7); font-size: .86rem; font-weight: 500;
    transition: all .15s ease; margin-bottom: 2px; text-decoration: none;
}
.sidebar-nav .nav-link i { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--brand-primary); color: #fff; }

.main-content { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-height); background: var(--brand-white); border-bottom: 1px solid rgba(210,196,180,.4);
    display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
    position: sticky; top: 0; z-index: 90; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.topbar .page-title { font-size: 1.05rem; font-weight: 600; color: var(--text-dark); }
.topbar .topbar-actions { display: flex; align-items: center; gap: 12px; }

.content-area { flex: 1; padding: 24px; }

/* ── Cards ─────────────────────────────────────────────────── */
.rp-card {
    background: var(--brand-white); border: 1px solid rgba(210,196,180,.35);
    border-radius: var(--radius); padding: 22px; transition: all .2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.rp-card:hover { box-shadow: 0 4px 12px rgba(129,166,198,.12); }
.rp-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid rgba(210,196,180,.3);
}
.rp-card-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-dark); margin: 0; }

/* ── Stat Cards ────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--brand-white); border: 1px solid rgba(210,196,180,.35); border-radius: var(--radius);
    padding: 20px; display: flex; align-items: flex-start; gap: 14px;
    transition: all .2s ease; position: relative; overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: var(--radius) var(--radius) 0 0; }
.stat-card.blue::before   { background: var(--brand-primary); }
.stat-card.green::before  { background: #10b981; }
.stat-card.amber::before  { background: #f59e0b; }
.stat-card.purple::before { background: #8b5cf6; }
.stat-card.cyan::before   { background: var(--brand-accent); }
.stat-card.rose::before   { background: #ef4444; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(129,166,198,.15); }
.stat-card .stat-icon {
    width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem; flex-shrink: 0;
}
.stat-card.blue .stat-icon   { background: var(--brand-light); color: var(--brand-dark); }
.stat-card.green .stat-icon  { background: #d1fae5; color: #059669; }
.stat-card.amber .stat-icon  { background: #fef3c7; color: #d97706; }
.stat-card.purple .stat-icon { background: #ede9fe; color: #7c3aed; }
.stat-card.cyan .stat-icon   { background: #e0f2fe; color: #0891b2; }
.stat-card.rose .stat-icon   { background: #ffe4e6; color: #dc2626; }
.stat-card .stat-info h3 { font-size: 1.35rem; font-weight: 700; color: var(--text-dark); line-height: 1.2; margin: 0; }
.stat-card .stat-info p  { font-size: .78rem; color: var(--text-muted); margin: 2px 0 0; }
a.stat-card-link { text-decoration: none; }
a.stat-card-link:hover .stat-card { border-color: var(--brand-primary); }

/* ── Tables ────────────────────────────────────────────────── */
.rp-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.rp-table thead th {
    padding: 11px 14px; font-size: .73rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .7px; color: var(--text-muted); border-bottom: 2px solid var(--brand-taupe);
    text-align: left; white-space: nowrap; background: transparent;
}
.rp-table tbody tr { transition: background .12s ease; }
.rp-table tbody tr:hover { background: var(--brand-light); }
.rp-table tbody td {
    padding: 12px 14px; font-size: .87rem; border-bottom: 1px solid rgba(210,196,180,.25);
    color: var(--text-body); vertical-align: middle;
}
.rp-table tbody td:first-child { color: var(--text-dark); font-weight: 500; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn-brand {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

.btn-brand:hover {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
}

.btn-outline-brand {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.btn-outline-brand:hover {
    background-color: var(--brand-primary);
    color: #fff;
}

.btn-accent {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
    color: var(--brand-darker);
}

.btn-accent:hover {
    background-color: #90bdd0;
    border-color: #90bdd0;
    color: #fff;
}

.btn-outline-accent {
    border-color: var(--brand-accent);
    color: var(--brand-dark);
}

.btn-outline-accent:hover {
    background-color: var(--brand-accent);
    color: #fff;
}

.btn-taupe {
    background-color: var(--brand-taupe);
    border-color: var(--brand-taupe);
    color: #fff;
}

.btn-taupe:hover {
    background-color: #bfb1a0;
    border-color: #bfb1a0;
    color: #fff;
}

.btn-outline-taupe {
    border-color: var(--brand-taupe);
    color: #8a7a6a;
}

.btn-outline-taupe:hover {
    background-color: var(--brand-taupe);
    color: #fff;
}

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge-brand {
    background-color: var(--brand-primary);
    color: #fff;
}

.badge-accent {
    background-color: var(--brand-accent);
    color: var(--brand-darker);
}

.badge-taupe {
    background-color: var(--brand-taupe);
    color: #fff;
}

.badge-cream {
    background-color: var(--brand-cream);
    color: var(--brand-darker);
    border: 1px solid var(--brand-taupe);
}

.badge-rp {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px;
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}
.badge-rp.primary { background: var(--brand-light); color: var(--brand-dark); border: 1px solid rgba(129,166,198,.3); }
.badge-rp.accent  { background: #e0f2fe; color: #0c7792; border: 1px solid rgba(170,205,220,.4); }
.badge-rp.success { background: #d1fae5; color: #059669; border: 1px solid rgba(16,185,129,.2); }
.badge-rp.warning { background: #fef3c7; color: #b45309; border: 1px solid rgba(245,158,11,.2); }
.badge-rp.danger  { background: #ffe4e6; color: #dc2626; border: 1px solid rgba(239,68,68,.2); }
.badge-rp.muted   { background: #f1f5f9; color: #64748b; border: 1px solid rgba(100,116,139,.15); }
.badge-rp.purple  { background: #ede9fe; color: #7c3aed; border: 1px solid rgba(139,92,246,.2); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-rp {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: var(--radius);
    font-size: .84rem; font-weight: 600; font-family: 'Inter', sans-serif; border: 1px solid transparent;
    cursor: pointer; transition: all .15s ease; text-decoration: none; white-space: nowrap;
}
.btn-rp:hover { transform: translateY(-1px); }
.btn-rp-primary { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); box-shadow: 0 2px 6px rgba(129,166,198,.3); }
.btn-rp-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; box-shadow: 0 4px 12px rgba(129,166,198,.35); }
.btn-rp-accent  { background: var(--brand-accent); color: var(--brand-darker); border-color: var(--brand-accent); }
.btn-rp-accent:hover { background: #90bdd0; color: #fff; }
.btn-rp-success { background: #10b981; color: #fff; box-shadow: 0 2px 6px rgba(16,185,129,.25); }
.btn-rp-success:hover { background: #059669; color: #fff; }
.btn-rp-danger  { background: #ef4444; color: #fff; box-shadow: 0 2px 6px rgba(239,68,68,.25); }
.btn-rp-danger:hover { background: #dc2626; color: #fff; }
.btn-rp-warning { background: #f59e0b; color: #fff; }
.btn-rp-warning:hover { background: #d97706; color: #fff; }
.btn-rp-ghost {
    background: transparent; color: var(--text-body); border: 1px solid var(--brand-taupe);
}
.btn-rp-ghost:hover { background: var(--brand-light); color: var(--brand-darker); border-color: var(--brand-primary); }
.btn-rp-sm { padding: 5px 12px; font-size: .78rem; }
.btn-rp-xs { padding: 3px 8px; font-size: .72rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.rp-form-group { margin-bottom: 16px; }
.rp-label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-body); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
.rp-input, .rp-select, .rp-textarea {
    width: 100%; padding: 9px 13px; background: var(--brand-white); border: 1px solid var(--brand-taupe);
    border-radius: var(--radius); color: var(--text-dark); font-size: .88rem; font-family: 'Inter', sans-serif;
    transition: all .15s ease; outline: none;
}
.rp-input:focus, .rp-select:focus, .rp-textarea:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(129,166,198,.2); }
.rp-input::placeholder { color: var(--brand-taupe); }
.rp-textarea { resize: vertical; min-height: 70px; }
.rp-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23D2C4B4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
.field-validation-error { color: #dc2626; font-size: .76rem; margin-top: 3px; display: block; }
.input-validation-error { border-color: #dc2626 !important; }

/* Bootstrap overrides */
.form-control, .form-select {
    background: var(--brand-white) !important; border: 1px solid var(--brand-taupe) !important;
    color: var(--text-dark) !important; border-radius: var(--radius); font-family: 'Inter', sans-serif;
}
.form-control:focus, .form-select:focus { border-color: var(--brand-primary) !important; box-shadow: 0 0 0 3px rgba(129,166,198,.2) !important; }
.form-check-input { border-color: var(--brand-taupe); }
.form-check-input:checked { background-color: var(--brand-primary); border-color: var(--brand-primary); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(129,166,198,.2); }
.form-check-label { color: var(--text-body); font-size: .85rem; }

/* ── Alerts ─────────────────────────────────────────────────── */
.rp-alert { padding: 12px 18px; border-radius: var(--radius); display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: .84rem; }
.rp-alert.success { background: #d1fae5; border: 1px solid rgba(16,185,129,.2); color: #059669; }
.rp-alert.danger  { background: #ffe4e6; border: 1px solid rgba(239,68,68,.2); color: #dc2626; }
.rp-alert.warning { background: #fef3c7; border: 1px solid rgba(245,158,11,.2); color: #b45309; }
.rp-alert.info    { background: var(--brand-light); border: 1px solid rgba(129,166,198,.2); color: var(--brand-dark); }
.btn-close { opacity: .5; }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 1rem; color: var(--text-body); margin-bottom: 6px; }
.empty-state p { font-size: .82rem; margin-bottom: 16px; }

/* ── Menu Tree ──────────────────────────────────────────────── */
.cat-row { background: rgba(232,240,246,.5); border: 1px solid rgba(210,196,180,.3); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; transition: all .15s ease; }
.cat-row:hover { border-color: var(--brand-primary); }
.sub-border { border-left: 2px solid var(--brand-accent); }

/* ── Login ──────────────────────────────────────────────────── */
.login-bg-tenant { background: linear-gradient(135deg, var(--brand-primary), var(--brand-dark)); }
.login-bg-admin  { background: linear-gradient(135deg, var(--brand-darker), #2a4055); }
.login-card { background: var(--brand-white); border-radius: 14px; box-shadow: 0 8px 32px rgba(0,0,0,.12); }

/* ── Grid Helpers ───────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── SA brand icon ──────────────────────────────────────────── */
.sa-brand { background: linear-gradient(135deg, #8b5cf6, var(--brand-primary)) !important; }

/* ── Lifecycle ──────────────────────────────────────────────── */
.lifecycle-btn { width: 100%; text-align: left; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .grid-2 { grid-template-columns: 1fr; }
}

/* ── Utilities ──────────────────────────────────────────────── */
.text-mono { font-family: 'JetBrains Mono', monospace; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
