/* ============================================================
   Healthy Zone · Metro-UI Win8.1 磁铁卡片风格
   设计要点：
   - 深蓝紫渐变背景（Win8.1 开始屏幕氛围）+ 高饱和扁平磁铁色块
   - Segoe UI / 微软雅黑字体栈；Segoe UI Light 用于大数字
   - 全站直角（无圆角），徽标圆形角标是 Win8 的经典元素
   - 磁铁卡片入场逐个浮起（stagger），按下有“物理按压”反馈
   - PC 多列网格，手机自动单列；尊重 prefers-reduced-motion
   ============================================================ */

:root {
    --c-blue: #2672EC;
    --c-teal: #01A9B4;
    --c-lime: #7CB900;
    --c-orange: #F09609;
    --c-purple: #5133AB;
    --c-pink: #E671B8;
    --c-red: #D24726;
    --c-magenta: #8C0095;
    --c-green: #008A00;
    --c-yellow: #FFC40D;
    --bg1: #1F1A3D;
    --bg2: #0F2A4A;
    --ink: #1D1D1D;
    --muted: #6B6B6B;
    --panel: #FFFFFF;
    --line: #EAEAEA;
    --font: "Segoe UI", "Segoe UI Light", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: linear-gradient(135deg, var(--bg1) 0%, #16324F 55%, var(--bg2) 100%) fixed;
    color: #fff;
    font-size: 14px;
    line-height: 1.55;
    min-height: 100vh;
}

a { color: inherit; }

/* ---------------- 顶部固定磁铁通知栏 ---------------- */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 50;
    background: rgba(16, 24, 48, .94);
    border-bottom: 2px solid rgba(255, 255, 255, .14);
}
.topbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    color: #fff;
    margin-right: 6px;
}
.logo-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: var(--c-blue);
    font-size: 19px;
}
.logo-text {
    font-size: 16px;
    font-weight: 600;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav {
    display: flex;
    flex: 1;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-item {
    padding: 8px 13px;
    color: #E6ECF5;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, .12); }
.nav-item.active {
    background: rgba(255, 255, 255, .16);
    border-bottom-color: var(--c-yellow);
    color: #fff;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.bell {
    position: relative;
    font-size: 19px;
    text-decoration: none;
    padding: 4px 6px;
    line-height: 1;
}
.bell:hover { background: rgba(255, 255, 255, .12); }
.badge {
    position: absolute;
    top: -7px; right: -9px;
    min-width: 19px; height: 19px;
    padding: 0 5px;
    border-radius: 10px;
    background: #E81123;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px rgba(16, 24, 48, .9);
}
.userchip {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    text-decoration: none;
    padding: 3px 6px;
    font-size: 13px;
}
.userchip:hover { background: rgba(255, 255, 255, .12); }
.userchip-name { max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout {
    color: #E6ECF5;
    font-size: 13px;
    text-decoration: none;
    padding: 6px 8px;
}
.logout:hover { background: rgba(210, 71, 38, .75); color: #fff; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, .18);
    background-size: cover;
    background-position: center;
    font-size: 22px;
    color: #fff;
    flex: none;
}
.avatar-none { font-size: 15px; }

/* ---------------- 主内容区 ---------------- */
.main {
    max-width: 1240px;
    margin: 0 auto;
    padding: 78px 16px 30px;
}

.flash {
    padding: 10px 16px;
    margin-bottom: 14px;
    font-size: 14px;
    color: #fff;
}
.flash-ok { background: var(--c-lime); }
.flash-err { background: var(--c-red); }

.page-head {
    margin: 4px 0 16px;
    display: flex;
    align-items: baseline;
    gap: 12px;
}
.page-head-title {
    font-size: 24px;
    font-weight: 300; /* Segoe UI Light */
    letter-spacing: .5px;
}
.page-head-sub { font-size: 13px; opacity: .75; }

.footer {
    max-width: 1240px;
    margin: 10px auto 26px;
    padding: 0 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, .55);
    text-align: center;
}

/* ---------------- 磁铁网格（PC 多列 / 手机单列） ---------------- */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    margin: 0 0 22px;
}
.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 150px;
    padding: 16px 18px;
    color: #fff;
    text-decoration: none;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
    transition: filter .12s ease, transform .12s ease;
    animation: tileIn .35s ease backwards;
}
.tile:nth-child(2) { animation-delay: .04s; }
.tile:nth-child(3) { animation-delay: .08s; }
.tile:nth-child(4) { animation-delay: .12s; }
.tile:nth-child(5) { animation-delay: .16s; }
.tile:nth-child(6) { animation-delay: .2s; }
.tile:nth-child(7) { animation-delay: .24s; }
.tile:nth-child(8) { animation-delay: .28s; }
@keyframes tileIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.tile:hover { filter: brightness(1.13); transform: translateY(-2px); }
.tile:active { transform: scale(.97); }
.tile-wide { grid-column: span 2; }
.tile-icon { font-size: 30px; line-height: 1.15; }
.tile-title { font-size: 19px; font-weight: 600; line-height: 1.3; }
.tile-desc { font-size: 13px; opacity: .9; line-height: 1.5; }
.tile .big {
    font-size: 30px;
    font-weight: 300; /* Segoe UI Light 大数字 */
    line-height: 1.2;
}
.tile .badge { position: absolute; top: 12px; right: 12px; }

/* 磁铁内的切换按钮与长文本 */
.tile-toggle-row { display: flex; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.tile-toggle {
    display: inline-block;
    font-size: 12px;
    padding: 3px 11px;
    background: rgba(255, 255, 255, .22);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    border: 0;
    cursor: pointer;
    font-family: var(--font);
}
.tile-toggle.active { background: rgba(255, 255, 255, .88); color: #16324F; }
.tile-toggle:hover { background: rgba(255, 255, 255, .45); }
.tile-toggle[disabled] { opacity: .55; cursor: wait; }
.tile-ai-text {
    white-space: pre-wrap;
    font-size: 12.5px;
    opacity: .96;
    line-height: 1.65;
    max-height: 150px;
    overflow-y: auto;
}

/* 磁铁内的统计条（深底白字） */
.tile .stat-row { margin-top: 4px; }
.tile .stat-row + .stat-row { margin-top: 8px; }
.tile .stat-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    flex-wrap: wrap;
}
.tile .stat-label { font-weight: 600; }
.tile .stat-num { opacity: .95; }
.tile .stat-num small { opacity: .75; font-size: 11px; }
.tile .stat-right { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; font-size: 11.5px; opacity: .9; }
.tile .bar { height: 10px; background: rgba(255, 255, 255, .28); margin-top: 3px; }
.tile .bar-fill { height: 100%; }

/* ---------------- 内容卡片（表单/表格页） ---------------- */
.card {
    background: var(--panel);
    color: var(--ink);
    margin: 0 0 20px;
}
.card-head {
    padding: 11px 18px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.card-head .badge { position: static; }
.card-body { padding: 18px; }
.card-body p { margin: 0 0 12px; }
.card-body p:last-child { margin-bottom: 0; }

/* 卡片内的统计条（浅底深字） */
.card .stat-row + .stat-row { margin-top: 10px; }
.card .stat-head { display: flex; align-items: center; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.card .stat-label { font-weight: 600; min-width: 52px; }
.card .stat-num { color: #444; }
.card .stat-num small { color: #999; }
.card .stat-right { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; font-size: 12px; }
.card .stat-pct { color: #888; }
.card .bar { height: 14px; background: #E5E5E5; margin-top: 4px; }
.card .bar-fill { height: 100%; }

.bar-fill.bar-ok { background: var(--c-lime); }
.bar-fill.bar-warn { background: var(--c-orange); }
.bar-fill.bar-danger { background: var(--c-red); }

/* ---------------- 标签 ---------------- */
.tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    color: #fff;
    font-weight: 600;
    line-height: 1.6;
}
.tag-ok { background: var(--c-lime); }
.tag-warn { background: var(--c-orange); }
.tag-danger { background: var(--c-red); }
.tag-gray { background: #8A8A8A; }
.tag-muted { background: #B4B4B4; color: #555; }

/* ---------------- 表单（Metro 扁平直角控件） ---------------- */
.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}
.field .hint { font-size: 12px; color: #999; margin-top: 3px; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"], input[type="file"],
select, textarea {
    width: 100%;
    border: 2px solid #C8C8C8;
    padding: 9px 11px;
    font-size: 14px;
    font-family: var(--font);
    background: #fff;
    color: var(--ink);
    border-radius: 0;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--c-blue);
    outline: none;
    background: #F2F7FF;
}
textarea { resize: vertical; min-height: 90px; }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.form-inline .field { flex: 1; min-width: 150px; margin-bottom: 0; }
.check-row { display: flex; gap: 16px; flex-wrap: wrap; }
.check-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; color: #444; }
.check-row input[type="checkbox"] { width: auto; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--c-blue); }

.btn {
    display: inline-block;
    border: 0;
    border-radius: 0;
    color: #fff;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: var(--c-blue);
    font-family: var(--font);
    text-decoration: none;
    transition: filter .12s ease, transform .12s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.97); }
.btn-green { background: var(--c-lime); }
.btn-orange { background: var(--c-orange); }
.btn-red { background: var(--c-red); }
.btn-gray { background: #7A7A7A; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-ghost {
    background: #fff;
    color: var(--c-blue);
    border: 2px solid var(--c-blue);
    padding: 8px 20px;
}
.btn-block { display: block; width: 100%; text-align: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    background: var(--c-blue);
    color: #fff;
    padding: 9px 10px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:nth-child(even) td { background: #F7F9FC; }
.table .num { text-align: right; white-space: nowrap; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; gap: 6px; margin: 14px 0 0; flex-wrap: wrap; }
.pager-item {
    min-width: 32px;
    padding: 5px 10px;
    text-align: center;
    background: #EFEFEF;
    color: #444;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}
.pager-item.active { background: var(--c-blue); color: #fff; }
.pager-item:hover { filter: brightness(.94); }

/* ---------------- 登录页（Win8 锁屏氛围） ---------------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 14px;
    gap: 18px;
}
.auth-hero { text-align: center; }
.auth-hero .logo-tile {
    width: 74px; height: 74px;
    font-size: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--c-blue);
}
.auth-hero h1 { font-size: 26px; font-weight: 300; margin: 14px 0 6px; }
.auth-hero p { font-size: 13px; opacity: .8; margin: 0; }
.auth-card { width: 100%; max-width: 440px; background: var(--panel); color: var(--ink); }
.auth-tabs { display: flex; }
.auth-tab {
    flex: 1;
    text-align: center;
    padding: 13px 6px;
    color: #fff;
    background: #4A4A5A;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    border: 0;
    font-family: var(--font);
}
.auth-tab.active { background: var(--c-blue); }
.auth-body { padding: 24px; }
.auth-switch { text-align: center; font-size: 13px; color: #666; margin-top: 14px; }
.auth-switch a { color: var(--c-blue); font-weight: 600; text-decoration: none; }
.auth-links { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ---------------- 聊天 ---------------- */
.chat-wrap { display: grid; grid-template-columns: 290px 1fr; gap: 14px; align-items: start; }
.chat-list { display: flex; flex-direction: column; gap: 8px; }
.chat-item {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--panel);
    color: var(--ink);
    text-decoration: none;
    padding: 11px 12px;
    border-left: 4px solid transparent;
}
.chat-item:hover { filter: brightness(.97); }
.chat-item.active { border-left-color: var(--c-blue); }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-name { font-weight: 600; font-size: 14px; }
.chat-item-last { font-size: 12px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-badge {
    background: #E81123;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    min-width: 19px;
    height: 19px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}
.chat-box { background: var(--panel); color: var(--ink); display: flex; flex-direction: column; }
.chat-box-head {
    padding: 10px 16px;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; min-height: 300px; max-height: 52vh; display: flex; flex-direction: column; }
.chat-tip { text-align: center; color: #AAA; font-size: 12px; margin: 8px 0; }
.msg {
    max-width: 72%;
    margin: 0 0 10px;
    padding: 9px 13px;
    font-size: 14px;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.55;
}
.msg.mine { background: var(--c-blue); color: #fff; margin-left: auto; }
.msg.theirs { background: #F1F1F1; color: var(--ink); }
.msg .msg-time { display: block; font-size: 11px; opacity: .75; margin-top: 4px; }
.msg-record { background: #FFF8E1; border: 1px solid #F0C36D; }
.msg-record .rec-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.msg-record .rec-line { font-size: 12.5px; color: #6B5320; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #FAFAFA; align-items: center; }
.chat-input input[type="text"] { flex: 1; }

/* 专家侧边资料面板 */
.peer-panel { background: var(--panel); color: var(--ink); margin-bottom: 14px; }
.peer-panel .card-head { font-size: 14px; padding: 9px 16px; }

/* ---------------- 菜品卡片 ---------------- */
.dish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.dish-card { background: var(--panel); color: var(--ink); }
.dish-card-head {
    padding: 11px 14px;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.dish-card-head .dish-tags { margin-left: auto; display: inline-flex; gap: 4px; }
.dish-card-body { padding: 12px 14px; font-size: 13px; }
.dish-nutr { display: flex; flex-wrap: wrap; gap: 4px 14px; color: #555; margin-top: 6px; }
.dish-nutr b { color: var(--ink); }
.dish-qty { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.dish-qty select { width: 72px; }
.dish-ingr { color: #888; font-size: 12px; margin-top: 6px; }

/* ---------------- 模态框（Metro 直角面板） ---------------- */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .62);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-mask.open { display: flex; }
.modal {
    background: #fff;
    color: var(--ink);
    width: 100%;
    max-width: 540px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
}
.modal-head {
    padding: 12px 18px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: none;
}
.modal-x {
    background: none;
    border: 0;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    padding: 2px 6px;
}
.modal-x:hover { background: rgba(0, 0, 0, .25); }
.modal-body { padding: 18px; overflow-y: auto; font-size: 14px; }
.modal-foot {
    padding: 12px 18px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #F2F2F2;
    flex: none;
}
.modal table { font-size: 13px; }

/* ---------------- Toast ---------------- */
.toast {
    position: fixed;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: rgba(18, 22, 40, .96);
    color: #fff;
    padding: 10px 24px;
    font-size: 14px;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
    max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-err { background: var(--c-red); }

/* ---------------- 预警/通知条目 ---------------- */
.notice-item {
    background: var(--panel);
    color: var(--ink);
    padding: 13px 16px;
    margin-bottom: 10px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.notice-item.unread { border-left: 5px solid #E81123; }
.notice-item.read { border-left: 5px solid #D8D8D8; opacity: .8; }
.notice-main { flex: 1; min-width: 0; }
.notice-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notice-detail { font-size: 13px; color: #555; margin-top: 4px; }
.notice-time { font-size: 12px; color: #AAA; margin-top: 4px; }
.notice-actions { display: flex; gap: 6px; flex: none; }

/* ---------------- 其他 ---------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.hidden { display: none !important; }
.muted { color: #888; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; }
.mt12 { margin-top: 12px; }
.mb0 { margin-bottom: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.kv { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; color: #555; margin: 3px 0; }
.kv b { color: var(--ink); }

/* 键盘可达性 */
:focus-visible { outline: 3px solid var(--c-yellow); outline-offset: 2px; }

/* ---------------- 响应式：手机单列 ---------------- */
@media (max-width: 820px) {
    .tile-wide { grid-column: span 1; }
    .chat-wrap { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .logo-text { max-width: 130px; font-size: 14px; }
    .main { padding-top: 66px; }
    .page-head-title { font-size: 20px; }
    .msg { max-width: 88%; }
}

@media (max-width: 560px) {
    .tiles { grid-template-columns: 1fr; }
    .tile { min-height: 132px; }
    .userchip-name { display: none; }
    .nav-item { padding: 8px 10px; font-size: 13px; }
}

/* 动效偏好：减少动态 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
