/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, sans-serif; background: #f9f9f9; overflow-x: hidden; }

/* ===== Top Header Bar ===== */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1e3a8a;
    color: #fff;
    padding: 0 20px;
    height: 54px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    gap: 12px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1;
}

.site-header .page-title {
    font-size: 17px;
    font-weight: bold;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.quick-links a {
    color: #dbeafe;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.quick-links a:hover { background: rgba(255,255,255,0.12); color: #fff; }
.quick-links a.active { background: rgba(255,255,255,0.18); color: #fff; }

/* ===== Header Right & User Info (修復按鈕跌落下一行) ===== */
.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 15px;
    flex-shrink: 0;
}

.site-header .user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    white-space: nowrap;
}
.site-header .user-info span { font-weight: bold; }

/* ===== Hamburger Button ===== */
.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0; /* 防止按鈕被壓縮 */
}
.hamburger-btn:hover { background: rgba(255,255,255,0.15); }
.hamburger-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s;
}
/* 漢堡按鈕 X 動畫 */
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== Slide-in Side Menu ===== */
.side-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1100;
}
.side-menu-overlay.open { display: block; }

.side-menu {
    position: fixed;
    top: 0; right: -400px;
    min-width: 280px;
    max-width: 85vw; /* 防止喺超細螢幕被斬開 */
    height: 100dvh;
    background: #1e293b;
    color: #e2e8f0;
    z-index: 1200;
    transition: right 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: -2px 0 8px rgba(0,0,0,0.2);
}
.side-menu.open { right: 0; }

.side-menu-header {
    padding: 18px 20px;
    background: #0f172a;
    border-bottom: 1px solid #334155;
}
.side-menu-header .user-name { font-size: 16px; font-weight: bold; color: #fff; word-break: break-all; }
.side-menu-header .user-email { font-size: 12px; color: #94a3b8; margin-top: 3px; word-break: break-all; }
.side-menu-header .user-subscription-expiry{
    margin-top: 6px;
    font-size: 13px;
    color: #64748b;
}
.side-menu-header .user-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    background: #3b82f6;
    color: #fff;
}
.side-menu-header .user-badge.admin { background: #dc2626; }

.side-menu nav { flex: 1; padding: 10px 0; }
.side-menu nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 22px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
    white-space: normal; /* 允許文字太長時自動換行，防止斬字 */
    line-height: 1.4;
}
.side-menu nav a:hover { background: #334155; color: #fff; }
.side-menu nav a.active {
    background: #1e3a8a;
    color: #fff;
    border-left-color: #60a5fa;
}
.side-menu nav a .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.side-menu nav .menu-section {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1.2px;
    color: #64748b;
    padding: 14px 22px 4px;
    text-transform: uppercase;
}
.side-menu nav hr { border: none; border-top: 1px solid #334155; margin: 6px 0; }

.side-menu-footer {
    padding: 14px 22px;
    border-top: 1px solid #334155;
}
.side-menu-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f87171;
    font-size: 14px;
    text-decoration: none;
}
.side-menu-footer a:hover { color: #fca5a5; }

/* ===== Page Content Wrapper ===== */
.page-content { padding: 10px; }
.container { display: flex; gap: 10px; flex-wrap: wrap; }
.form-section { flex: 1; min-width: 320px; padding: 20px; background: #fff; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);}
.result-section { flex: 2; min-width: 500px; padding: 20px; background: #fff; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); height: calc(100dvh - 74px); overflow-y: auto; }
.input-group { margin-bottom: 12px; display: flex; align-items: center; }
.input-group label { width: 150px; font-weight: bold; font-size: 14px; flex-shrink: 0; }
.input-group input, .input-group select { padding: 6px; border: 1px solid #ccc; border-radius: 4px; width: 100%; }
.currency-toggle { margin-bottom: 15px; padding: 12px; background: #e2e8f0; border-radius: 5px; font-weight: bold; }

/* ===== Table Styles ===== */
#table-container { width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; white-space: nowrap; }
th, td { border: 1px solid #cbd5e1; padding: 8px; text-align: right; }
th { background: #1e3a8a; color: white; text-align: center; }
td:nth-child(1), td:nth-child(2) { text-align: center; }
tr:nth-child(even) { background-color: #f8fafc; }
tr:hover { background-color: #e2e8f0; }

/* ===== Responsive Adjustments (修復窄螢幕問題) ===== */
@media (max-width: 860px) {
    .container { flex-direction: column; }
    .form-section, .result-section { min-width: 100%; width: 100%; flex: none; }
}

@media (max-width: 640px) {
    .site-header { padding: 0 12px; }
    .header-left { gap: 10px; min-width: 0; }
    .site-header .page-title { font-size: 15px; max-width: 52vw; }
    .quick-links { display: none; }
}

@media (max-width: 480px) {
    .hamburger-btn { padding: 4px; }
    .hamburger-btn span { width: 22px; }
    .input-group { flex-direction: column; align-items: flex-start; gap: 5px; }
    .input-group label { width: auto; }
}