/* ============================================================
   Finance Monitor - Global Stylesheet
   全站唯一CSS文件，所有页面都引用这一份，不另外写style。
   配色参考：白色背景 + 紫色高亮（仿用户提供的UI参考图）
   ============================================================ */

:root {
    --fm-primary: #7c5cff;
    --fm-primary-dark: #6a47f0;
    --fm-primary-light: #f1edff;
    --fm-bg: #f5f6fa;
    --fm-card-bg: #ffffff;
    --fm-text: #1f2937;
    --fm-text-muted: #6b7280;
    --fm-border: #e5e7eb;
    --fm-danger: #ef4444;
    --fm-danger-light: #fef2f2;
    --fm-success: #16a34a;
    --fm-radius: 10px;
    --fm-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--fm-bg);
    color: var(--fm-text);
    font-size: 14px;
}

a { color: var(--fm-primary); text-decoration: none; }

/* ============================================================
   Login Page
   ============================================================ */
.fm-login-body {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fm-login-wrap {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.fm-login-card {
    background: var(--fm-card-bg);
    border-radius: var(--fm-radius);
    box-shadow: var(--fm-shadow);
    padding: 36px 32px;
}

.fm-login-logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--fm-primary);
    margin-bottom: 4px;
}

.fm-login-sub {
    color: var(--fm-text-muted);
    margin: 0 0 24px;
    font-size: 13px;
}

.fm-field { margin-bottom: 16px; }

.fm-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--fm-text);
}

.fm-field input[type="text"],
.fm-field input[type="password"],
.fm-field input[type="number"],
.fm-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--fm-border);
    border-radius: var(--fm-radius);
    font-size: 14px;
    background: #fff;
    color: var(--fm-text);
}

.fm-field input:focus, .fm-input-large:focus {
    outline: none;
    border-color: var(--fm-primary);
    box-shadow: 0 0 0 3px var(--fm-primary-light);
}

.fm-captcha-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.fm-captcha-row img {
    border-radius: 6px;
    border: 1px solid var(--fm-border);
}

/* ============================================================
   Buttons
   ============================================================ */
.fm-btn-primary {
    background: var(--fm-primary);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: var(--fm-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.fm-btn-primary:hover { background: var(--fm-primary-dark); }
.fm-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.fm-btn-ghost {
    background: transparent;
    border: 1px solid var(--fm-border);
    color: var(--fm-text);
    padding: 9px 14px;
    border-radius: var(--fm-radius);
    cursor: pointer;
    font-size: 13px;
}
.fm-btn-ghost:hover { background: var(--fm-bg); }

.fm-btn-block { width: 100%; }

/* ============================================================
   Alerts
   ============================================================ */
.fm-alert {
    padding: 10px 14px;
    border-radius: var(--fm-radius);
    font-size: 13px;
    margin-bottom: 16px;
}
.fm-alert-error {
    background: var(--fm-danger-light);
    color: var(--fm-danger);
    border: 1px solid #fecaca;
}
.fm-alert-success {
    background: #f0fdf4;
    color: var(--fm-success);
    border: 1px solid #bbf7d0;
}

/* ============================================================
   Custom Modal (全站统一，不用浏览器原生alert/confirm)
   ============================================================ */
.fm-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}
.fm-modal-overlay.active {
    display: flex;
}

.fm-modal {
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 380px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    animation: fmModalIn 0.15s ease-out;
}

@keyframes fmModalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.fm-modal-title {
    margin: 0 0 12px;
    font-size: 17px;
    font-weight: 700;
}

.fm-modal-text {
    font-size: 13px;
    color: var(--fm-text-muted);
    margin: 0 0 12px;
}

.fm-modal-steps {
    font-size: 13px;
    color: var(--fm-text-muted);
    padding-left: 18px;
    margin: 0 0 12px;
}

.fm-secret-box {
    background: var(--fm-bg);
    border: 1px dashed var(--fm-border);
    border-radius: 8px;
    padding: 12px;
    font-family: monospace;
    font-size: 16px;
    text-align: center;
    letter-spacing: 2px;
    margin-bottom: 16px;
    word-break: break-all;
}

.fm-qr-box {
    display: flex;
    justify-content: center;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--fm-border);
    border-radius: 10px;
    margin-bottom: 16px;
}

.fm-input-large {
    width: 100%;
    padding: 14px;
    font-size: 22px;
    text-align: center;
    letter-spacing: 8px;
    border: 1px solid var(--fm-border);
    border-radius: var(--fm-radius);
    margin-bottom: 16px;
}

.fm-modal-actions { display: flex; gap: 10px; }

/* ============================================================
   App Layout (Sidebar + Topbar + Content) - 后续模块会用到
   ============================================================ */
.fm-app {
    display: flex;
    min-height: 100vh;
}

.fm-sidebar {
    width: 240px;
    background: #fff;
    border-right: 1px solid var(--fm-border);
    padding: 20px 16px;
    flex-shrink: 0;
}

.fm-sidebar-logo {
    font-size: 20px;
    font-weight: 800;
    color: var(--fm-primary);
    margin-bottom: 20px;
}
.fm-sidebar-logo img {
    max-width: 100%;
    max-height: 48px;
    display: block;
}

.fm-sidebar-user {
    background: var(--fm-bg);
    border-radius: var(--fm-radius);
    padding: 12px;
    margin-bottom: 20px;
}
.fm-sidebar-user .name { font-weight: 700; font-size: 14px; }
.fm-sidebar-user .role { font-size: 12px; color: var(--fm-text-muted); }

.fm-sidebar-group {
    font-size: 11px;
    font-weight: 700;
    color: var(--fm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 18px 0 6px;
}

.fm-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--fm-text);
    font-size: 14px;
    margin-bottom: 2px;
}
.fm-sidebar-link:hover { background: var(--fm-bg); }
.fm-sidebar-link.active { background: var(--fm-primary-light); color: var(--fm-primary-dark); font-weight: 600; }

.fm-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.fm-topbar {
    background: #fff;
    border-bottom: 1px solid var(--fm-border);
    padding: 0 24px;
    display: flex;
    gap: 24px;
}

.fm-topbar-tab {
    padding: 14px 4px;
    color: var(--fm-text-muted);
    font-size: 14px;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}
.fm-topbar-tab.active {
    color: var(--fm-primary);
    border-bottom-color: var(--fm-primary);
    font-weight: 600;
}

.fm-content {
    padding: 24px;
}

/* ============================================================
   Cards / Tables (后续模块通用)
   ============================================================ */
.fm-card {
    background: var(--fm-card-bg);
    border-radius: var(--fm-radius);
    box-shadow: var(--fm-shadow);
    padding: 18px;
}

.fm-table {
    width: 100%;
    border-collapse: collapse;
}
.fm-table th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--fm-text-muted);
    padding: 10px 12px;
    border-bottom: 1px solid var(--fm-border);
}
.fm-table td {
    padding: 12px;
    border-bottom: 1px solid var(--fm-border);
    font-size: 14px;
}

/* ============================================================
   Transfer List (双栏选择器：左边可选，右边已选)
   ============================================================ */
.fm-transfer {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 16px;
}

.fm-transfer-panel {
    flex: 1;
    border: 1px solid var(--fm-border);
    border-radius: var(--fm-radius);
    display: flex;
    flex-direction: column;
    height: 280px;
}

.fm-transfer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--fm-border);
    font-size: 12px;
    color: var(--fm-text-muted);
    background: var(--fm-bg);
}

.fm-transfer-header select {
    border: none;
    background: transparent;
    font-size: 12px;
    color: var(--fm-primary);
    cursor: pointer;
}

.fm-transfer-search {
    padding: 6px 8px;
    border-bottom: 1px solid var(--fm-border);
}
.fm-transfer-search input {
    width: 100%;
    border: 1px solid var(--fm-border);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 12px;
}

.fm-transfer-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.fm-transfer-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
}
.fm-transfer-item:hover { background: var(--fm-bg); }
.fm-transfer-item.fm-transfer-group {
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--fm-text-muted);
    cursor: default;
    padding-top: 10px;
}
.fm-transfer-item.fm-transfer-group:hover { background: transparent; }

.fm-transfer-empty {
    text-align: center;
    color: var(--fm-text-muted);
    font-size: 12px;
    padding: 30px 10px;
}

.fm-transfer-arrows {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

/* ============================================================
   Toast 通知
   ============================================================ */
.fm-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fm-toast {
    background: #1f2937;
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.2s, transform 0.2s;
    max-width: 320px;
}
.fm-toast.show {
    opacity: 1;
    transform: translateX(0);
}
.fm-toast-success { background: #16a34a; }
.fm-toast-error { background: #ef4444; }

/* ============================================================
   Credentials Card (新增用户/重设密码 后显示的登录凭证)
   ============================================================ */
.fm-cred-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--fm-bg);
    border: 1px solid var(--fm-border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
}
.fm-cred-row .fm-cred-label {
    font-size: 11px;
    color: var(--fm-text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}
.fm-cred-row .fm-cred-value {
    font-family: monospace;
    font-size: 14px;
    word-break: break-all;
}
.fm-cred-row button {
    flex-shrink: 0;
    margin-left: 10px;
}

.fm-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.fm-badge-success { background: #f0fdf4; color: var(--fm-success); }
.fm-badge-muted { background: var(--fm-bg); color: var(--fm-text-muted); }
.fm-badge-warning { background: #fffbeb; color: #d97706; }
.fm-badge-danger { background: var(--fm-danger-light); color: var(--fm-danger); }

/* Permissions table alignment */
.fm-permission-table {
    table-layout: fixed;
}

.fm-permission-table th:nth-child(1),
.fm-permission-table td:nth-child(1) {
    width: 34%;
}

.fm-permission-table th:nth-child(2),
.fm-permission-table td:nth-child(2) {
    width: 36%;
}

.fm-permission-table th:nth-child(3),
.fm-permission-table td:nth-child(3) {
    width: 15%;
}

.fm-permission-table th:nth-child(4),
.fm-permission-table td:nth-child(4) {
    width: 15%;
    text-align: right;
}

.fm-btn-small {
    padding: 6px 10px;
    font-size: 12px;
}

/* ============================================================
   Custom Date Picker
   ============================================================ */
.fm-datepicker-modal {
    max-width: 300px;
}
.fm-datepicker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.fm-datepicker-grid { width: 100%; }
.fm-dp-weekdays, .fm-dp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
}
.fm-dp-weekdays span {
    font-size: 11px;
    color: var(--fm-text-muted);
    font-weight: 700;
    padding: 4px 0;
}
.fm-dp-day {
    padding: 8px 0;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
}
.fm-dp-day:hover { background: var(--fm-bg); }
.fm-dp-day.selected {
    background: var(--fm-primary);
    color: #fff;
    font-weight: 700;
}
.fm-dp-shortcuts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--fm-border);
}

/* ============================================================
   Custom Date RANGE Picker
   ============================================================ */
.fm-rangepicker-modal {
    max-width: 680px;
}
.fm-rp-body {
    display: flex;
    gap: 16px;
}
.fm-rp-sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 140px;
    flex-shrink: 0;
    border-right: 1px solid var(--fm-border);
    padding-right: 14px;
}
.fm-rp-shortcut {
    text-align: left;
    background: none;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    color: var(--fm-text);
}
.fm-rp-shortcut:hover { background: var(--fm-bg); }

.fm-rp-calendars { flex: 1; min-width: 0; }
.fm-rp-cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.fm-rp-two-months {
    display: flex;
    gap: 20px;
}
.fm-rp-two-months .fm-datepicker-grid { flex: 1; min-width: 0; }

.fm-dp-day.range-start, .fm-dp-day.range-end {
    background: var(--fm-primary);
    color: #fff;
    font-weight: 700;
    border-radius: 6px;
}
.fm-dp-day.range-mid {
    background: var(--fm-primary-light);
    border-radius: 0;
}

/* ============================================================
   Date Range Picker
   ============================================================ */
.fm-rangepicker-modal {
    max-width: 640px;
}
.fm-rp-body {
    display: flex;
    gap: 16px;
}
.fm-rp-presets {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 130px;
    flex-shrink: 0;
    border-right: 1px solid var(--fm-border);
    padding-right: 12px;
}
.fm-rp-presets button {
    text-align: left;
    background: transparent;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    color: var(--fm-text);
}
.fm-rp-presets button:hover { background: var(--fm-bg); }

.fm-rp-calendars { flex: 1; min-width: 0; }
.fm-rp-cal-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}
.fm-rp-grids {
    display: flex;
    gap: 16px;
}
.fm-rp-grids .fm-datepicker-grid { flex: 1; min-width: 0; }

.fm-dp-day.in-range {
    background: var(--fm-primary-light);
    border-radius: 0;
}
.fm-dp-day.range-start, .fm-dp-day.range-end {
    background: var(--fm-primary);
    color: #fff;
    font-weight: 700;
}