/* ============================================================
 * 食堂菜单管理系统 · UI 设计 v4
 * 现代 · 清爽 · 有层次
 * ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #059669;
  --primary-d: #047857;
  --primary-l: #d1fae5;
  --primary-ll: #ecfdf5;
  --success: #16a34a;
  --success-l: #dcfce7;
  --warning: #d97706;
  --warning-l: #fef3c7;
  --danger: #dc2626;
  --danger-l: #fee2e2;
  --info: #2563eb;
  --info-l: #dbeafe;
  --ink: #0f172a;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow: 0 1px 3px rgba(15,23,42,.05), 0 4px 14px rgba(15,23,42,.04);
  --shadow-md: 0 8px 24px rgba(15,23,42,.08);
  --shadow-lg: 0 24px 56px rgba(15,23,42,.18);
  --radius: 14px;
  --radius-sm: 10px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.65;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 17px; border-radius: 10px; font-size: 14px; font-weight: 600; transition: all .16s ease; white-space: nowrap; border: 1px solid var(--border); background: #fff; color: var(--text-2); }
.btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-ll); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(5,150,105,.25); }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); color: #fff; }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 8px; font-weight: 500; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); border-color: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 输入 ---------- */
.input, .select, .textarea { width: 100%; padding: 10px 13px; border: 1px solid var(--border); border-radius: 10px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(5,150,105,.12); }
.textarea { resize: vertical; min-height: 74px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 7px; font-weight: 600; color: var(--text-2); font-size: 13px; }
.field label .req { color: var(--danger); margin-left: 3px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: #fff; }
.login-brand { background: linear-gradient(160deg, #064e3b 0%, #047857 55%, #059669 100%); color: #fff; display: flex; align-items: center; justify-content: center; padding: 48px; position: relative; overflow: hidden; }
.login-brand::before { content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.12), transparent 65%); top: -120px; right: -100px; }
.login-brand::after { content: ''; position: absolute; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.08), transparent 65%); bottom: -90px; left: -70px; }
.login-brand-inner { position: relative; z-index: 1; max-width: 420px; }
.login-logo { width: 66px; height: 66px; border-radius: 18px; background: rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; font-size: 36px; margin-bottom: 24px; backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,.2); }
.login-brand h1 { font-size: 30px; letter-spacing: .5px; margin-bottom: 10px; }
.login-brand > .login-brand-inner > p { color: rgba(255,255,255,.85); font-size: 15px; margin-bottom: 34px; }
.login-features { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.login-features li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: rgba(255,255,255,.9); }
.login-features li span { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.14); display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 48px; background: #fff; }
.login-form-inner { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 26px; color: var(--ink); margin-bottom: 8px; }
.login-form-sub { color: var(--text-3); font-size: 13px; margin-bottom: 30px; }
.login-btn { width: 100%; padding: 12px; font-size: 15px; border-radius: 10px; }
.login-tips { margin-top: 22px; padding: 12px 14px; background: var(--primary-ll); border: 1px solid #a7f3d0; border-radius: 10px; font-size: 12px; color: #065f46; text-align: center; }
.login-tips b { color: var(--primary); }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; background: var(--ink); color: rgba(255,255,255,.72); display: flex; flex-direction: column; flex-shrink: 0; transition: transform .25s ease; }
.sidebar-logo { padding: 22px 20px 18px; font-size: 15px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; gap: 10px; }
.sidebar-logo .logo-ic { width: 34px; height: 34px; background: linear-gradient(135deg, #10b981, #059669); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.nav-group-title { padding: 18px 22px 6px; font-size: 11px; color: rgba(255,255,255,.32); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.nav-item { margin: 2px 12px; padding: 10px 13px; cursor: pointer; display: flex; align-items: center; gap: 11px; font-size: 14px; border-radius: 10px; transition: all .16s ease; color: rgba(255,255,255,.72); }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(5,150,105,.35); }
.nav-item .ic { font-size: 16px; width: 20px; text-align: center; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 60px; background: rgba(255,255,255,.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 26px; flex-shrink: 0; position: sticky; top: 0; z-index: 50; }
.topbar .crumb { font-size: 16px; font-weight: 700; color: var(--ink); }
.topbar .user-area { display: flex; align-items: center; gap: 12px; }
.topbar .user-chip { display: flex; align-items: center; gap: 8px; padding: 5px 13px 5px 6px; background: #f1f5f9; border-radius: 22px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.topbar .avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #10b981, #059669); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.role-badge { font-size: 11px; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.role-badge.admin { background: var(--danger-l); color: var(--danger); }
.role-badge.chef { background: var(--primary-l); color: var(--primary); }
.content { flex: 1; padding: 26px; overflow-y: auto; }

/* ---------- 工作台 hero ---------- */
.hero { background: linear-gradient(120deg, #064e3b, #059669 70%); border-radius: 16px; padding: 28px 30px; color: #fff; display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; box-shadow: 0 10px 28px rgba(5,150,105,.25); position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.12), transparent 65%); right: -60px; top: -80px; }
.hero-text h2 { font-size: 22px; margin-bottom: 6px; }
.hero-text p { color: rgba(255,255,255,.85); font-size: 13px; }
.hero-ic { font-size: 54px; opacity: .95; position: relative; z-index: 1; }

/* ---------- 快捷操作 ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.quick-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px; cursor: pointer; transition: all .18s ease; display: flex; flex-direction: column; gap: 5px; }
.quick-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.quick-card .quick-ic { font-size: 26px; margin-bottom: 4px; }
.quick-card b { font-size: 14px; color: var(--ink); }
.quick-card span { font-size: 12px; color: var(--text-3); }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; border: 1px solid var(--border); }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink); }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { flex: 1; min-width: 160px; max-width: 320px; }
.toolbar .spacer { flex: 1; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.table thead th { background: #f8fafc; font-weight: 600; color: var(--text-2); white-space: nowrap; position: sticky; top: 0; font-size: 12px; letter-spacing: .3px; }
.table tbody tr { transition: background .14s ease; }
.table tbody tr:hover { background: #f0fdf4; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; padding: 56px 20px; color: var(--text-3); }
.empty .big { font-size: 48px; margin-bottom: 12px; }

/* ---------- 标签 ---------- */
.tag { display: inline-block; padding: 2px 11px; border-radius: 8px; font-size: 12px; line-height: 1.7; font-weight: 600; }
.tag-blue { background: var(--info-l); color: var(--info); }
.tag-green { background: var(--success-l); color: var(--success); }
.tag-orange { background: var(--warning-l); color: #b45309; }
.tag-gray { background: #f1f5f9; color: var(--text-3); }
.tag-red { background: var(--danger-l); color: var(--danger); }
.tag-purple { background: #f3e8ff; color: #7e22ce; }
.stars { color: #f59e0b; letter-spacing: 1px; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 16px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.pager button { padding: 7px 13px; border: 1px solid var(--border); border-radius: 8px; background: #fff; transition: all .15s; font-weight: 500; }
.pager button:hover { border-color: var(--primary); color: var(--primary); }
.pager button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 模态框 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; z-index: 1000; padding: 42px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 660px; box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.2,.8,.3,1); }
.modal.wide { max-width: 940px; }
@keyframes pop { from { transform: translateY(18px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 20px 26px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 700; color: var(--ink); }
.modal-head .close { font-size: 24px; color: var(--text-3); line-height: 1; padding: 4px 9px; border-radius: 8px; transition: all .15s; }
.modal-head .close:hover { background: #f1f5f9; color: var(--text); }
.modal-body { padding: 24px 26px; max-height: 74vh; overflow-y: auto; }
.modal-foot { padding: 16px 26px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 重复预警 ---------- */
.dup-warn { background: var(--warning-l); border: 1px solid #fde68a; border-radius: 10px; padding: 11px 14px; color: #92400e; font-size: 13px; display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.dup-warn .ic { font-size: 16px; }

/* ---------- 日菜单 ---------- */
.meal-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.meal-col { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.meal-col-head { padding: 12px 16px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; color: #fff; }
.meal-col-head.breakfast { background: linear-gradient(90deg,#d97706,#f59e0b); }
.meal-col-head.lunch { background: linear-gradient(90deg,#059669,#10b981); }
.meal-col-head.dinner { background: linear-gradient(90deg,#2563eb,#3b82f6); }
.meal-col-head .cnt { font-size: 12px; font-weight: 500; opacity: .92; }
.meal-body { padding: 12px; min-height: 84px; }
.meal-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 10px; background: #f8fafc; margin-bottom: 7px; font-size: 13px; transition: background .15s; }
.meal-item:hover { background: var(--primary-l); }
.meal-item .name { font-weight: 600; }
.meal-item .meta { color: var(--text-3); font-size: 12px; }
.meal-item .rm { color: var(--danger); cursor: pointer; padding: 2px 8px; border-radius: 7px; }
.meal-item .rm:hover { background: var(--danger-l); }
.add-dish-row { display: flex; gap: 8px; padding: 11px; border-top: 1px dashed var(--border); }
.add-dish-row select { flex: 1; }

/* ---------- 周菜单 ---------- */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 11px; }
.day-card { border: 1px solid var(--border); border-radius: 12px; background: #fff; min-height: 164px; display: flex; flex-direction: column; transition: all .18s; }
.day-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.day-card .day-head { padding: 10px 12px; font-weight: 700; font-size: 13px; border-bottom: 1px solid var(--border); background: #f8fafc; display: flex; justify-content: space-between; align-items: center; }
.day-card .day-body { padding: 10px; flex: 1; font-size: 12px; }
.day-card.assigned { border-color: var(--primary); }
.day-card .placeholder { color: var(--text-3); text-align: center; padding: 22px 4px; }
.day-card .meal-mini { margin-bottom: 6px; }
.day-card .meal-mini b { color: var(--text-2); }

/* ---------- 原料/流程 ---------- */
.item-row { display: grid; grid-template-columns: 1.4fr .7fr .8fr .8fr .8fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.item-row input, .item-row select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.step-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.step-row .step-no { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; box-shadow: 0 3px 8px rgba(5,150,105,.3); }
.step-row .content { flex: 1; }
.add-row-btn { color: var(--primary); font-size: 13px; font-weight: 600; padding: 6px 0; cursor: pointer; }
.add-row-btn:hover { text-decoration: underline; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 12px 22px; border-radius: 11px; color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 10px 28px rgba(15,23,42,.2); animation: slideDown .22s ease; }
@keyframes slideDown { from { transform: translateY(-18px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
.toast.warn { background: var(--warning); }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); border: 1px solid var(--border); transition: all .2s; }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-head { display: flex; align-items: center; gap: 10px; }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-card .label { color: var(--text-2); font-size: 13px; font-weight: 600; }
.stat-card .num { font-size: 28px; font-weight: 800; margin-top: 12px; letter-spacing: -.5px; color: var(--ink); }

/* ---------- 日历 ---------- */
.cal-day { transition: all .15s ease; }
.cal-day:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.cal-day.today { border-color: var(--primary); background: var(--primary-ll); }

/* ---------- 加载 ---------- */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 44px; color: var(--text-3); font-weight: 500; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 响应式 ---------- */
.menu-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-toggle { display: inline-flex; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .week-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .content { padding: 14px; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 10px 8px; }
  .login-form { padding: 28px 22px; }
  .topbar { padding: 0 14px; }
  .topbar .user-chip span:last-child, .topbar .role-badge { display: none; }
}
.scrim { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 90; }
.scrim.show { display: block; }
