/* 股票交易管理系统 - 移动端优先 */
/* 涨:红(#e74c3c) 跌:绿(#27ae60) - 中国惯例 */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    font-size: 14px;
    line-height: 1.5;
    padding-top: 50px;
}
a { color: #58a6ff; text-decoration: none; }
a:hover { color: #79c0ff; }

/* ===== Header ===== */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 200;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 12px;
}
.menu-btn {
    width: 36px; height: 36px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px;
    background: none; border: none;
    cursor: pointer; padding: 6px;
    flex-shrink: 0;
}
.menu-btn span {
    display: block;
    width: 20px; height: 2px;
    background: #8b949e;
    border-radius: 1px;
    transition: .3s;
}
.logo {
    flex: 1;
    font-size: 15px; font-weight: 600;
    padding-left: 8px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.logo a { color: #e6edf3; }
.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-info { color: #8b949e; font-size: 12px; display: none; }
.btn-logout {
    padding: 4px 10px;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #c9d1d9;
    font-size: 11px;
    background: transparent;
    white-space: nowrap;
}

/* ===== Sidebar (off-canvas) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    z-index: 150;
}
.sidebar-open .sidebar-overlay { display: block; }

.sidebar {
    position: fixed;
    top: 0; left: -240px;
    width: 240px; height: 100%;
    background: #161b22;
    border-right: 1px solid #30363d;
    z-index: 300;
    transition: left .25s ease;
    padding-top: 50px;
    overflow-y: auto;
}
.sidebar-open .sidebar { left: 0; }

.sidebar-close {
    position: absolute;
    top: 8px; right: 8px;
    background: none; border: none;
    color: #8b949e; font-size: 22px;
    cursor: pointer; padding: 4px 8px;
}

.nav-item {
    display: block;
    padding: 12px 20px;
    color: #c9d1d9;
    font-size: 14px;
    border-bottom: 1px solid #21262d;
    transition: .15s;
}
.nav-item:hover { background: #1c2128; }
.nav-item.on { background: #1c2128; border-left: 3px solid #e74c3c; font-weight: 600; }
.nav-icon { margin-right: 8px; font-size: 16px; }

/* ===== Main ===== */
.wrapper { min-height: calc(100vh - 50px - 54px); }
.main { padding: 12px; }

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 8px 12px;
    font-size: 11px;
    color: #484f58;
    height: 36px;
}

/* ===== Page Head ===== */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}
.page-head h2 { font-size: 17px; color: #e6edf3; font-weight: 600; }

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 8px 14px;
    background: #238636;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
    text-align: center;
    white-space: nowrap;
}
.btn:hover { background: #2ea043; color: #fff; }
.btn-sec {
    background: #21262d;
    border: 1px solid #30363d;
    color: #c9d1d9;
}
.btn-sec:hover { background: #30363d; color: #e6edf3; }
.btn-sm {
    display: inline-block;
    padding: 4px 8px;
    border: 1px solid #30363d;
    border-radius: 3px;
    color: #c9d1d9;
    font-size: 11px;
    cursor: pointer;
    transition: .15s;
    background: transparent;
    white-space: nowrap;
}
.btn-sm:hover { background: #30363d; }
.btn-sm-danger { border-color: #f85149; color: #f85149; }
.btn-sm-danger:hover { background: #f85149; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Cards ===== */
.cards { display: flex; gap: 10px; margin-bottom: 12px; }
.card {
    flex: 1;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 14px 10px;
    text-align: center;
}
.card-val { font-size: 20px; font-weight: 700; color: #e6edf3; }
.card-lbl { font-size: 11px; color: #8b949e; margin-top: 2px; }

/* ===== Grids ===== */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 10px; }

/* ===== Box ===== */
.box {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    margin-bottom: 12px;
}
.box-hd {
    padding: 10px 12px;
    border-bottom: 1px solid #30363d;
    font-size: 14px;
    font-weight: 600;
    color: #e6edf3;
}
.box-bd { padding: 8px; }
.box-bd .empty { padding: 20px; text-align: center; color: #484f58; font-size: 13px; }

/* ===== Filter Bar ===== */
.filter-bar {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
    padding: 6px 8px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #c9d1d9;
    font-size: 13px;
    max-width: 130px;
}
.filter-bar .btn { font-size: 12px; padding: 6px 10px; }

/* ===== Info Bar ===== */
.info-bar {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #8b949e;
}

/* ===== Table (水平滚动) ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; min-width: 600px; }
.table th {
    padding: 7px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    color: #8b949e;
    border-bottom: 1px solid #30363d;
    white-space: nowrap;
}
.table td {
    padding: 7px 8px;
    border-bottom: 1px solid #21262d;
    font-size: 12px;
    vertical-align: middle;
    white-space: nowrap;
}
.table tr:hover td { background: #1c2128; }
.table .up td { color: #e74c3c; }
.table .down td { color: #27ae60; }

.table-info { width: 100%; }
.table-info td {
    padding: 6px 8px;
    border-bottom: 1px solid #21262d;
    font-size: 12px;
}
.table-info td:first-child { color: #8b949e; width: 80px; white-space: nowrap; }

/* ===== Tag ===== */
.tag {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid #30363d;
    border-radius: 3px;
    font-size: 10px;
    color: #8b949e;
}
.tag-red { border-color: rgba(231,76,60,.3); color: #e74c3c; }
.tag-green { border-color: rgba(39,174,96,.3); color: #27ae60; }
.tag-gray { border-color: #30363d; color: #484f58; }

/* ===== Empty ===== */
.empty {
    text-align: center;
    color: #484f58;
    padding: 30px 12px;
    font-size: 13px;
}

/* ===== Form ===== */
.form-wrap {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 16px;
}
.form-group {
    margin-bottom: 14px;
    position: relative;
}
.form-group label {
    display: block;
    color: #8b949e;
    font-size: 12px;
    margin-bottom: 4px;
}
.form-group .r { color: #f85149; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #c9d1d9;
    font-size: 14px;
    transition: border-color .15s;
    -webkit-appearance: none;
    appearance: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: #58a6ff;
    outline: none;
}
.form-group textarea { resize: vertical; min-height: 44px; }
.form-static { padding: 8px 0; color: #e6edf3; font-size: 13px; }
.form-hint { color: #8b949e; font-size: 11px; margin-top: 4px; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

/* ===== Suggest ===== */
.suggest-list {
    display: none;
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 4px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 200;
}
.suggest-list a {
    display: block;
    padding: 8px 12px;
    color: #c9d1d9;
    font-size: 13px;
    border-bottom: 1px solid #30363d;
}
.suggest-list a:last-child { border-bottom: none; }
.suggest-list a:hover { background: #30363d; }

/* ===== Pagination ===== */
.page { margin-top: 12px; text-align: center; }
.page a {
    display: inline-block;
    padding: 5px 10px;
    margin: 0 1px;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #c9d1d9;
    font-size: 12px;
    transition: .15s;
}
.page a:hover { background: #30363d; }
.page a.on { background: #238636; border-color: #238636; color: #fff; }

/* ===== 底部导航 (App Tab Bar) ===== */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    z-index: 100;
    background: #161b22;
    border-top: 1px solid #30363d;
    display: flex;
    height: 54px;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #8b949e;
    font-size: 10px;
    text-decoration: none;
    gap: 1px;
    transition: .15s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav a .nav-icon-b {
    font-size: 18px;
    line-height: 1;
    transition: .15s;
}
.bottom-nav a .nav-label {
    font-size: 10px;
    transition: .15s;
}
.bottom-nav a.on {
    color: #e74c3c;
}
.bottom-nav a.on .nav-icon-b {
    color: #e74c3c;
}
.bottom-nav a::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    width: 0; height: 2px;
    background: #e74c3c;
    transition: .2s;
    transform: translateX(-50%);
}
.bottom-nav a.on::before {
    width: 24px;
}

/* ===== 浮动新增按钮 ===== */
.stockadd {
    position: fixed;
    top: 2px;
    right: 12px;
    z-index: 300;
    width: 44px;
    height: 44px;
    font-size: 24px;
    font-weight: 600;
    color: #fff;
    background: #238636;
    border-radius: 50%;
    line-height: 44px;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
    -webkit-tap-highlight-color: transparent;
}
.stockadd:hover {
    background: #2ea043;
    color: #fff;
}

/* 底部导航占位，防止内容被遮挡 */
body { padding-bottom: 54px; }

/* ===== 弹窗 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.6);
    z-index: 500;
    align-items: center;
    justify-content: center;
}
.modal {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    width: 320px;
    max-width: 90%;
    position: relative;
    padding: 20px;
}
.modal-hd {
    font-size: 16px;
    font-weight: 600;
    color: #e6edf3;
    margin-bottom: 16px;
}
.modal-close {
    position: absolute;
    top: 10px; right: 14px;
    color: #8b949e;
    font-size: 22px;
    text-decoration: none;
    line-height: 1;
}
.modal-close:hover { color: #e6edf3; }
.modal .form-group { margin-bottom: 12px; }
.modal .form-group input { font-size: 16px; padding: 12px; }
.modal .form-hint { margin-top: 2px; }

/* ===== 平板及以上 ===== */
@media (min-width: 768px) {
    body { padding-top: 52px; }
    .header { height: 52px; padding: 0 20px; }
    .logo { font-size: 16px; }
    .user-info { display: inline; font-size: 13px; }
    .btn-logout { padding: 5px 14px; font-size: 12px; }

    .sidebar { padding-top: 52px; }

    .main {
        padding: 20px;
    }
    .nav-item { font-size: 13px; padding: 10px 16px; border-bottom: none; }

    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
    .cards { gap: 15px; }
    .card { padding: 18px 20px; }
    .card-val { font-size: 24px; }

    .form-wrap { padding: 24px; }
    .form-group label { font-size: 13px; }
    .form-group input, .form-group select, .form-group textarea { font-size: 13px; padding: 8px 10px; }

    .table { min-width: auto; }
    .table th { padding: 8px 10px; font-size: 12px; }
    .table td { padding: 8px 10px; font-size: 13px; }
    .table-wrap { overflow-x: visible; }

    .filter-bar { flex-wrap: nowrap; }
    .filter-bar select, .filter-bar input { max-width: none; }
}

/* ===== Utility ===== */
.up { color: #e74c3c; }
.down { color: #27ae60; }
small { font-size: 10px; color: #8b949e; }
@media (min-width: 768px) { small { font-size: 11px; } }
