/* =========================================================
   吃药提醒系统 · 统一设计系统
   ========================================================= */

:root {
    --brand:        #409eff;
    --brand-dark:   #337ecc;
    --brand-light:  #ecf5ff;
    --success:      #67c23a;
    --warning:      #e6a23c;
    --danger:       #f56c6c;
    --info:         #909399;

    --bg:           #f4f6f9;
    --card:         #ffffff;
    --text:         #1f2d3d;
    --text-regular: #4e5969;
    --text-secondary: #86909c;
    --border:       #e8ecf1;
    --border-light: #f2f4f7;

    --radius:       12px;
    --radius-sm:    8px;
    --shadow:       0 2px 12px rgba(31, 45, 61, .06);
    --shadow-lg:    0 8px 28px rgba(31, 45, 61, .10);

    --sidebar-w:    232px;
    --topbar-h:     62px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[v-cloak] { display: none !important; }

a { color: var(--brand); text-decoration: none; }

.fade-enter-active, .fade-leave-active { transition: opacity .2s; }
.fade-enter-from, .fade-leave-to { opacity: 0; }

/* =========================================================
   应用骨架
   ========================================================= */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, #fbfcfe 0%, #f4f7fb 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: width .24s cubic-bezier(.4, 0, .2, 1);
}

.sidebar.is-collapsed { width: 68px; }

.brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar.is-collapsed .brand { padding: 0 20px; }

.brand-logo {
    font-size: 24px;
    line-height: 1;
    flex-shrink: 0;
}

.brand-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.brand-sub {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-top: 1px;
}

.menu {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
    padding: 0 14px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    color: var(--text-regular);
    font-size: 14px;
    white-space: nowrap;
    transition: background .18s, color .18s;
}

.menu-item:hover {
    background: #eaf1fb;
    color: var(--brand);
}

.menu-item.active {
    background: var(--brand);
    color: #fff;
    font-weight: 500;
    box-shadow: 0 3px 10px rgba(64, 158, 255, .28);
}

.menu-item .el-icon { font-size: 18px; flex-shrink: 0; }

.sidebar-foot {
    padding: 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.collapse-btn {
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: background .18s, color .18s;
}

.collapse-btn:hover { background: #eaf1fb; color: var(--brand); }

.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- 顶栏 ---------- */
.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left { display: flex; align-items: baseline; gap: 12px; }

.page-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.page-date { font-size: 13px; color: var(--text-secondary); }

.topbar-right { display: flex; align-items: center; gap: 18px; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 5px;
    border-radius: 20px;
    cursor: pointer;
    transition: background .18s;
    outline: none;
}

.user-chip:hover { background: var(--border-light); }

.user-avatar {
    background: linear-gradient(135deg, #409eff, #66b1ff);
    color: #fff;
    font-weight: 600;
}

.user-name { font-size: 14px; color: var(--text-regular); }
.arrow { font-size: 12px; color: var(--text-secondary); }

/* ---------- 内容区 ---------- */
.content {
    flex: 1;
    padding: 22px 24px 8px;
    min-width: 0;
}

.page { max-width: 1400px; }

.footer {
    padding: 16px 24px 22px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.footer .dot { margin: 0 8px; }

/* =========================================================
   通用组件
   ========================================================= */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 10px;
}

.card-head h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.card-head-sub { font-size: 13px; color: var(--text-secondary); }
.card-head-right { display: flex; gap: 6px; flex-wrap: wrap; }

.empty { padding: 30px 20px 40px; }

/* ---------- 工具栏 ---------- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.toolbar-right { display: flex; gap: 10px; }

.date-nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.date-tag {
    font-size: 13px;
    color: var(--text-regular);
    background: #fff;
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 18px;
}

.date-tag.is-today {
    background: var(--brand-light);
    border-color: #b3d8ff;
    color: var(--brand);
    font-weight: 500;
}

.page-subtitle { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.page-desc { font-size: 13px; color: var(--text-secondary); margin: 0; }

/* ---------- 统计卡片 ---------- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-row.compact { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    flex-shrink: 0;
}

.stat-body { flex: 1; min-width: 0; }

.stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; }

.stat-value {
    font-size: 25px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat-suffix { font-size: 13px; font-weight: 400; color: var(--text-secondary); margin-left: 3px; }
.stat-ring { flex-shrink: 0; }

/* ---------- 提醒列表 ---------- */
.reminder-list { list-style: none; margin: 0; padding: 6px 0; }

.reminder-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    transition: background .18s;
    position: relative;
}

.reminder-item:last-child { border-bottom: none; }
.reminder-item:hover { background: #fafbfd; }

.reminder-item.is-done { background: #fafcfa; }
.reminder-item.is-done .ri-title { color: var(--text-secondary); text-decoration: line-through; }
.reminder-item.is-skipped { opacity: .62; }

.reminder-item.is-overdue::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--warning);
}

.ri-time {
    width: 62px;
    flex-shrink: 0;
    text-align: right;
}

.ri-time-hm {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.ri-time-tag {
    font-size: 11px;
    color: var(--success);
    margin-top: 2px;
}

.ri-time-tag.pending { color: var(--warning); }

.ri-bar {
    width: 3px;
    align-self: stretch;
    min-height: 36px;
    border-radius: 3px;
    flex-shrink: 0;
}

.ri-main { flex: 1; min-width: 0; }

.ri-title-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.ri-title { font-size: 15px; font-weight: 500; color: var(--text); }

.ri-note {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ri-taken {
    font-size: 12px;
    color: var(--success);
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ri-action {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-shrink: 0;
}

.ri-value { display: flex; align-items: center; gap: 6px; }
.value-input { width: 118px; }
.value-unit { font-size: 13px; color: var(--text-secondary); }

.done-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--success);
    min-width: 80px;
    text-align: right;
}

.ri-buttons { display: flex; align-items: center; gap: 8px; }

.ri-buttons .el-checkbox__label { font-size: 13px; }

.reminder-item.is-done .ri-buttons .el-checkbox__label { color: var(--text-secondary); }

/* ---------- 计划卡片 ---------- */
.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.plan-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow .2s, transform .2s;
    display: flex;
    flex-direction: column;
}

.plan-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.plan-card.is-off { opacity: .62; background: #fafbfc; }

.pc-head {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-light);
}

.pc-color {
    width: 4px;
    align-self: stretch;
    min-height: 38px;
    border-radius: 3px;
    flex-shrink: 0;
}

.pc-title-wrap { flex: 1; min-width: 0; }

.pc-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    word-break: break-all;
}

.pc-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.pc-body { padding: 12px 16px; flex: 1; }

.pc-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--text-regular);
    margin-bottom: 8px;
    line-height: 1.5;
}

.pc-row:last-child { margin-bottom: 0; }
.pc-row .el-icon { color: var(--text-secondary); margin-top: 2px; flex-shrink: 0; }

.pc-foot {
    padding: 10px 16px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
}

/* ---------- 表单 ---------- */
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 5px; line-height: 1.6; }
.form-hint.is-warn { color: var(--warning); }
.form-suffix { margin-left: 10px; font-size: 13px; color: var(--text-regular); }
.divider-text { font-size: 13px; font-weight: 600; color: var(--text-regular); padding: 0 8px; }

.time-preview { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.time-editor { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.time-chip { display: flex; align-items: center; gap: 4px; }

/* ---------- 筛选 ---------- */
.filter-card { padding: 4px 20px 18px; }
.filter-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter-right { margin-left: auto; display: flex; gap: 10px; }

/* ---------- 表格 ---------- */
.cell-date { font-weight: 500; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.cell-muted { color: #c0c4cc; }
.cell-value { font-weight: 600; color: var(--success); font-variant-numeric: tabular-nums; }

.cell-title {
    display: inline-block;
    padding-left: 9px;
    border-left: 3px solid var(--brand);
    font-weight: 500;
    color: var(--text);
}

.table-foot {
    padding: 12px 20px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    border-top: 1px solid var(--border-light);
}

/* ---------- 图表 ---------- */
.chart { width: 100%; height: 300px; padding: 12px; }
.chart-lg { height: 360px; }

/* ---------- 个人设置 ---------- */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 18px;
    align-items: start;
}

.profile-user { display: flex; align-items: center; gap: 16px; padding: 22px 20px 18px; }
.big-avatar { background: linear-gradient(135deg, #409eff, #66b1ff); color: #fff; font-size: 24px; font-weight: 600; }
.profile-name { font-size: 18px; font-weight: 600; }
.profile-date { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.mini-stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--border-light);
}

.mini-stat { padding: 14px 10px; text-align: center; border-right: 1px solid var(--border-light); }
.mini-stat:last-child { border-right: none; }
.mini-value { font-size: 20px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.mini-label { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

.notify-box { padding: 20px; }
.delta-up { color: var(--danger); }
.delta-down { color: var(--success); }

/* ---------- 登录 / 注册 ---------- */
#auth-root {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #5b8def 0%, #6f7ee8 45%, #9271e8 100%);
    position: relative;
    overflow: hidden;
}

#auth-root::before,
#auth-root::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .07);
}

#auth-root::before { width: 420px; height: 420px; top: -140px; right: -110px; }
#auth-root::after  { width: 320px; height: 320px; bottom: -100px; left: -90px; }

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .2);
    padding: 38px 36px 30px;
}

.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-logo { font-size: 46px; line-height: 1; margin-bottom: 12px; }
.auth-brand h1 { font-size: 22px; font-weight: 600; color: var(--text); margin: 0 0 6px; }
.auth-brand p { font-size: 13px; color: var(--text-secondary); margin: 0; }

.auth-alert { margin-bottom: 18px; }
.auth-submit { width: 100%; margin-top: 6px; height: 44px; font-size: 15px; letter-spacing: 2px; }

/* 「记住我」勾选框 */
.auth-remember { margin: -8px 0 2px; }
.auth-remember .el-checkbox { height: 32px; }
.auth-remember .el-checkbox__label { font-size: 14px; color: var(--text-secondary); padding-left: 9px; }

.auth-foot {
    text-align: center;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-foot a { font-weight: 500; }

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 900px) {
    .sidebar { width: 68px; }
    .sidebar .brand-text,
    .sidebar .menu-item span,
    .collapse-btn span { display: none; }
    .content { padding: 16px 14px 8px; }
    .topbar { padding: 0 16px; }
    .reminder-item { flex-wrap: wrap; padding: 14px 16px; }
    .ri-action { width: 100%; justify-content: flex-end; padding-left: 92px; }
    .user-name { display: none; }
    .profile-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .auth-card { padding: 30px 22px 24px; }
    .filter-right { margin-left: 0; width: 100%; }
    .plan-grid { grid-template-columns: 1fr; }
}
