:root {
    --primary: #0f172a;
    --secondary: #64748b;
    --accent: #0284c7;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --success: #166534;
    --danger: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    color: #333;
    background-color: var(--bg);
}

/* Tooltip Styles - Mobile Friendly (Click/Hover) */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 5px;
    color: #64748b;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.tooltip:hover::after,
.tooltip.visible::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 140%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    white-space: normal;
    width: 240px;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    line-height: 1.5;
    text-align: left;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s;
}

.tooltip:hover::before,
.tooltip.visible::before {
    content: "";
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
    z-index: 1000;
}

/* Rate Fetcher Style */
.rate-fetcher {
    font-size: 0.8rem; 
    background: #e0f2fe; 
    color: #0284c7; 
    padding: 2px 8px; 
    border-radius: 4px; 
    font-weight: bold;
    display: inline-block;
    transition: background 0.2s, transform 0.1s;
}

.rate-ready:hover {
    background: #bae6fd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.rate-ready:active {
    transform: translateY(0);
}

/* Navbar */
.navbar {
    background: white;
    /* padding handled in index.php via inline style override or keep default here */
    padding: 12px 0; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    display: block;
}

/* Alignment Container */
.nav-content-wrapper { 
    max-width: 600px; 
    margin: 0 auto; 
    width: 100%; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 15px; 
    box-sizing: border-box;
}

.nav-logo {
    font-weight: 900;
    font-size: 1.2rem;
    text-decoration: none;
    color: var(--primary);
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.nav-actions {
    display: flex;
    align-items: center; /* Vertical center */
    gap: 8px;
}

/* Make form behave like a flex item wrapper */
.nav-actions form {
    display: flex;
    margin: 0;
    padding: 0;
}

/* UNIFIED BUTTON STYLES for <a> and <button> */
.nav-btn {
    background: #f1f5f9;
    border: none; /* Reset default border */
    height: 36px; /* Fixed height for consistency */
    padding: 0 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--secondary);
    text-decoration: none;
    
    /* Flex alignment for content inside button */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    
    transition: background 0.2s;
    box-sizing: border-box; /* Ensure padding doesn't affect height */
    line-height: 1; /* Reset line height */
    vertical-align: middle;
    font-family: inherit; /* Ensure font matches */
}

.nav-btn:hover {
    background: #e2e8f0;
    color: var(--primary);
}

.lang-btn {
    font-weight: bold;
    color: var(--accent);
}

/* Home Header */
.home-header {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    margin-bottom: 20px;
}

.home-logo {
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    backdrop-filter: blur(5px);
}

.home-logo-main {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary);
    text-decoration: none;
    display: block;
}

.home-logo-sub {
    font-size: 0.85rem;
    color: var(--secondary);
    font-weight: bold;
    margin-top: 5px;
    letter-spacing: 0.5px;
}

.home-lang {
    position: absolute;
    right: 20px;
    top: 20px;
}

.lang-pill {
    text-decoration: none;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--secondary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.lang-pill:hover {
    transform: scale(1.05);
    color: var(--accent);
}

/* Container & Cards */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 10px;
    padding-bottom: 50px; /* Space for footer */
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

h3 { margin-top: 0; color: var(--primary); }

/* Forms */
label {
    display: block;
    margin: 10px 0 5px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary);
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1rem;
    background: #fff;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

button {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    transition: opacity 0.2s;
}

button:active { opacity: 0.9; }

/* Table */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
td { padding: 12px 5px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.date-header { background: #f8fafc; font-weight: bold; color: var(--secondary); font-size: 0.85rem; }
.date-header td { padding: 5px 10px; }

/* Tags & Badges */
.curr-tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-right: 5px;
}
.curr-base { background: #e0f2fe; color: #0369a1; }
.curr-def { background: #f0fdf4; color: #15803d; }
.curr-other { background: #fefce8; color: #a16207; }

.detail-badge {
    display: inline-block;
    background: #f1f5f9;
    color: #64748b;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-right: 3px;
    margin-top: 2px;
}

/* Splits */
.split-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed #f1f5f9;
}
.split-row:last-child { border-bottom: none; }
.split-inputs { display: flex; gap: 5px; width: 60%; }
.inp-amt { flex: 2; }
.inp-pct { flex: 1; }

/* Currency Tabs */
.currency-tabs { display: flex; gap: 5px; background: #f1f5f9; padding: 4px; border-radius: 8px; }
.currency-tab {
    flex: 1;
    text-align: center;
    padding: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 6px;
    color: var(--secondary);
    font-weight: 500;
}
.currency-tab.active { background: white; color: var(--accent); font-weight: bold; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

/* Documents */
.doc-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 8px;
}
.doc-icon { font-size: 1.5rem; margin-right: 12px; }
.doc-info { flex-grow: 1; overflow: hidden; }
.doc-title { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-note { font-size: 0.8rem; color: var(--secondary); }
.doc-actions { display: flex; gap: 5px; }
.doc-btn {
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
}
.btn-view { background: #e0f2fe; color: #0369a1; }
.btn-edit { background: #f1f5f9; color: #64748b; }
.btn-del { background: #fee2e2; color: #991b1b; }

/* Helper Classes */
.row { display: flex; gap: 10px; margin-bottom: 10px; }
.col-grow { flex-grow: 1; }
.col-date { width: 140px; }
.alert-box { padding: 15px; border-radius: 8px; margin-bottom: 20px; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.recent-link { display: flex; justify-content: space-between; color: #333; text-decoration: none; }
.locked-tag { background: #fee2e2; color: #991b1b; padding: 2px 8px; border-radius: 12px; font-size: 0.7rem; vertical-align: middle; }

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 30px;
}
.footer a {
    color: var(--secondary);
    text-decoration: none;
    border-bottom: 1px dashed #94a3b8;
    cursor: pointer;
}
.footer a:hover { color: var(--primary); border-bottom-style: solid; }

/* Modals */
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); overflow-y: auto; }
.modal-content { background-color: white; margin: 10% auto; padding: 25px; border-radius: 12px; width: 90%; max-width: 500px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); position: relative; }
.settle-btn { padding: 4px 10px; font-size: 0.75rem; width: auto; margin: 0; }
.settle-details-box { background: #f8fafc; padding: 10px; border-radius: 6px; font-size: 0.85rem; max-height: 150px; overflow-y: auto; color: #475569; }

/* Info Box in Modal (if reused) */
.info-box { background: #f8fafc; padding: 15px; border-radius: 8px; margin-bottom: 15px; border: 1px solid #e2e8f0; }
.info-box h4 { margin: 0 0 8px 0; color: var(--primary); font-size: 1rem; }
.info-box p { margin: 0; font-size: 0.9rem; line-height: 1.5; color: #475569; }

/* Print Styles */
@media print {
    .no-print { display: none !important; }
    body { background: white !important; color: black; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    .container { max-width: 100%; padding-bottom: 0; }
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .navbar span { display: none; } /* Hide label text on mobile, show icons only */
    .nav-btn { padding: 0 10px; } /* Slightly tighter on mobile */
    .home-header { flex-direction: column; gap: 15px; }
    .home-lang { position: static; transform: none; align-self: flex-end; }
    /* Tooltip adjustments for mobile */
    .tooltip:hover::after, .tooltip.visible::after { width: 200px; left: -120px; bottom: 130%; }
    .tooltip:hover::before, .tooltip.visible::before { left: 5px; transform: translateX(0); }
    .modal-content { margin: 20% auto; width: 85%; }
    .nav-content-wrapper { padding: 0 10px; }
}