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

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.05);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at top left, #1e1b4b, #0f172a);
    color: var(--text);
    margin: 0;
    padding: 12px;
    min-height: 100vh;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    body {
        padding: 20px;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 15px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .container {
        padding: 30px;
    }
}

header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
}

@media (min-width: 768px) {
    header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 20px;
    }
}

header > div:first-child {
    display: flex;
    flex-direction: column;
    width: 100%;
}

@media (min-width: 768px) {
    header > div:first-child {
        width: auto;
    }
}

h1 {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    line-height: 1.2;
}

@media (min-width: 640px) {
    h1 {
        font-size: 2rem;
    }
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-size: 0.95rem;
    white-space: nowrap;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.nav-links {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 5px;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Hide scrollbars but keep horizontal scroll on touch/mobile devices */
.nav-links::-webkit-scrollbar {
    display: none;
}
.nav-links {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}

@media (min-width: 640px) {
    .nav-link {
        font-size: 0.95rem;
        background: transparent;
        padding: 0;
        border-radius: 0;
    }
}

.nav-link:hover,
.nav-link.active {
    color: var(--text);
}

.nav-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

@media (min-width: 640px) {
    .nav-link.active {
        background: transparent;
        color: var(--text);
        border-bottom: 2px solid var(--primary);
        padding-bottom: 4px;
        border-radius: 0;
    }
}

/* Grid Layout for Index */
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 992px) {
    .grid {
        grid-template-columns: 280px 1fr;
        gap: 25px;
    }
}

@media (min-width: 1200px) {
    .grid {
        grid-template-columns: 320px 1fr;
        gap: 30px;
    }
}

/* Category / Sidebar */
.sidebar {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 15px;
    border: 1px solid var(--border);
}

@media (min-width: 640px) {
    .sidebar {
        padding: 20px;
    }
}

.sidebar h2 {
    font-size: 1.1rem;
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-muted);
    font-weight: 600;
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: row;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
}

@media (min-width: 992px) {
    .category-list {
        flex-direction: column;
        overflow-x: visible;
        padding-bottom: 0;
        gap: 0;
    }
}

.category-list::-webkit-scrollbar {
    height: 4px;
}
.category-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.category-item {
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
}

@media (min-width: 992px) {
    .category-item {
        margin-bottom: 8px;
        background: transparent;
        border: none;
        padding: 12px 16px;
        font-size: 0.95rem;
    }
}

.category-item:hover,
.category-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.category-item.active {
    border: 1px solid var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

@media (min-width: 992px) {
    .category-item.active {
        border: none;
        border-left: 4px solid var(--primary);
        background: rgba(99, 102, 241, 0.1);
        border-radius: 0 10px 10px 0;
    }
}

/* Main Content / Table Section */
.main-content {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 15px;
    border: 1px solid var(--border);
    overflow: hidden;
}

@media (min-width: 640px) {
    .main-content {
        padding: 25px;
    }
}

/* Flex header for lists */
.section-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

@media (min-width: 576px) {
    .section-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.section-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

@media (min-width: 640px) {
    .section-header h2 {
        font-size: 1.3rem;
    }
}

.section-header input,
.section-header select {
    width: 100%;
}

@media (min-width: 576px) {
    .section-header input,
    .section-header select {
        width: auto;
    }
}

/* Tables and scrolling */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.15);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 12px 14px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.1);
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

@media (min-width: 768px) {
    th {
        padding: 14px 18px;
        font-size: 0.9rem;
    }
    td {
        padding: 16px 18px;
        font-size: 0.95rem;
    }
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.amount {
    font-weight: 700;
    color: var(--success);
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: inline-block;
    border: 1px solid var(--border);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 15px;
    box-sizing: border-box;
}

.modal-content {
    background: #1e293b;
    padding: 20px;
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    box-sizing: border-box;
    max-height: 90vh;
    overflow-y: auto;
}

@media (min-width: 640px) {
    .modal-content {
        padding: 30px;
    }
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

input,
select {
    width: 100%;
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    color: white;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 140px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.25);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
}

.checkbox-item input {
    width: auto;
    cursor: pointer;
}

/* settlements page styling */
.settlement-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settlement-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.2s, background-color 0.2s;
}

@media (min-width: 576px) {
    .settlement-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
    }
}

.settlement-item:hover {
    transform: translateX(4px);
    background: rgba(255, 255, 255, 0.04);
}

.user-names {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    flex-wrap: wrap;
}

@media (min-width: 576px) {
    .user-names {
        font-size: 1.05rem;
        gap: 12px;
    }
}

.debtor {
    color: var(--danger);
    font-weight: 700;
}

.creditor {
    color: var(--success);
    font-weight: 700;
}

.settlement-item .amount {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fb923c;
}

@media (min-width: 576px) {
    .settlement-item .amount {
        font-size: 1.2rem;
    }
}
