/*
 * Kockerbeck Stewardship 2025 - Monastic Scribe Theme
 * Medieval manuscript aesthetic with parchment and illuminated text
 */

/* ========== Color Palette ========== */
:root {
    --parchment-light: #F4F1E8;
    --parchment-dark: #E8E5D5;
    --text-primary: #2C1810;
    --text-secondary: #5A4A3A;
    --burgundy: #6B2737;
    --burgundy-light: #8B4757;
    --gold: #C9A961;
    --gold-dark: #A98941;
    --link-blue: #1A3A52;
    --positive-green: #2E7D32;
    --negative-red: #C62828;
    --border-brown: #8B7355;
    --shadow: rgba(0, 0, 0, 0.15);
}

/* ========== Reset & Base Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Crimson Text', 'Georgia', serif;
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--parchment-light) 0%, var(--parchment-dark) 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* Parchment texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(139, 115, 85, 0.03) 2px, rgba(139, 115, 85, 0.03) 4px);
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-weight: 600;
    color: var(--burgundy);
    letter-spacing: 0.5px;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

h2 {
    font-size: 2rem;
    margin-bottom: 0.8rem;
}

h3 {
    font-size: 1.5rem;
    margin-bottom: 0.6rem;
}

/* Numbers in tables and amounts */
.numeric,
.card-amount,
.stat-value {
    font-family: 'Lora', 'Georgia', serif;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ========== Header ========== */
.monastic-header {
    background: linear-gradient(to bottom, var(--parchment-dark), var(--parchment-light));
    border-bottom: 3px solid var(--burgundy);
    box-shadow: 0 4px 8px var(--shadow);
    padding: 2rem 0 1.5rem;
    position: relative;
}

.monastic-header::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
}

.header-content {
    text-align: center;
}

.illuminated-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.drop-cap {
    font-size: 5rem;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--burgundy);
    line-height: 1;
    text-shadow: 2px 2px 4px var(--shadow);
    margin-right: 0.5rem;
    padding: 0.2rem 0.5rem;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.illuminated-title h1 {
    color: var(--text-primary);
    margin: 0;
}

/* Hide mobile K on desktop - drop-cap handles it */
.illuminated-title .mobile-k {
    display: none;
}

.illuminated-title .year {
    color: var(--burgundy);
    font-style: italic;
}

.header-flourish {
    margin-top: 1rem;
    height: 20px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 20"><path d="M0 10 Q 50 0, 100 10 T 200 10" stroke="%236B2737" fill="none" stroke-width="2"/></svg>');
    background-repeat: repeat-x;
    background-position: center;
    opacity: 0.4;
}

/* ========== Navigation ========== */
.monastic-nav {
    background: var(--parchment-dark);
    border-bottom: 2px solid var(--border-brown);
    box-shadow: 0 2px 4px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Hide hamburger on desktop */
.nav-toggle {
    display: none;
}

.nav-ribbon {
    display: flex;
    list-style: none;
    justify-content: center;
    gap: 2rem;
    padding: 0;
    margin: 0;
}

.nav-ribbon li {
    position: relative;
}

.nav-ribbon li a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.nav-ribbon li a:hover {
    color: var(--burgundy);
    background: rgba(107, 39, 55, 0.05);
}

.nav-ribbon li.active a {
    color: var(--burgundy);
    border-bottom-color: var(--burgundy);
    background: rgba(107, 39, 55, 0.1);
}

.nav-icon {
    font-size: 1.2rem;
}

/* Nav Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--parchment-light);
    border: 2px solid var(--burgundy);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 100;
    list-style: none;
    padding: 0.25rem 0;
    margin: 0;
}

.nav-dropdown:last-child .nav-dropdown-menu {
    left: auto;
    right: 0;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu li a {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    border-bottom: none;
    white-space: nowrap;
}

.nav-dropdown-menu li a:hover {
    background: rgba(107, 39, 55, 0.1);
}

.nav-dropdown-menu li.active a {
    color: var(--burgundy);
    background: rgba(107, 39, 55, 0.08);
    border-bottom: none;
}

/* ========== Breadcrumb ========== */
.breadcrumb {
    background: var(--parchment-light);
    border-bottom: 1px solid var(--border-brown);
    padding: 0.75rem 0;
    font-size: 0.9rem;
}

.breadcrumb-path {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.breadcrumb-path a {
    color: var(--link-blue);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-path a:hover {
    color: var(--burgundy);
    text-decoration: underline;
}

.breadcrumb-path .separator {
    color: var(--border-brown);
}

.breadcrumb-path .current {
    color: var(--text-primary);
    font-weight: 600;
}

/* ========== Main Content ========== */
.monastic-main {
    padding: 3rem 0;
    min-height: 60vh;
}

.parchment-page {
    background: var(--parchment-light);
    border: 2px solid var(--border-brown);
    border-radius: 4px;
    padding: 3rem;
    box-shadow:
        0 4px 6px var(--shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    position: relative;
}

/* Decorative corners */
.parchment-page::before,
.parchment-page::after {
    content: '❦';
    position: absolute;
    font-size: 2rem;
    color: var(--gold);
    opacity: 0.3;
}

.parchment-page::before {
    top: 1rem;
    left: 1rem;
}

.parchment-page::after {
    bottom: 1rem;
    right: 1rem;
}

/* ========== Page Header ========== */
.page-header {
    margin-bottom: 2rem;
    text-align: center;
}

.page-title {
    display: inline-block;
    margin: 0;
    padding-bottom: 0.5rem;
}

.illuminated-initial {
    font-size: 3rem;
    font-weight: 700;
    color: var(--burgundy);
    background: linear-gradient(135deg, var(--burgundy) 0%, var(--burgundy-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-right: 0.2rem;
    text-shadow: 2px 2px 4px var(--shadow);
}

.decorative-line {
    height: 2px;
    background: linear-gradient(to right, transparent, var(--burgundy), transparent);
    margin: 1rem auto;
    max-width: 400px;
    position: relative;
}

.decorative-line::before {
    content: '✦';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--parchment-light);
    padding: 0 0.5rem;
    color: var(--burgundy);
}

/* ========== Summary Cards ========== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.summary-card {
    background: linear-gradient(135deg, var(--parchment-dark) 0%, var(--parchment-light) 100%);
    border: 2px solid var(--border-brown);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 4px var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

.card-icon {
    font-size: 3rem;
    line-height: 1;
}

.card-content {
    flex: 1;
}

.card-label {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin: 0 0 0.5rem;
}

.card-amount {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.summary-card.income .card-amount {
    color: var(--positive-green);
}

.summary-card.expense .card-amount {
    color: var(--negative-red);
}

.summary-card.reinvestment .card-amount {
    color: #5B7C99;  /* Muted blue - money moved, not spent */
}

.summary-card.net.positive .card-amount {
    color: var(--positive-green);
}

.summary-card.net.negative .card-amount {
    color: var(--negative-red);
}

/* ========== Section Header ========== */
.section-header {
    margin: 3rem 0 1.5rem;
}

.section-title {
    font-size: 1.5rem;
    text-align: center;
    color: var(--burgundy);
}

/* ========== Filter Display ========== */
.filter-display {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--parchment-dark);
    border: 1px solid var(--border-brown);
    border-radius: 4px;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--parchment-light);
    border: 1px solid var(--burgundy);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.filter-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-value {
    color: var(--burgundy);
    font-weight: 600;
}

.filter-clear {
    background: var(--burgundy);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.filter-clear:hover {
    background: var(--burgundy-light);
}

/* ========== Account Tabs ========== */
.account-tabs {
    margin-bottom: 2rem;
}

.tab-ribbon {
    display: flex;
    gap: 1rem;
    border-bottom: 3px solid var(--burgundy);
    margin-bottom: 1.5rem;
}

.tab-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: var(--parchment-dark);
    border: 2px solid var(--border-brown);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    top: 3px;
}

.tab-button:hover {
    background: var(--parchment-light);
    color: var(--burgundy);
}

.tab-button.active {
    background: var(--parchment-light);
    color: var(--burgundy);
    border-color: var(--burgundy);
    border-bottom: 3px solid var(--parchment-light);
    box-shadow: 0 -2px 4px var(--shadow);
}

.tab-icon {
    font-size: 1.2rem;
}

/* ========== Stats Bar ========== */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    background: linear-gradient(135deg, var(--parchment-dark) 0%, var(--parchment-light) 100%);
    border: 2px solid var(--border-brown);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.stat-label {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--burgundy);
}

/* ========== Toolbar ========== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    border: 2px solid var(--border-brown);
    border-radius: 4px;
    background: var(--parchment-light);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--burgundy);
    box-shadow: 0 0 0 3px rgba(107, 39, 55, 0.1);
}

.toolbar-actions {
    display: flex;
    gap: 1rem;
}

/* ========== Buttons ========== */
.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: 600;
    border: 2px solid;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: var(--burgundy);
    color: white;
    border-color: var(--burgundy);
}

.btn-primary:hover {
    background: var(--burgundy-light);
    border-color: var(--burgundy-light);
    box-shadow: 0 2px 4px var(--shadow);
}

.btn-secondary {
    background: transparent;
    color: var(--burgundy);
    border-color: var(--burgundy);
}

.btn-secondary:hover {
    background: var(--burgundy);
    color: white;
}

/* ========== Tables ========== */
.table-container {
    overflow-x: auto;
    margin-bottom: 2rem;
    border: 2px solid var(--border-brown);
    border-radius: 4px;
    box-shadow: 0 2px 4px var(--shadow);
}

.monastic-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--parchment-light);
    font-size: 1rem;
}

.monastic-table thead {
    background: linear-gradient(to bottom, var(--burgundy), var(--burgundy-light));
    color: white;
}

.monastic-table thead th {
    padding: 1rem;
    text-align: left;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
    border-bottom: 3px solid var(--gold);
}

.monastic-table thead th.numeric {
    text-align: right;
}

.monastic-table thead th.center {
    text-align: center;
}

.monastic-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.monastic-table thead th.sortable:hover {
    background: var(--burgundy-light);
}

.monastic-table thead th.sortable.sorted-asc::after {
    content: ' ▲';
    font-size: 0.7em;
    margin-left: 0.3em;
    color: var(--gold);
}

.monastic-table thead th.sortable.sorted-desc::after {
    content: ' ▼';
    font-size: 0.7em;
    margin-left: 0.3em;
    color: var(--gold);
}

.monastic-table tbody tr {
    border-bottom: 1px solid var(--border-brown);
    transition: background 0.2s;
}

.monastic-table tbody tr:hover {
    background: var(--parchment-dark);
    cursor: pointer;
}

.monastic-table tbody tr:last-child {
    border-bottom: none;
}

.monastic-table tbody td {
    padding: 0.875rem 1rem;
}

.monastic-table tbody td.numeric {
    text-align: right;
}

.monastic-table tbody td.center {
    text-align: center;
}

/* Table cell types */
.category-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.category-name {
    font-weight: 600;
}

.classification-cell {
    font-weight: 600;
}

.date-cell {
    font-family: 'Lora', serif;
    color: var(--text-secondary);
}

.description-cell {
    max-width: 400px;
}

.description-text {
    color: var(--text-primary);
}

.category-badge {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 0.2rem;
}

/* Amount colors */
.positive {
    color: var(--positive-green);
    font-weight: 600;
}

.negative {
    color: var(--negative-red);
    font-weight: 600;
}

/* Row types */
.income-row {
    background: rgba(46, 125, 50, 0.03);
}

.expense-row {
    background: rgba(198, 40, 40, 0.03);
}

/* Links */
.detail-link,
.classification-link {
    color: var(--link-blue);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.detail-link:hover,
.classification-link:hover {
    color: var(--burgundy);
    text-decoration: underline;
}

/* Special cells */
.loading-cell,
.error-cell,
.empty-cell {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.loading-spinner {
    font-family: 'Cinzel', serif;
}

.error-cell {
    color: var(--negative-red);
}

.account-badge {
    font-size: 1.3rem;
}

/* ========== Pagination ========== */
.pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.page-btn {
    padding: 0.5rem 1rem;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    background: var(--parchment-light);
    border: 2px solid var(--border-brown);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    background: var(--parchment-dark);
    border-color: var(--burgundy);
    color: var(--burgundy);
}

.page-btn.active {
    background: var(--burgundy);
    border-color: var(--burgundy);
    color: white;
    font-weight: 600;
}

.page-ellipsis {
    padding: 0.5rem;
    color: var(--text-secondary);
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ========== Footer ========== */
.monastic-footer {
    background: linear-gradient(to top, var(--parchment-dark), var(--parchment-light));
    border-top: 3px solid var(--burgundy);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
}

.footer-flourish {
    height: 20px;
    margin-bottom: 1rem;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 20"><path d="M0 10 Q 50 20, 100 10 T 200 10" stroke="%236B2737" fill="none" stroke-width="2"/></svg>');
    background-repeat: repeat-x;
    background-position: center;
    opacity: 0.4;
}

.footer-text {
    font-family: 'Crimson Text', serif;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .parchment-page {
        padding: 1.5rem;
    }

    .illuminated-title {
        flex-direction: row;
    }

    /* Hide fancy drop-cap on mobile, show inline K */
    .drop-cap {
        display: none;
    }

    .illuminated-title .mobile-k {
        display: inline;
    }

    /* Hamburger toggle button */
    .nav-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
        background: var(--burgundy);
        border: none;
        border-radius: 4px;
        cursor: pointer;
        margin: 0.5rem auto;
    }

    .nav-toggle .hamburger,
    .nav-toggle .hamburger::before,
    .nav-toggle .hamburger::after {
        display: block;
        width: 24px;
        height: 3px;
        background: white;
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    .nav-toggle .hamburger {
        position: relative;
    }

    .nav-toggle .hamburger::before,
    .nav-toggle .hamburger::after {
        content: '';
        position: absolute;
        left: 0;
    }

    .nav-toggle .hamburger::before {
        top: -8px;
    }

    .nav-toggle .hamburger::after {
        top: 8px;
    }

    /* Hamburger animation when open */
    .nav-toggle.open .hamburger {
        background: transparent;
    }

    .nav-toggle.open .hamburger::before {
        top: 0;
        transform: rotate(45deg);
    }

    .nav-toggle.open .hamburger::after {
        top: 0;
        transform: rotate(-45deg);
    }

    /* Collapsible nav */
    .nav-ribbon {
        display: none;
        flex-direction: column;
        gap: 0;
        padding-bottom: 0.5rem;
    }

    .nav-ribbon.open {
        display: flex;
    }

    .nav-ribbon li a {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-brown);
        justify-content: center;
    }

    .nav-dropdown-menu {
        position: static;
        border: none;
        box-shadow: none;
        background: rgba(107, 39, 55, 0.05);
        min-width: auto;
        border-radius: 0;
    }

    .nav-dropdown-menu li a {
        padding-left: 2.5rem;
        font-size: 0.85rem;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        flex-direction: column;
        gap: 1rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: 100%;
    }

    .tab-ribbon {
        flex-direction: column;
        border-bottom: none;
        gap: 0.5rem;
    }

    .tab-button {
        border-radius: 4px;
        border: 2px solid var(--border-brown);
    }

    .tab-button.active {
        border: 2px solid var(--burgundy);
    }

    .monastic-table {
        font-size: 0.9rem;
    }

    .monastic-table thead th,
    .monastic-table tbody td {
        padding: 0.5rem;
    }

    .description-cell {
        max-width: 200px;
    }
}

/* ========== Utilities ========== */
mark {
    background: var(--gold);
    color: var(--text-primary);
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

/* ========== Mobile Responsive Styles ========== */

/* Tablet and below (768px) */
@media (max-width: 768px) {
    /* Typography adjustments */
    body {
        font-size: 16px;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.2rem;
    }

    .container {
        padding: 0 15px;
    }

    /* Header */
    .monastic-header {
        padding: 1.5rem 0 1rem;
    }

    .header-title {
        font-size: 1.5rem;
    }

    .header-subtitle {
        font-size: 0.9rem;
    }

    /* Navigation */
    .nav-ribbon {
        flex-direction: column;
        gap: 0.5rem;
    }

    .nav-item {
        width: 100%;
        text-align: center;
        padding: 0.75rem 1rem;
    }

    /* Summary cards */
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Stats bar */
    .stats-bar {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    .stat-item {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }

    /* Tables - make scrollable horizontally */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }

    .monastic-table {
        font-size: 14px;
        min-width: 600px; /* Prevent table from being too cramped */
    }

    .monastic-table thead th {
        padding: 0.75rem 0.5rem;
        font-size: 13px;
    }

    .monastic-table tbody td {
        padding: 0.75rem 0.5rem;
    }

    /* Hide less important columns on small screens */
    .monastic-table .hide-mobile {
        display: none;
    }

    /* Filter display */
    .filter-display {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filter-badge {
        width: 100%;
    }

    /* Toolbar */
    .toolbar {
        flex-direction: column;
        gap: 1rem;
    }

    .search-box {
        width: 100%;
    }

    .toolbar-actions {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }

    .toolbar-actions button,
    .toolbar-actions .btn-primary,
    .toolbar-actions .btn-secondary {
        width: 100%;
    }

    /* Pagination */
    .pagination-controls {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .page-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.9rem;
    }

    .pagination-info {
        font-size: 0.85rem;
    }

    /* Account tabs */
    .account-tabs .tab-ribbon {
        flex-direction: column;
    }

    .tab-button {
        width: 100%;
    }

    /* Page header */
    .page-header {
        padding: 1.5rem 0;
    }

    .page-title {
        font-size: 1.8rem;
    }

    /* Cards */
    .metacategory-grid {
        grid-template-columns: 1fr;
    }

    /* Buttons */
    .btn-primary,
    .btn-secondary {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

/* Mobile phones (480px and below) */
@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    .container {
        padding: 0 10px;
    }

    .monastic-header {
        padding: 1rem 0 0.75rem;
    }

    .header-title {
        font-size: 1.3rem;
    }

    .header-subtitle {
        font-size: 0.8rem;
    }

    /* Navigation - stack vertically */
    .nav-ribbon {
        gap: 0.25rem;
    }

    .nav-item {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }

    /* Tables */
    .monastic-table {
        font-size: 13px;
        min-width: 500px;
    }

    .monastic-table thead th {
        padding: 0.6rem 0.4rem;
        font-size: 12px;
    }

    .monastic-table tbody td {
        padding: 0.6rem 0.4rem;
    }

    /* Stats */
    .stats-bar {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .stat-label {
        font-size: 0.85rem;
    }

    .stat-value {
        font-size: 0.95rem;
    }

    /* Summary cards */
    .summary-card {
        padding: 1rem;
    }

    .card-title {
        font-size: 0.9rem;
    }

    .card-amount {
        font-size: 1.5rem;
    }

    /* Pagination */
    .page-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.85rem;
        min-width: 35px;
    }

    .pagination-info {
        font-size: 0.8rem;
        padding: 0.5rem 0;
    }

    /* Filter badges */
    .filter-badge {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    /* Illuminated initials - reduce size on mobile */
    .illuminated-initial {
        font-size: 2rem;
    }

    /* Decorative elements - simplify on mobile */
    .decorative-line {
        margin: 0.75rem 0;
    }
}

/* Landscape orientation for phones */
@media (max-width: 768px) and (orientation: landscape) {
    .monastic-header {
        padding: 0.75rem 0 0.5rem;
    }

    .stats-bar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .stat-item {
        width: auto;
        min-width: 45%;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets */
    .nav-item,
    .tab-button,
    .btn-primary,
    .btn-secondary,
    .page-btn {
        min-height: 44px; /* iOS recommended minimum */
    }

    /* Remove hover effects on touch devices */
    .monastic-table tbody tr:hover {
        background: transparent;
    }

    .nav-item:hover {
        background: var(--burgundy);
    }

    /* Active state for touch */
    .monastic-table tbody tr:active {
        background: var(--parchment-dark);
    }

    .btn-primary:active {
        transform: translateY(1px);
    }
}
