/* 岷江国际旅行社管理系统 - 前端样式 */
:root {
    --primary: #1a5fb4;
    --primary-dark: #144a8c;
    --primary-light: #e8f1fb;
    --accent: #f59e0b;
    --danger: #dc2626;
    --success: #16a34a;
    --text: #1f2937;
    --text-2: #4b5563;
    --text-3: #6b7280;
    --border: #e2e8f0;
    --bg: #f4f6f9;
    --panel: #ffffff;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0; height: 100%;
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px; color: var(--text); background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 登录页 ---------- */
.login-wrap {
    min-height: 100%; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1a5fb4 0%, #0f3d75 100%);
}
.login-box {
    width: 380px; background: #fff; border-radius: 10px; padding: 36px 34px 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.login-box h1 { margin: 0 0 6px; font-size: 21px; text-align: center; color: var(--primary); letter-spacing: 1px; }
.login-box .sub { text-align: center; color: var(--text-3); font-size: 12px; margin-bottom: 26px; }
.login-box .err { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; padding: 8px 12px; border-radius: 4px; font-size: 13px; margin-bottom: 14px; display: none; }
.login-box .err.show { display: block; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 208px; background: #1e293b; color: #cbd5e1; flex-shrink: 0;
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto;
}
.sidebar .brand {
    padding: 16px 16px 14px; border-bottom: 1px solid #334155;
    font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .5px;
}
.sidebar .brand small { display: block; font-size: 11px; font-weight: 400; color: #94a3b8; margin-top: 4px; }
.sidebar nav { padding: 8px 0; flex: 1; overflow-y: auto; overflow-x: hidden; }
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
.sidebar .grp-title { padding: 12px 16px 6px; font-size: 11px; color: #64748b; letter-spacing: 1px; }
.sidebar nav a {
    display: flex; align-items: center; gap: 8px; padding: 9px 16px; color: #cbd5e1; font-size: 13.5px;
    border-left: 3px solid transparent; cursor: pointer;
}
.sidebar nav a:hover { background: #334155; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #334155; color: #fff; border-left-color: var(--accent); }
.sidebar nav a .ico { width: 16px; text-align: center; opacity: .85; }

.main { flex: 1; margin-left: 208px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 52px; background: #fff; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
    position: sticky; top: 0; z-index: 20;
}
.topbar .crumb { font-size: 15px; font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-2); }
.topbar .uname { font-weight: 600; color: var(--text); }

.content { padding: 18px 20px 40px; flex: 1; }

/* ---------- 卡片 / 面板 ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel-hd {
    padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14.5px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.panel-bd { padding: 16px; }

/* ---------- 搜索栏 ---------- */
.search-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-3); }

/* ---------- 表单控件 ---------- */
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
    height: 32px; padding: 0 9px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 13.5px;
    font-family: inherit; color: var(--text); background: #fff; outline: none; min-width: 130px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26, 95, 180, .12); }
textarea { height: auto; padding: 7px 9px; min-height: 68px; resize: vertical; line-height: 1.6; }
input.search-input { min-width: 180px; }

/* ---------- 按钮 ---------- */
.btn {
    height: 32px; padding: 0 14px; border: 1px solid var(--primary); background: var(--primary); color: #fff;
    border-radius: 4px; cursor: pointer; font-size: 13.5px; font-family: inherit; white-space: nowrap;
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.ghost { background: #fff; color: var(--text-2); border-color: #cbd5e1; }
.btn.ghost:hover { background: #f1f5f9; color: var(--text); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.2px; }
table.grid th {
    background: #f8fafc; text-align: left; padding: 9px 10px; font-weight: 600; color: var(--text-2);
    border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0;
}
table.grid td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
table.grid tbody tr:hover { background: #f8fafc; }
table.grid tbody tr:nth-child(even) { background: #fcfdfe; }
table.grid tbody tr:nth-child(even):hover { background: #f8fafc; }
table.grid .num { text-align: right; white-space: nowrap; }
table.grid .ctr { text-align: center; white-space: nowrap; }
table.grid td.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { padding: 46px 0; text-align: center; color: var(--text-3); font-size: 13.5px; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; flex-wrap: wrap; }
.pager .info { color: var(--text-3); font-size: 12.5px; margin-right: auto; }
.pager button {
    min-width: 30px; height: 28px; padding: 0 8px; border: 1px solid #cbd5e1; background: #fff;
    border-radius: 4px; cursor: pointer; font-size: 13px; color: var(--text-2); font-family: inherit;
}
.pager button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager button:disabled { opacity: .5; cursor: not-allowed; }
.pager button.cur { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 统计卡片 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.stat {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
    box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.stat .v { font-size: 22px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat .v.green { color: var(--success); }
.stat .v.red { color: var(--danger); }
.stat .v.amber { color: var(--accent); }
.stat .u { font-size: 12px; color: var(--text-3); margin-left: 3px; font-weight: 400; }

/* ---------- 弹窗 ---------- */
.mask {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100;
    display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
    background: #fff; border-radius: 8px; width: 640px; max-width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .3); animation: pop .15s ease-out;
}
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.wide { width: 900px; }
.modal-hd {
    padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-hd .x { cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; }
.modal-hd .x:hover { color: var(--danger); }
.modal-bd { padding: 18px; max-height: 62vh; overflow-y: auto; }
.modal-ft { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid .col2 { grid-column: span 2; }
.form-grid .f { display: flex; flex-direction: column; gap: 5px; }
.form-grid .f label { font-size: 12.5px; color: var(--text-2); }
.form-grid .f input, .form-grid .f select, .form-grid .f textarea { width: 100%; min-width: 0; }
.form-grid .f input[readonly] { background: var(--bg-2); color: var(--text-3); }
.form-grid .checks { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 6px 0; }
.form-grid .checks .ck { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); }
.form-grid .checks .ck input { width: auto; }

/* ---------- 详情表 ---------- */
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv .k { color: var(--text-3); }
.kv .v { color: var(--text); word-break: break-all; }

/* ---------- 提示 ---------- */
#toast {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200;
    display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast-item {
    background: #1f2937; color: #fff; padding: 9px 18px; border-radius: 5px; font-size: 13.5px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .2); animation: tin .2s ease-out;
}
.toast-item.ok { background: var(--success); }
.toast-item.err { background: var(--danger); }
@keyframes tin { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; line-height: 18px; }
.badge.g { background: #dcfce7; color: #15803d; }
.badge.r { background: #fee2e2; color: #b91c1c; }
.badge.b { background: #dbeafe; color: #1d4ed8; }
.badge.y { background: #fef3c7; color: #a16207; }
.badge.n { background: #f1f5f9; color: #64748b; }

.sum-bar {
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-2);
}
.sum-bar b { color: var(--text-1); font-weight: 600; }

.loading { padding: 50px 0; text-align: center; color: var(--text-3); }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 12.5px; }

/* ---------- 移动端：抽屉式菜单（默认隐藏，≤768px 才显示） ---------- */
.nav-toggle {
    display: none; width: 40px; height: 40px; margin-right: 8px; flex-shrink: 0;
    border: 1px solid var(--border); background: #fff; color: var(--text);
    border-radius: 6px; font-size: 17px; line-height: 1; cursor: pointer;
    align-items: center; justify-content: center; font-family: inherit;
}
.nav-toggle:active { background: #f1f5f9; }
.nav-mask { display: none; }
.side-foot { padding: 12px 16px; border-top: 1px solid #334155; }

/* ============ 平板（769~1024）：收成图标栏 ============ */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar { width: 64px; }
    /* 分组标题改成一条分隔线，避免竖排换行成乱码 */
    .sidebar .grp-title {
        display: block; padding: 0; margin: 10px 12px; height: 1px;
        background: #334155; overflow: hidden; font-size: 0; color: transparent;
    }
    .sidebar .brand span, .sidebar .brand small, .sidebar nav a span.t { display: none; }
    .sidebar .brand { text-align: center; padding: 14px 4px 12px; font-size: 15px; }
    .sidebar .brand::before { content: '岷江'; font-size: 13px; color: #fff; font-weight: 700; }
    .sidebar nav a { justify-content: center; padding: 11px 0; font-size: 16px; }
    .sidebar nav a .ico { width: auto; }
    .side-foot { text-align: center; padding: 12px 4px; }
    .side-foot a { font-size: 0; }
    .side-foot a::before { content: '⏻'; font-size: 16px; color: #94a3b8; }
    .main { margin-left: 64px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .col2 { grid-column: span 1; }
}

/* ============ 手机（≤768）：侧边栏变抽屉 + 全面触控适配 ============ */
@media (max-width: 768px) {
    /* --- 抽屉 --- */
    .nav-toggle { display: inline-flex; }
    .sidebar {
        width: 270px; z-index: 60; box-shadow: 2px 0 20px rgba(0, 0, 0, .32);
        transform: translateX(-100%); transition: transform .22s ease;
    }
    body.nav-open .sidebar { transform: none; }
    .nav-mask {
        display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
        z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s;
    }
    body.nav-open .nav-mask { opacity: 1; pointer-events: auto; }
    body.nav-open { overflow: hidden; }
    .main { margin-left: 0; }
    .sidebar nav a { padding: 13px 16px; font-size: 15px; }

    /* --- 顶栏 / 内容 --- */
    .topbar { height: 56px; padding: 0 10px; }
    .topbar .crumb {
        font-size: 14px; min-width: 0; overflow: hidden;
        text-overflow: ellipsis; white-space: nowrap;
    }
    .topbar .right { font-size: 12px; gap: 8px; overflow: hidden; white-space: nowrap; }
    .content { padding: 12px 12px 32px; }

    /* --- 触控目标 ≥40px；输入框 16px 防止 iOS 聚焦时自动放大 --- */
    .btn { height: 42px; padding: 0 16px; font-size: 14.5px; }
    .btn.sm { height: 40px; padding: 0 14px; font-size: 14px; }
    input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
        height: 42px; font-size: 16px;
    }
    textarea { min-height: 92px; }
    .pager button { height: 42px; min-width: 42px; padding: 0 10px; }
    .pager { justify-content: center; gap: 6px; }
    .pager .info { margin-right: 0; width: 100%; text-align: center; }

    /* --- 搜索栏竖排 --- */
    .search-bar { flex-direction: column; align-items: stretch; }
    .search-bar .field, .search-bar .field input,
    .search-bar .field select { width: 100%; }
    .search-bar .btn { width: 100%; }

    /* --- 表单 / 详情 --- */
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .col2 { grid-column: span 1; }
    .kv { grid-template-columns: 92px 1fr; }
    .stats { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }

    /* --- 弹窗全屏化 --- */
    .mask { padding: 0; align-items: stretch; }
    .modal, .modal.wide {
        width: 100%; max-width: 100%; border-radius: 0;
        min-height: 100%; display: flex; flex-direction: column;
    }
    .modal-bd { max-height: none; flex: 1; -webkit-overflow-scrolling: touch; }
    .modal-ft { position: sticky; bottom: 0; background: #fff; }
    .modal-ft .btn { flex: 1; }
    .modal-hd { padding: 14px 14px; }

    /* --- 列表表格卡片化（横向内容 2229px 在手机上不再需要横拖 8 屏） --- */
    .table-wrap { overflow-x: visible; }
    .table-wrap.keep-scroll { overflow-x: auto; }
    table.grid.cardable thead { display: none; }
    table.grid.cardable,
    table.grid.cardable tbody,
    table.grid.cardable tr,
    table.grid.cardable td { display: block; width: 100%; }
    table.grid.cardable tr {
        background: #fff; border: 1px solid var(--border); border-radius: 8px;
        margin: 0 0 10px; padding: 8px 12px;
    }
    table.grid.cardable tbody tr:nth-child(even),
    table.grid.cardable tbody tr:nth-child(even):hover { background: #fff; }
    table.grid.cardable td {
        border: 0; padding: 5px 0; display: flex; gap: 10px; align-items: baseline;
        white-space: normal !important; max-width: none !important;
        overflow: visible !important; word-break: break-all;
    }
    table.grid.cardable td::before {
        content: attr(data-label); flex: 0 0 88px; color: var(--text-3); font-size: 12.5px;
    }
    table.grid.cardable td.num,
    table.grid.cardable td.ctr { text-align: left; white-space: normal; }
    table.grid.cardable td .act {
        display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px;
        margin: 2px 6px 2px 0; border: 1px solid var(--border); border-radius: 6px;
        background: #f8fafc;
    }
}

/* ---------- 小屏登录框 ---------- */
@media (max-width: 420px) {
    .login-box { width: auto; margin: 16px; padding: 28px 20px 24px; }
}

/* ============ A4 打印（通知书 / 合同 / 传真记录表）============ */
#print-root { display: none; }
body.printing { overflow: hidden; }
body.printing #print-root {
    display: block; position: fixed; inset: 0; z-index: 9999;
    background: #525659; overflow: auto; padding: 16px 0 40px;
}
.print-bar {
    position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; background: #fff; border-bottom: 1px solid #d8dee9;
}
.print-bar .tip { font-size: 12.5px; color: #64748b; }

.a4 {
    width: 210mm; min-height: 297mm; margin: 0 auto 16px; background: #fff;
    padding: 14mm 12mm; box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
    color: #000; font-family: "宋体", SimSun, serif; font-size: 12pt; line-height: 1.5;
}
.a4.preview { width: 100%; min-height: 0; box-shadow: none; padding: 12px; border: 1px solid var(--border); }

.doc-title { text-align: center; font-size: 20pt; font-weight: 700; font-family: "黑体", SimHei, serif; margin: 0 0 10px; }
.doc-sub { text-align: center; font-size: 11pt; margin-bottom: 8px; }
.doc-tip { font-size: 11px; color: #c00; margin: 4px 0; }
.doc-para { margin: 4px 0; font-size: 11pt; text-indent: 2em; }
.doc-para u { text-decoration: underline; padding: 0 4px; }

.doc-tbl { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 11pt; }
.doc-tbl td { border: 1px solid #666; padding: 4px 6px; vertical-align: middle; }
.doc-tbl.bare td { border: 0; }
.doc-tbl .k { background: #ACD6FF; white-space: nowrap; font-weight: 400; }
.doc-tbl .v { background: #E0E0E0; }
.doc-tbl .sect { background: #ACD6FF; text-align: center; font-weight: 700; font-family: "黑体", SimHei, serif; }
.doc-tbl .sect2 { background: #ACD6FF; text-align: center; font-weight: 700; }
.doc-tbl .note { background: #ACD6FF; font-size: 10pt; line-height: 1.6; }
.doc-tbl .head td { background: #ACD6FF; text-align: center; font-weight: 700; }
.doc-tbl .ctr { text-align: center; }
.doc-tbl .num { text-align: right; }
.doc-tbl td.ctr { text-align: center; }
.doc-tbl td.num { text-align: right; }
.doc-act { color: #1d4ed8; text-decoration: none; }
.bad { color: #c00; }
.ok2 { color: #00c; }

/* 合同正文（print.asp 原始模板） */
.a4 .MsoNormal { margin: 0; text-align: justify; font-size: 10.5pt; line-height: 1.5; }
.a4 table { max-width: 100%; }

@media print {
    @page { size: A4; margin: 0; }
    html, body { background: #fff; }
    body > *:not(#print-root) { display: none !important; }
    #print-root {
        display: block !important; position: static !important; background: #fff;
        padding: 0 !important; overflow: visible !important;
    }
    .print-bar { display: none !important; }
    .a4 {
        width: 210mm; min-height: 0; margin: 0; padding: 12mm 10mm;
        box-shadow: none; page-break-after: always;
    }
    .a4:last-child { page-break-after: auto; }
    .no-print { display: none !important; }
    .doc-tbl tr { page-break-inside: avoid; }
}
