/* =============================================
   FD Tracker - Main Stylesheet
   Dark Theme with Glassmorphism
   ============================================= */

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

/* ---- CSS Custom Properties (Design Tokens) ---- */
:root {
    /* Background colors - Luxurious Obsidian Zinc Theme */
    --bg-primary: #09090b;       /* Zinc 950 (Obsidian black) */
    --bg-secondary: #0f0f11;     /* Charcoal panel */
    --bg-card: #18181b;          /* Zinc 900 panel */
    --bg-card-hover: #202024;    /* Slightly lighter on hover */
    --bg-glass: rgba(24, 24, 27, 0.6);
    --bg-glass-hover: rgba(39, 39, 42, 0.4);
    --bg-input: #18181b;
    --bg-sidebar: #0f0f11;
    --bg-modal: rgba(9, 9, 11, 0.85);

    /* Text colors - zinc scale */
    --text-primary: #fafafa;     /* Zinc 50 */
    --text-secondary: #a1a1aa;   /* Zinc 400 */
    --text-muted: #71717a;       /* Zinc 500 */
    --text-accent: #a78bfa;      /* Light Lavender */

    /* Accent colors */
    --accent-primary: #8b5cf6;         /* Modern Vibrant Violet */
    --accent-primary-hover: #a78bfa;   /* Bright Violet */
    --accent-green: #10b981;           /* Emerald Mint */
    --accent-green-glow: rgba(16, 185, 129, 0.1);
    --accent-amber: #f59e0b;           /* Sunset Amber */
    --accent-amber-glow: rgba(245, 158, 11, 0.1);
    --accent-red: #f43f5e;             /* Crimson Rose */
    --accent-red-glow: rgba(244, 63, 94, 0.1);
    --accent-blue: #3b82f6;            /* Neon Blue */
    --accent-blue-glow: rgba(59, 130, 246, 0.1);
    --accent-purple: #c084fc;          /* Lavender */
    --accent-gold: #fbbf24;            /* Gold Accent */

    /* Borders */
    --border-color: #27272a;           /* Zinc 800 - extremely clean! */
    --border-color-hover: #3f3f46;     /* Zinc 700 */

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.6);
    --shadow-glow-green: 0 0 15px rgba(16, 185, 129, 0.08);
    --shadow-glow-amber: 0 0 15px rgba(245, 158, 11, 0.08);
    --shadow-glow-red: 0 0 15px rgba(244, 63, 94, 0.08);
    --shadow-glow-blue: 0 0 15px rgba(59, 130, 246, 0.08);

    /* Sizing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 0px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 120ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Background gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(59, 130, 246, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

a {
    color: var(--text-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-primary-hover);
}

/* ---- Layout ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-slow), transform var(--transition-slow);
    overflow: hidden;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-green));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.sidebar-logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-primary-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.sidebar-logo-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 16px 12px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
}

.nav-link:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.05));
    color: var(--accent-primary-hover);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 0 4px 4px 0;
}

.nav-link-icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent-primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

.page-header {
    margin-bottom: 32px;
}

.page-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.page-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    transition: all var(--transition-base);
    overflow: hidden;
}

.card:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
}

/* Summary Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
}

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

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.summary-card.green::before { background: linear-gradient(90deg, var(--accent-green), #34d399); }
.summary-card.amber::before { background: linear-gradient(90deg, var(--accent-amber), #fbbf24); }
.summary-card.red::before { background: linear-gradient(90deg, var(--accent-red), #f87171); }
.summary-card.blue::before { background: linear-gradient(90deg, var(--accent-blue), #60a5fa); }
.summary-card.purple::before { background: linear-gradient(90deg, var(--accent-purple), #c084fc); }

.summary-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.summary-card.green .summary-card-icon { background: var(--accent-green-glow); }
.summary-card.amber .summary-card-icon { background: var(--accent-amber-glow); }
.summary-card.red .summary-card-icon { background: var(--accent-red-glow); }
.summary-card.blue .summary-card-icon { background: var(--accent-blue-glow); }
.summary-card.purple .summary-card-icon { background: rgba(168, 85, 247, 0.15); }

.summary-card-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.summary-card-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.2;
}

.summary-card.green .summary-card-value { color: var(--accent-green); }
.summary-card.amber .summary-card-value { color: var(--accent-amber); }
.summary-card.red .summary-card-value { color: var(--accent-red); }
.summary-card.blue .summary-card-value { color: var(--accent-blue); }
.summary-card.purple .summary-card-value { color: var(--accent-purple); }

.summary-card-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ---- FD Group Cards ---- */
.fd-group-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fd-group-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
}

.fd-group-card:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-lg);
}

.fd-group-card.status-active { border-left: 3px solid var(--accent-green); }
.fd-group-card.status-matured { border-left: 3px solid var(--accent-amber); }
.fd-group-card.status-closed { border-left: 3px solid var(--accent-red); }

.fd-group-header {
    padding: 20px 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
    user-select: none;
}

.fd-group-header:hover {
    background: var(--bg-glass-hover);
}

.fd-group-info {
    flex: 1;
}

.fd-group-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.fd-group-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.fd-group-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fd-group-meta-item .icon {
    font-size: 0.9rem;
}

.fd-group-amounts {
    text-align: right;
    flex-shrink: 0;
}

.fd-group-principal {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.fd-group-maturity-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.fd-group-maturity-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-green);
}

.fd-group-expand-icon {
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: transform var(--transition-base);
    padding: 4px;
}

.fd-group-card.expanded .fd-group-expand-icon {
    transform: rotate(180deg);
}

.fd-group-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.fd-group-card.expanded .fd-group-body {
    max-height: 2000px;
}

.fd-group-body-inner {
    padding: 0 24px 20px;
}

.fd-group-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.1);
}

/* ---- Status Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-active {
    background: var(--accent-green-glow);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-matured {
    background: var(--accent-amber-glow);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-closed {
    background: var(--accent-red-glow);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-renewed {
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-created { background: var(--accent-green-glow); color: var(--accent-green); }
.badge-updated { background: var(--accent-blue-glow); color: var(--accent-blue); }
.badge-deleted { background: var(--accent-red-glow); color: var(--accent-red); }

/* Days remaining badge */
.days-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.days-badge.urgent {
    background: var(--accent-red-glow);
    color: var(--accent-red);
}

.days-badge.soon {
    background: var(--accent-amber-glow);
    color: var(--accent-amber);
}

.days-badge.safe {
    background: var(--accent-green-glow);
    color: var(--accent-green);
}

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: var(--bg-glass-hover);
}

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

.data-table .amount {
    font-family: 'Inter', monospace;
    font-weight: 600;
    color: var(--accent-gold);
}

.data-table .rate {
    color: var(--accent-green);
    font-weight: 600;
}

.table-footer {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #7c3aed);
    color: white;
    border-color: rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-primary-hover), #8b5cf6);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
}

.btn-success:hover {
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent-amber), #d97706);
    color: #1a1a1a;
}

.btn-warning:hover {
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
    color: #1a1a1a;
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border-color: var(--border-color-hover);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

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

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

select.form-control option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-readonly {
    background: rgba(255, 255, 255, 0.02);
    border-style: dashed;
    cursor: not-allowed;
}

/* ---- Modals ---- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-modal);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-fast);
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp var(--transition-base);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--accent-red-glow);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---- Dynamic Slip Rows ---- */
.slip-rows-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.slip-row {
    display: grid;
    grid-template-columns: 1fr 100px 100px auto;
    gap: 12px;
    align-items: end;
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    animation: fadeIn var(--transition-fast);
}

.slip-row .remove-slip {
    align-self: end;
    margin-bottom: 2px;
}

/* ---- History Timeline ---- */
.history-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.history-container.show {
    max-height: 5000px;
}

.history-timeline {
    padding: 20px 0;
    position: relative;
}

.history-timeline::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.history-entry {
    position: relative;
    padding-left: 44px;
    margin-bottom: 20px;
}

.history-entry::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    background: var(--bg-primary);
}

.history-entry.action-created::before { border-color: var(--accent-green); }
.history-entry.action-updated::before { border-color: var(--accent-blue); }
.history-entry.action-renewed::before { border-color: var(--accent-amber); }
.history-entry.action-closed::before { border-color: var(--accent-red); }
.history-entry.action-matured::before { border-color: var(--accent-purple); }
.history-entry.action-deleted::before { border-color: var(--accent-red); }

.history-timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.history-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.history-diff {
    margin-top: 8px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.history-diff-old {
    color: var(--accent-red);
    text-decoration: line-through;
    opacity: 0.7;
}

.history-diff-new {
    color: var(--accent-green);
}

/* ---- Activity Log ---- */
.activity-log-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.activity-log-item {
    padding: 16px 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.activity-log-item:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-color-hover);
}

.activity-log-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.activity-log-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.activity-log-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.activity-log-diff {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-base);
}

.activity-log-item.expanded .activity-log-diff {
    max-height: 1000px;
}

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar .form-control {
    width: auto;
    min-width: 150px;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination-btn {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.pagination-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ---- Renewal Steps ---- */
.renewal-steps {
    display: flex;
    gap: 4px;
    margin-bottom: 32px;
}

.renewal-step {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition-base);
}

.renewal-step.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary-hover);
}

.renewal-step.completed {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.renewal-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--border-color);
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 8px;
}

.renewal-step.active .renewal-step-number {
    background: var(--accent-primary);
    color: white;
}

.renewal-step.completed .renewal-step-number {
    background: var(--accent-green);
    color: white;
}

/* Renewal option cards */
.renewal-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 24px 0;
}

.renewal-option-card {
    padding: 24px;
    background: var(--bg-glass);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
}

.renewal-option-card:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.renewal-option-card.selected {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: var(--shadow-glow-blue);
}

.renewal-option-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.renewal-option-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.renewal-option-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Comparison table */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.comparison-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.comparison-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.85rem;
}

.comparison-old {
    color: var(--accent-red);
    text-decoration: line-through;
    opacity: 0.6;
}

.comparison-new {
    color: var(--accent-green);
    font-weight: 600;
}

.comparison-arrow {
    color: var(--text-muted);
    text-align: center;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: slideInRight var(--transition-base);
    box-shadow: var(--shadow-lg);
}

.toast-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.9), rgba(5, 150, 105, 0.9));
    color: white;
}

.toast-error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(220, 38, 38, 0.9));
    color: white;
}

.toast-info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(37, 99, 235, 0.9));
    color: white;
}

/* ---- Loading Spinner ---- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 26, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 10;
}

/* ---- Animations ---- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Staggered card animations */
.fd-group-card {
    animation: slideUp var(--transition-slow);
}

.fd-group-card:nth-child(1) { animation-delay: 0.05s; }
.fd-group-card:nth-child(2) { animation-delay: 0.1s; }
.fd-group-card:nth-child(3) { animation-delay: 0.15s; }
.fd-group-card:nth-child(4) { animation-delay: 0.2s; }
.fd-group-card:nth-child(5) { animation-delay: 0.25s; }

/* ---- Mobile Top and Bottom Navigation Bars (Mobile App layout) ---- */
.mobile-top-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(15, 15, 17, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 999;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.mobile-top-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-top-logo-icon {
    font-size: 1.3rem;
}

.mobile-top-logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-primary-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}

.mobile-top-actions {
    display: flex;
    align-items: center;
}

.mobile-top-action-btn {
    font-size: 1.25rem;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(15, 15, 17, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    width: 20%;
    height: 100%;
    gap: 4px;
    transition: all var(--transition-fast);
}

.mobile-bottom-nav-item:active {
    transform: scale(0.95);
}

.mobile-bottom-nav-item.active {
    color: var(--accent-primary);
}

.mobile-bottom-nav-icon {
    font-size: 1.35rem;
    transition: transform var(--transition-fast);
}

.mobile-bottom-nav-item.active .mobile-bottom-nav-icon {
    transform: translateY(-2px);
}

/* ---- Mobile Toggle ---- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ---- Responsive & Mobile Redesign ---- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        display: none !important; /* Hide sidebar entirely */
    }

    .sidebar-toggle {
        display: none !important; /* Hide floating toggle, replaced by bottom bar & top header */
    }

    .mobile-top-bar {
        display: flex;
    }

    .mobile-bottom-nav {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-top: 72px; /* Clears top header */
        padding-bottom: 88px; /* Clears bottom nav */
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 24px;
    }

    .card-body {
        padding: 16px;
        overflow-x: auto;
    }

    .summary-card {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    .summary-card-icon {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
        margin-bottom: 12px;
    }

    .summary-card-value {
        font-size: 1.4rem;
    }

    .slip-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
        padding: 16px !important;
        padding-top: 44px !important; /* Space for absolute remove icon */
        background: rgba(255, 255, 255, 0.02) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: var(--radius-md) !important;
        position: relative !important;
        margin-bottom: 8px;
    }

    /* Slip Amount spans full width */
    .slip-row > div:nth-child(1) {
        grid-column: 1 / span 2;
    }

    /* No of Slips and Interest Rate side by side */
    .slip-row > div:nth-child(2) {
        grid-column: 1;
    }

    .slip-row > div:nth-child(3) {
        grid-column: 2;
    }

    /* Remove Button absolute positioned */
    .slip-row > div:nth-child(4) {
        position: absolute;
        top: 12px;
        right: 12px;
        margin: 0 !important;
    }

    .slip-row .remove-slip {
        width: 32px !important;
        height: 32px !important;
        border-radius: 50% !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .renewal-options {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .page-header {
        margin-bottom: 20px;
    }

    .page-header h2 {
        font-size: 1.45rem;
    }

    .page-header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    /* Elegant Mobile Stack for FD Group Card Header */
    .fd-group-header {
        flex-direction: column;
        align-items: stretch !important;
        padding: 16px;
        gap: 12px !important;
        position: relative;
    }

    .fd-group-amounts {
        text-align: left;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        border-top: 1px dashed var(--border-color);
        padding-top: 12px;
        margin-top: 4px;
    }

    .fd-group-principal {
        font-size: 1.15rem;
    }

    .fd-group-maturity-value {
        font-size: 1.15rem;
    }

    .fd-group-expand-icon {
        position: absolute;
        right: 16px;
        top: 16px;
        font-size: 0.95rem;
    }

    .fd-group-body-inner {
        padding: 0 16px 16px;
    }

    /* Mobile Table Overhaul: Convert wide table columns to touch cards */
    /* Mobile Table Overhaul: Convert wide table columns to touch cards globally */
    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table thead {
        display: none; /* Hide wide table headers */
    }

    .data-table tr {
        border: 1px solid var(--border-color);
        background: rgba(255, 255, 255, 0.01);
        border-radius: var(--radius-md);
        padding: 12px 14px;
        margin-bottom: 12px;
    }

    .data-table td {
        border-bottom: 1px dashed rgba(255, 255, 255, 0.03);
        padding: 8px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
    }

    .data-table td:last-child {
        border-bottom: none;
    }

    /* Display attribute label on the left, value on the right */
    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-align: left;
        font-size: 0.82rem;
    }

    /* Mobile Redesign for the FD Summary Card (Receipt grid view) */
    .fd-group-body-inner .fd-summary-card {
        padding: 14px 16px;
        gap: 10px;
    }
    
    .fd-group-body-inner .fd-summary-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .fd-group-body-inner .fd-summary-col {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        font-size: 0.85rem;
    }
    
    .fd-group-body-inner .fd-summary-col.text-right {
        align-items: flex-end;
    }
    
    .fd-group-body-inner .fd-summary-label {
        font-size: 0.75rem;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .fd-group-body-inner .fd-summary-val {
        font-size: 1.05rem;
    }

    /* 2x2 Grid display for meta parameters on mobile header */
    .fd-group-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 12px;
        width: 100%;
        font-size: 0.8rem;
    }

    .fd-group-actions {
        padding: 12px 16px;
        gap: 8px;
    }

    .btn {
        padding: 12px 16px; /* High touch-friendly sizes */
        font-size: 0.9rem;
    }

    /* Modern 2x2 Grid filter bar for activity log and lists pages */
    .filter-bar {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        margin-bottom: 16px;
    }

    .filter-bar .form-control {
        width: 100% !important;
        padding: 12px;
        margin: 0 !important;
    }

    .filter-bar .btn {
        grid-column: 1 / span 2;
        justify-content: center;
        padding: 12px;
    }

    /* Mobile-optimized Tenure and Date input fields row */
    .tenure-date-row {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
    }

    .tenure-date-row > div:nth-child(1) {
        grid-column: 1 / span 3 !important;
    }

    .tenure-date-row > div:nth-child(2),
    .tenure-date-row > div:nth-child(3),
    .tenure-date-row > div:nth-child(4) {
        grid-column: auto !important;
    }

    /* Redesigned 2x2 form summary block for mobile */
    form .card .card-body .form-row[style*="grid-template-columns"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 16px 12px !important;
    }
}

@media (max-width: 480px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    html {
        font-size: 13px;
    }
}

/* ---- Redesigned FD Group Summary Card (Desktop & General) ---- */
.fd-summary-card {
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fd-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.fd-summary-col {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.fd-summary-label {
    color: var(--text-secondary);
}

.fd-summary-val {
    font-weight: 700;
}

.fd-summary-divider {
    height: 1px;
    border-bottom: 1px dashed var(--border-color);
    margin: 2px 0;
}

/* ---- Utility Classes ---- */
.text-green { color: var(--accent-green); }
.text-amber { color: var(--accent-amber); }
.text-red { color: var(--accent-red); }
.text-blue { color: var(--accent-blue); }
.text-gold { color: var(--accent-gold); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'Inter', monospace; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }

/* Closure modal radio options */
.closure-option {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.closure-option:hover {
    border-color: var(--border-color-hover);
    background: var(--bg-glass-hover);
}

.closure-option.selected {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.closure-option label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}

.closure-option input[type="radio"] {
    accent-color: var(--accent-primary);
}

.closure-option .closure-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    padding-left: 26px;
}

/* ---- Mobile Sub-Tab Control (Segmented Control) ---- */
.mobile-sub-tabs {
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 16px;
    gap: 4px;
}

.mobile-sub-tab {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.mobile-sub-tab.active {
    background: var(--accent-primary);
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .mobile-sub-tabs {
        display: flex;
    }
}
