:root {
    --bg: #F8FAFC;
    --panel: #FFFFFF;
    --line: #E2E8F0;
    --text: #0F172A;
    --muted: #475569;
    
    /* Dukaan Ledger Brand Color */
    --brand: #134B9E;
    --brand-light: #1E66D4;
    --brand-gradient: linear-gradient(135deg, #134B9E 0%, #1E66D4 100%);
    
    --danger: #EF4444;
    --warning: #D97706;
    --ok: #10B981;
    
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.04), 0 4px 6px -2px rgba(15, 23, 42, 0.02);
}

* { 
    box-sizing: border-box; 
    transition: all 0.2s ease-in-out; 
}

body {
    margin: 0;
    background: linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 100%);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { 
    text-decoration: none; 
    color: inherit; 
}

.shell { 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column; 
}

/* Glassmorphic header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.header-inner, .footer-inner, .content {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
}

.header-inner {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 0 14px;
    position: relative;
}

.header-top {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.header-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    flex: 1;
}

.brand-link { 
    display: flex; 
    align-items: center; 
    gap: 14px; 
    min-width: 0; 
}

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--brand-gradient);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 20px;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    flex: 0 0 auto;
    box-shadow: 0 6px 16px rgba(19, 75, 158, 0.2);
}

.brand-link:hover .brand-mark { 
    transform: rotate(-5deg) scale(1.03); 
}

.brand-copy { 
    min-width: 0; 
}

.brand-title {
    font-family: 'Outfit', sans-serif;
    font-size: 20px; /* Sleeker, identical to marketing! */
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
    letter-spacing: -0.4px;
}

.brand-sub { 
    font-size: 11px; /* Smaller, smart tagline! */
    color: var(--muted); 
    margin-top: 2px; 
    font-weight: 500; 
    line-height: 1.25;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}

.header-actions { 
    display: flex; 
    align-items: center; 
    justify-content: flex-end;
    gap: 10px; 
    flex-wrap: nowrap; 
}

.top-pill, .header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--text);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.header-btn {
    border-color: var(--brand);
    background: var(--brand-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(19, 75, 158, 0.15);
}

.header-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(19, 75, 158, 0.25);
    background: var(--brand-light);
}

/* Modern navigation links */
.admin-menu {
    width: 100%;
    display: block;
}

.admin-menu-actions {
    display: none;
}

.nav { 
    display: flex; 
    gap: 10px; 
    flex-wrap: wrap; 
    align-items: center;
    padding: 10px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-sm);
}

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    font-weight: 600;
    font-size: 13px;
    box-shadow: none;
}

.nav-link:hover {
    color: var(--brand);
    border-color: var(--brand-light);
    transform: translateY(-1px);
}

.nav-link.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: 0 4px 12px rgba(19, 75, 158, 0.18);
}

.content { 
    padding: 36px 0 54px; 
    flex: 1; 
}

.hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

.hero h1 {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: 38px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.8px;
}

.hero .sub {
    margin-top: 8px;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.5;
    max-width: 800px;
    font-weight: 450;
}

/* Modern rounded cards */
.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 28px;
    box-shadow: var(--shadow-md);
}

.card + .card { 
    margin-top: 24px; 
}

.grid { 
    display: grid; 
    gap: 20px; 
}
.two { 
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
}
.four { 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
}

/* Metrics dashboard cards layout spacing */
.metrics-section {
    margin-bottom: 32px; /* Fixed space between metric cards and table below! */
}

/* Metrics dashboard cards styling */
.metric {
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.metric .label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.metric .value {
    margin-top: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
}

.metric .hint {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 450;
    line-height: 1.4;
}

.metric.info { background: #F0F7FF; border-color: #BFDBFE; }
.metric.info .value { color: #1E40AF; }
.metric.info .label { color: #1D4ED8; }

.metric.ok { background: #ECFDF5; border-color: #A7F3D0; }
.metric.ok .value { color: #065F46; }
.metric.ok .label { color: #047857; }

.metric.warn { background: #FFFBEB; border-color: #FDE68A; }
.metric.warn .value { color: #92400E; }
.metric.warn .label { color: #B45309; }

.muted { 
    color: var(--muted); 
    line-height: 1.5; 
    font-size: 14px; 
}

.label { 
    display: block; 
    margin-bottom: 8px; 
    font-weight: 700; 
    font-size: 14px; 
}

.field { 
    margin-top: 18px; 
}

.check-row {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    justify-content: start;
    gap: 12px;
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid #CBD5E1;
    border-radius: 14px;
    background: #F8FAFC;
    font-weight: 700;
    font-size: 14px;
}

.check-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.check-control input[type="checkbox"] {
    width: 20px !important;
    min-width: 20px;
    max-width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
    accent-color: var(--brand);
    display: block;
    flex: 0 0 20px;
}

.inline-form {
    display: inline;
}

.record-form {
    display: grid;
    gap: 14px;
}

.record-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.record-actions select {
    width: auto;
    min-width: 140px;
}

.small-textarea {
    min-height: 76px;
    min-width: 260px;
}

body.modal-open {
    overflow: hidden;
}

.modal-backdrop[hidden] {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
    width: min(560px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.modal-header h3 {
    margin: 0 0 4px;
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    line-height: 1.15;
}

.modal-close {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
    font-weight: 800;
}

/* Beautiful inputs */
input, textarea, select {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    border: 1px solid #CBD5E1;
    border-radius: 14px;
    font: inherit;
    background: #fff;
    color: var(--text);
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23475569'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px;
    padding-right: 40px !important;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(30, 102, 212, 0.15);
}

textarea { 
    min-height: 120px; 
    resize: vertical; 
}

/* Table Status and Tier Badges */
.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.status-pill.tier-pro {
    background: #EFF6FF;
    color: #1E40AF;
    border-color: rgba(30, 102, 212, 0.15);
}

.status-pill.tier-trial {
    background: #FFFBEB;
    color: #92400E;
    border-color: rgba(245, 158, 11, 0.15);
}

.status-pill.tier-free {
    background: #F1F5F9;
    color: #475569;
    border-color: #E2E8F0;
}

.status-pill.status-active {
    background: #ECFDF5;
    color: #065F46;
    border-color: rgba(16, 185, 129, 0.15);
}

.status-pill.status-paused {
    background: #FFFBEB;
    color: #92400E;
    border-color: rgba(245, 158, 11, 0.15);
}

.status-pill.status-blocked {
    background: #FEF2F2;
    color: #991B1B;
    border-color: rgba(239, 68, 68, 0.15);
}

/* Modern Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    padding: 12px 24px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:disabled,
.btn[disabled] {
    cursor: not-allowed;
    opacity: 0.58;
    filter: grayscale(0.35);
    box-shadow: none;
    pointer-events: none;
}

.btn:disabled:hover,
.btn[disabled]:hover {
    transform: none;
    box-shadow: none;
}

.btn:active { 
    transform: translateY(0); 
}

.btn-primary {
    background: var(--brand-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(19, 75, 158, 0.15);
}

.btn-primary:hover {
    background: var(--brand-gradient);
}

.btn-secondary {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--text);
}

.btn-secondary:hover {
    border-color: var(--brand-light);
    color: var(--brand);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #DC2626;
}

.actions { 
    display: flex; 
    gap: 10px; 
    flex-wrap: wrap; 
    margin-top: 24px; 
}

/* Clean Alerts */
.error, .success {
    padding: 14px 18px;
    border-radius: 16px;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid transparent;
}

.error {
    background: #FEF2F2;
    color: #991B1B;
    border-color: rgba(239, 68, 68, 0.15);
}

.success {
    background: #ECFDF5;
    color: #065F46;
    border-color: rgba(16, 185, 129, 0.15);
}

/* Modern Data Tables & Scrolling pagination setup */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: #fff;
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
}

.table-scroll table { 
    min-width: 800px; 
}

/* Vertical scrolling grid setup if records exceed maximum screen boundaries */
.grid-vertical-scroll {
    max-height: 480px;
    overflow-y: auto;
}

table { 
    width: 100%; 
    border-collapse: collapse; 
}

th, td { 
    padding: 16px 20px; 
    border-bottom: 1px solid var(--line); 
    vertical-align: middle; 
    text-align: left; 
}

th {
    font-size: 12px;
    color: var(--muted);
    background: #F8FAFC;
    white-space: nowrap;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

tr:last-child td { 
    border-bottom: none; 
}

tr:hover td { 
    background-color: #F8FAFC; 
}

/* Stripe rows styling */
tr:nth-child(even) td {
    background-color: #FAFBFD;
}

/* No word wrapping configuration on grid-interactive cells */
.table-scroll td {
    white-space: nowrap;
    font-weight: 500;
    color: #334155;
}

/* Custom Interactive Datatable Toolbar Styles */
.grid-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    background: #FCFDFE;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.grid-toolbar-left {
    display: flex;
    align-items: center;
    flex-grow: 1;
    max-width: 480px; /* Big prominent search bar! */
}

.grid-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.grid-entries-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.grid-toolbar select {
    padding: 8px 36px 8px 12px !important;
    border-radius: 10px;
    font-size: 13px;
    width: auto;
    min-height: 40px;
    background-position: right 10px center;
    background-size: 16px;
    box-shadow: var(--shadow-sm);
    border-color: #CBD5E1;
}

.grid-search-container {
    position: relative;
    width: 100%;
}

.grid-search-container input {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px 8px 38px;
    border-radius: 10px;
    font-size: 13px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 16px;
    box-shadow: var(--shadow-sm);
    border-color: #CBD5E1;
}

/* Custom Interactive Datatable Footer Styles */
.grid-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: #FCFDFE;
    border-top: 1px solid var(--line);
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.grid-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.grid-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.grid-page-btn:hover:not(.disabled):not(.active) {
    border-color: var(--brand-light);
    color: var(--brand);
}

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

.grid-page-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #F1F5F9;
}

/* Footer styling */
.footer {
    border-top: 1px solid var(--line);
    padding: 24px 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    background: #fff;
}
.footer-inner { 
    display: flex; 
    justify-content: space-between; 
    gap: 12px; 
    flex-wrap: wrap; 
}

.empty {
    padding: 40px;
    border: 2px dashed #CBD5E1;
    border-radius: 20px;
    background: #F8FAFC;
    color: var(--muted);
    text-align: center;
    font-weight: 500;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.table-toolbar-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.table-toolbar-controls input {
    max-width: 280px;
}

/* Hamburger menu toggle */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 32px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    align-self: center;
    z-index: 110;
}
.menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: var(--text);
    border-radius: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 1024px) {
    .header-inner {
        gap: 0;
    }
    .header-top {
        align-items: center;
    }
    .menu-toggle {
        display: flex;
    }
    .admin-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fff;
        border-bottom: 1px solid var(--line);
        padding: 24px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        box-shadow: var(--shadow-lg);
        pointer-events: none;
        z-index: 105;
        width: 100%;
    }
    .admin-menu.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
    }
    .nav {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 10px;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }
    .nav-link {
        width: 100%;
        justify-content: center;
        min-height: 46px;
    }
    .header-actions {
        gap: 8px;
    }
    .top-pill, .header-btn {
        justify-content: center;
        min-height: 46px;
        margin: 0;
    }
    .admin-menu-actions {
        display: none;
    }
    
    /* Burger menu lines transform to close (X) */
    .menu-toggle.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }
    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    .menu-toggle.active span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }
    
    .hero { flex-direction: column; }
    .hero h1 { font-size: 32px; }
    
    .grid-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .grid-toolbar-left {
        max-width: 100%;
        width: 100%;
    }
    .grid-toolbar-right {
        justify-content: stretch;
        width: 100%;
        gap: 10px;
    }
    .grid-toolbar-right > * {
        flex-grow: 1;
        width: 100%;
    }
    .grid-entries-selector {
        justify-content: center;
        margin-bottom: 4px;
    }
    .grid-search-container {
        max-width: 100%;
    }
    .grid-footer {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 700px) {
    .header-top {
        gap: 12px;
    }
    .brand-mark {
        width: 46px;
        height: 46px;
        border-radius: 14px;
    }
    .brand-title {
        font-size: 17px;
    }
    .brand-sub {
        display: none;
    }
    .header-actions {
        display: none;
    }
    .admin-menu-actions {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        border-top: 1px solid var(--line);
        padding-top: 16px;
        gap: 10px;
        margin-top: 16px;
    }
    .admin-menu-actions .top-pill,
    .admin-menu-actions .header-btn {
        width: 100%;
    }
    .menu-toggle {
        width: 30px;
    }
}
