/* Terry 家庭助理 · 温暖家庭风视觉 */

:root {
    --coral: #ff7a6b;
    --coral-dark: #e85a4a;
    --orange: #ffa64d;
    --green: #5a9367;
    --blue: #6b8cae;
    --cream: #fdf8f3;
    --cream-2: #f7efe5;
    --text: #2d2520;
    --text-soft: #6b5d53;
    --border: #e6d9c9;
    --danger: #d64545;
    --warn: #e8a83a;
    --shadow: 0 2px 8px rgba(45, 37, 32, 0.08);
    --shadow-lg: 0 8px 32px rgba(45, 37, 32, 0.12);
    --radius: 14px;
    --radius-sm: 10px;
}

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

html, body {
    height: 100%;
    font-family: "PingFang SC", "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    color: var(--text);
    background: var(--cream);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    outline: none;
}

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

/* ===== 登录页 ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fff0e6 0%, #ffe4d6 50%, #ffd4c1 100%);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: white;
    border-radius: 20px;
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 8px;
    font-size: 54px;
}

.login-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.login-subtitle {
    text-align: center;
    color: var(--text-soft);
    font-size: 13px;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-soft);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--coral);
    box-shadow: 0 0 0 3px rgba(255, 122, 107, 0.12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
    gap: 6px;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--coral);
    color: white;
}

.btn-primary:hover {
    background: var(--coral-dark);
    box-shadow: 0 4px 12px rgba(255, 122, 107, 0.35);
}

.btn-secondary {
    background: var(--cream-2);
    color: var(--text);
}

.btn-secondary:hover { background: #ebdfcd; }

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-soft);
}

.btn-ghost:hover { background: var(--cream-2); }

.btn-full { width: 100%; padding: 14px; font-size: 15px; }

.err-msg {
    color: var(--danger);
    font-size: 13px;
    padding: 10px 12px;
    background: #fff0f0;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    display: none;
}

.err-msg.show { display: block; }

/* ===== 主应用布局 ===== */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px 1fr;
}

.sidebar {
    background: white;
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--coral), var(--orange));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.brand-name {
    font-weight: 700;
    font-size: 15px;
}

.brand-sub {
    font-size: 11px;
    color: var(--text-soft);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.1s;
}

.nav-item:hover { background: var(--cream-2); color: var(--text); }

.nav-item.active {
    background: linear-gradient(90deg, rgba(255, 122, 107, 0.14), rgba(255, 166, 77, 0.08));
    color: var(--coral-dark);
    font-weight: 600;
}

.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

.nav-bottom {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--cream-2);
    margin-bottom: 8px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    color: white;
}

.avatar-sm { width: 24px; height: 24px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 24px; }

.user-card .name { font-size: 13px; font-weight: 600; }
.user-card .role { font-size: 11px; color: var(--text-soft); }

.main {
    padding: 28px 36px;
    max-width: 1200px;
    width: 100%;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
}

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

.card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== Dashboard 网格 ===== */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.stat-card {
    background: linear-gradient(135deg, var(--coral), var(--orange));
    color: white;
    border-radius: var(--radius);
    padding: 20px;
}

.stat-card .label { font-size: 13px; opacity: 0.9; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 4px; }

.empty {
    padding: 32px;
    text-align: center;
    color: var(--text-soft);
    font-size: 13px;
}

.empty .empty-icon { font-size: 42px; margin-bottom: 10px; }

/* ===== Events / Announcements ===== */
.evt-item, .ann-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: white;
    margin-bottom: 10px;
    transition: border-color 0.15s;
}

.evt-item:hover, .ann-item:hover { border-color: var(--coral); }

.evt-time {
    font-size: 12px;
    color: var(--text-soft);
    display: flex;
    align-items: center;
    gap: 6px;
}

.evt-title {
    font-weight: 600;
    margin: 4px 0;
}

.evt-meta {
    font-size: 12px;
    color: var(--text-soft);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
}

.badge-school { background: #e4f0ff; color: #2d5f9e; }
.badge-medical { background: #ffe4e4; color: #b63838; }
.badge-activity { background: #e4f7e4; color: #3a7c3a; }
.badge-parent { background: #f0e4ff; color: #6a3aa0; }
.badge-family { background: #fff3e0; color: #a06d20; }
.badge-other { background: #f0f0f0; color: #666; }

.priority-urgent { border-left: 4px solid var(--danger); }
.priority-high { border-left: 4px solid var(--warn); }
.priority-normal { border-left: 4px solid var(--blue); }
.priority-low { border-left: 4px solid var(--border); }

.ann-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.ann-title { font-weight: 600; flex: 1; }

.ann-content {
    color: var(--text-soft);
    font-size: 14px;
    white-space: pre-wrap;
}

.ann-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-soft);
}

.readers {
    display: flex;
    gap: -6px;
}

.readers .avatar-sm + .avatar-sm { margin-left: -6px; border: 2px solid white; }

/* ===== Calendar 视图 ===== */
.cal-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.cal-head, .cal-cell {
    background: white;
    padding: 10px 8px;
    min-height: 96px;
}

.cal-head {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    min-height: 0;
    padding: 8px;
}

.cal-cell {
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
}

.cal-cell:hover { background: var(--cream); }
.cal-cell.other-month { background: #fafafa; color: #bbb; }
.cal-cell.today { background: #fff3e8; }
.cal-cell .day-num { font-size: 13px; font-weight: 600; margin-bottom: 6px; }

.cal-evt {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
    background: var(--coral);
}

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(45, 37, 32, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-backdrop.show { display: flex; }

.modal {
    background: white;
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

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

.modal-title { font-size: 17px; font-weight: 700; }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== 用户列表 ===== */
.user-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    background: white;
}

.user-row .info { flex: 1; }
.user-row .name { font-weight: 600; }
.user-row .meta { font-size: 12px; color: var(--text-soft); }

.role-tag {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 8px;
    font-weight: 600;
}

.role-super_admin { background: #fff0ee; color: var(--coral-dark); }
.role-parent { background: #e4f0ff; color: #2d5f9e; }
.role-teen { background: #e4f7e4; color: #3a7c3a; }
.role-guest { background: #f0f0f0; color: #666; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 100; transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.open { transform: translateX(0); }
    .main { padding: 16px; }
    .cal-cell { min-height: 68px; }
    .mobile-menu-btn { display: inline-flex; }
}

.mobile-menu-btn {
    display: none;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: white;
    border: 1px solid var(--border);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: white;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.2s;
    z-index: 2000;
    max-width: 320px;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--green); }
.toast.error { background: var(--danger); }

/* ===== 通用 · 表单/卡片网格/筹码/气泡（contacts / places / trips 共用） ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
}
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--text-soft);
    font-weight: 600;
}
.form-grid input, .form-grid select, .form-grid textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: white;
}
.form-grid textarea { resize: vertical; min-height: 56px; }
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.contact-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.contact-card:hover {
    border-color: var(--coral);
    box-shadow: 0 4px 14px rgba(255,122,107,0.1);
    transform: translateY(-1px);
}

.chip {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    cursor: pointer;
    transition: all 0.15s;
}
.chip:hover { border-color: var(--coral); color: var(--text); }
.chip-on {
    background: var(--coral);
    border-color: var(--coral);
    color: white;
}

/* ===== 出差托付 专属 ===== */
.trip-split {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    align-items: flex-start;
}
@media (max-width: 900px) { .trip-split { grid-template-columns: 1fr; } }

.trip-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

.trip-list-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.trip-list-item:hover { border-color: var(--coral-light, #ffb3a8); }
.trip-list-item.active {
    background: linear-gradient(135deg, #fff3f0, #fff);
    border-color: var(--coral);
    box-shadow: 0 2px 10px rgba(255,122,107,0.15);
}

.trip-detail {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    min-height: 400px;
}

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

.trip-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.trip-dels { margin-top: 14px; }

.trip-day { margin-bottom: 16px; }
.trip-day-head {
    font-weight: 700;
    color: var(--text-soft);
    font-size: 13px;
    padding: 6px 0;
    letter-spacing: 2px;
}

.del-card {
    padding: 14px 16px;
    background: #fdf8f3;
    border-radius: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}
.del-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.del-depart {
    font-weight: 700;
    color: var(--coral);
    font-size: 16px;
}
.del-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
    margin-left: 4px;
}

/* ===== 时间轴 ===== */
.timeline {
    position: relative;
    padding: 8px 0 0 8px;
}
.timeline::before {
    content: "";
    position: absolute;
    left: 72px;
    top: 16px;
    bottom: 16px;
    width: 2px;
    background: #e4d4c2;
    border-radius: 1px;
}
.tl-stop {
    display: grid;
    grid-template-columns: 56px 24px 1fr auto;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 0;
    position: relative;
}
.tl-time {
    font-weight: 700;
    color: var(--text);
    font-size: 14px;
    padding-top: 4px;
}
.tl-node {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: white;
    border: 3px solid #fdf8f3;
    box-shadow: 0 0 0 1px #e4d4c2;
    z-index: 1;
    margin-left: -2px;
}
.tl-body { min-width: 0; padding-top: 2px; }
.tl-place { font-weight: 600; font-size: 14px; }
.tl-addr { color: var(--text-soft); font-size: 12px; margin-top: 1px; }
.tl-note {
    background: #fff9e6;
    color: #8a5a00;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    margin-top: 4px;
    display: inline-block;
}
.kid-line {
    font-size: 13px;
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}
.kid-line.pu { color: #3a7c3a; }
.kid-line.dr { color: #b63838; }
.kid-line.wi { color: var(--text-soft); }
.kid-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 12px;
    color: var(--text);
}

/* ===== 站点编辑器 ===== */
.stop-edit {
    background: #fdf8f3;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
}
.stop-edit-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.stop-edit-seq {
    font-weight: 700;
    color: var(--coral);
    font-size: 13px;
}
.kid-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
    padding: 6px 0;
}
.kid-pick-row {
    display: flex;
    gap: 6px;
    align-items: center;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 8px;
}
.kid-pick-lbl {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 400 !important;
    color: var(--text) !important;
}
.kid-pick-lbl input { width: auto; margin: 0; }
.kid-role {
    font-size: 11px;
    padding: 3px 6px;
}

/* 周几重复 */
.wd-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.wd-chip {
    min-width: 48px;
    padding: 6px 10px;
}
.wd-preview {
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-soft);
    background: #fdf8f3;
    border-radius: 8px;
    line-height: 1.6;
    min-height: 14px;
}
.wd-preview:empty { display: none; }

/* 模板套用栏 */
.tpl-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: linear-gradient(90deg, #fff9e6, #fff3d6);
    border: 1px solid #f0d9a0;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
}
.tpl-bar select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    font-size: 13px;
}
.tpl-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 8px;
    background: #fdf8f3;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.tpl-row:hover { border-color: var(--coral); }

/* ===== 成绩单卡片 ===== */
.rc-card {
    padding: 14px 16px;
    margin-bottom: 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: border-color 0.15s;
}
.rc-card:hover { border-color: #f0d0c8; }
.rc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.rc-title { font-size: 15px; font-weight: 700; }
.rc-meta { font-size: 12px; color: var(--text-soft); margin-top: 3px; }
.rc-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.rc-actions .btn { padding: 4px 10px; font-size: 12px; }
.rc-summary {
    background: #fdf8f3;
    border: 1px solid #ebdfd0;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    margin-bottom: 10px;
}
.rc-md-h {
    font-weight: 700;
    color: var(--coral-dark, #c55a4a);
    font-size: 13px;
    margin: 8px 0 4px;
}
.rc-md-h:first-child { margin-top: 0; }
.rc-md-li { padding-left: 8px; margin: 2px 0; }
.rc-notes {
    background: #fff9e6;
    color: #8a5a00;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 8px;
}
.rc-attach {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    flex-wrap: wrap;
}

/* 分享 */
.share-users {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}
.share-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.share-user:hover { border-color: var(--coral); }
.share-user input { margin: 0; }

.share-inbox-item {
    padding: 12px 14px;
    margin-bottom: 10px;
    background: #fdf8f3;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.share-inbox-item.unread { border-color: var(--coral); background: #fff6f3; }
.share-inbox-item.read { opacity: 0.8; }
