/* =====================================================================
   设计系统 · 变量与通用组件
   主题色通过 CSS 变量注入：租户换品牌色只需覆盖 --brand-* 这几项，
   不需要改任何页面样式。
   ===================================================================== */
:root {
    --brand-900: #14532D;
    --brand-800: #1B6B3C;
    --brand-700: #208748;
    --brand-600: #229653;
    --brand-100: #DDF2E5;
    --brand-50: #EEF8F1;

    --ink: #151B18;
    --ink-2: #333D38;
    --ink-3: #5C6B63;
    --muted: #87948C;
    --line: #DDE6E0;
    --line-2: #EDF2EE;
    --bg: #F5F7F6;

    --danger: #C0443A;
    --warn: #B97A2E;
    --ok: #229653;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 18px;
    --shadow: 0 18px 44px rgba(18, 40, 27, .12);
    --shadow-soft: 0 3px 12px rgba(18, 40, 27, .07);

    --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
            "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

a { color: var(--brand-700); }

.hidden { display: none !important; }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    padding: 0 14px;
    height: 34px;
    font-size: 13.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background .16s, border-color .16s, opacity .16s;
    white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }
.btn-ghost {
    background: #fff;
    border-color: var(--line);
    color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--brand-50); border-color: var(--brand-100); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }
.btn-danger-ghost {
    background: #fff; border-color: #EFCFCF; color: var(--danger);
}
.btn-danger-ghost:hover:not(:disabled) { background: #FFF6F6; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- 表单控件 ---------- */
.input, .select, .textarea {
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 0 12px;
    height: 38px;
    outline: none;
    transition: border-color .16s, box-shadow .16s;
}
.textarea { height: auto; padding: 9px 12px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--brand-600);
    box-shadow: 0 0 0 3px rgba(46, 139, 87, .12);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }

.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 6px;
}
.field .req { color: var(--danger); font-style: normal; margin-left: 2px; }

/* ---------- 吐司 ---------- */
.toast-layer {
    position: fixed;
    left: 50%;
    top: 18px;
    transform: translateX(-50%);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}
.toast {
    background: rgba(31, 42, 36, .92);
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
    padding: 9px 16px;
    border-radius: 999px;
    max-width: min(86vw, 420px);
    animation: toast-in .2s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.toast-ok { background: var(--brand-700); }
.toast-err { background: #A93226; }
.toast.out { opacity: 0; transition: opacity .22s; }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
}

/* ---------- 弹窗 ---------- */
.mask {
    position: fixed;
    inset: 0;
    background: rgba(18, 30, 24, .38);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 8000;
    padding: 16px;
    animation: mask-in .16s ease;
}
@keyframes mask-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
    width: 100%;
    max-width: 460px;
    background: #fff;
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: modal-in .18s ease;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(.99); }
    to { opacity: 1; transform: none; }
}
.modal-head {
    display: flex;
    align-items: center;
    padding: 16px 18px 10px;
}
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-head .close {
    margin-left: auto;
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
}
.modal-body { padding: 4px 18px 8px; font-size: 13.5px; color: var(--ink-2); line-height: 1.7; }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px 16px;
}

/* ---------- 表格 ---------- */
.table-wrap {
    background: #fff;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    overflow: auto;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
}
.table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: #FBFDFC;
    position: sticky;
    top: 0;
    z-index: 1;
}
.table tbody tr:hover { background: #FBFDFC; }
.table tbody tr:last-child td { border-bottom: none; }

/* ---------- 空态 ---------- */
.empty {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.9;
    padding: 48px 20px;
}

/* ---------- 移动端：输入框字号给足 16px ----------
   iOS 聚焦小于 16px 的输入框会自动放大页面，
   放大后布局比屏幕宽，右侧按钮会被挤出可视区。 */
@media (max-width: 768px) {
    input, select, textarea, .input, .select, .textarea { font-size: 16px; }
}
