:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --ink-soft: #52606d;
  --line: #e4e7eb;
  --brand: #a4322b;
  --brand-dark: #7f251f;
  --ok: #1d7a4f;
  --warn: #b7791f;
  --danger: #c0392b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft JhengHei", "PingFang HK", "Noto Sans CJK TC", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
}

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

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: #202a36;
  color: #e6edf3;
  flex-shrink: 0;
}

.sidebar .brand {
  padding: 18px 20px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,.08);
  letter-spacing: .5px;
}

.sidebar nav { padding: 10px 0; }

.sidebar nav a {
  display: block;
  padding: 12px 20px;
  color: #cbd5e0;
  font-size: 15px;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.is-active { background: rgba(164,50,43,.18); color: #fff; border-left-color: var(--brand); }

.sidebar .group {
  padding: 14px 20px 6px;
  font-size: 13px;
  color: #7b8794;
  text-transform: none;
}

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

.topbar {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar .title { font-size: 17px; font-weight: 600; }
.topbar .me { color: var(--ink-soft); font-size: 14px; }
.topbar .me strong { color: var(--ink); }
.topbar-right { display: flex; align-items: center; }

.content { padding: 24px; flex: 1; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 600; }
.page-head .sub { color: var(--ink-soft); font-size: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.card h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
.card h3 { font-size: 15px; margin: 18px 0 10px; font-weight: 600; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--ink-soft); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--ink-soft); font-weight: 600; background: #fafbfc; }
tbody tr:hover { background: #fcfcfd; }

.empty { color: var(--ink-soft); padding: 24px; text-align: center; font-size: 14px; }

.btn {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
}

.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: #f5f6f8; }
.btn.small { padding: 4px 9px; font-size: 13px; }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

label { display: block; font-size: 14px; margin-bottom: 5px; color: var(--ink-soft); }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 12px; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; }

.flash { margin-bottom: 14px; }
.flash .item { padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 8px; }
.flash .success { background: #e7f5ed; color: var(--ok); border: 1px solid #bfe3ce; }
.flash .error { background: #fdecea; color: var(--danger); border: 1px solid #f6cdc8; }
.flash .warning { background: #fdf5e3; color: var(--warn); border: 1px solid #f2dfb2; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 13px; background: #eef1f4; color: var(--ink-soft); }
.badge.ok { background: #e7f5ed; color: var(--ok); }
.badge.warn { background: #fdf5e3; color: var(--warn); }
.badge.danger { background: #fdecea; color: var(--danger); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 384px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; text-align: center; }
.login-card .tip { color: var(--ink-soft); font-size: 13px; text-align: center; margin-bottom: 20px; }

.cal-table { display: block; overflow-x: auto; }
.cal-table table { min-width: 760px; }
.slot-free { color: var(--ok); }
.slot-busy { background: #fdecea; color: var(--danger); }
.slot-hold { background: #fdf5e3; color: var(--warn); }

.muted { color: var(--ink-soft); }
.mono { font-family: Consolas, "Courier New", monospace; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .field { min-width: 150px; }

/* 电话输入：地区码与本地号码 */
.phone-field { display: flex; gap: 8px; }
.phone-field select.phone-region { flex: 0 0 auto; width: auto; min-width: 132px; }
.phone-field input { flex: 1 1 auto; }
.phone-hint { font-size: 13px; margin-top: 4px; }

/* 浮层提示 */
.toast-stack {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(360px, 90vw);
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(15, 23, 33, .16);
    font-size: 14px;
    line-height: 1.5;
    animation: toast-in .18s ease-out;
}

.toast-icon {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: var(--ink-soft);
}

.toast-text { flex: 1 1 auto; word-break: break-word; }

.toast-close {
    flex: 0 0 auto;
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--ink-soft);
    padding: 0 2px;
}

.toast-success { border-left: 4px solid var(--ok); }
.toast-success .toast-icon { background: var(--ok); }

.toast-error { border-left: 4px solid var(--danger); }
.toast-error .toast-icon { background: var(--danger); }

.toast-warning { border-left: 4px solid var(--warn); }
.toast-warning .toast-icon { background: var(--warn); }

.toast-info { border-left: 4px solid var(--brand); }
.toast-info .toast-icon { background: var(--brand); }

.toast-hiding { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 表单辅助：复选、提示、行内表单与文字按钮 */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 14px 6px 0;
  font-weight: 400;
  color: var(--ink);
  cursor: pointer;
}

.hint {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 13px;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
}

.btn-text {
  background: none;
  border: none;
  padding: 0;
  color: var(--brand);
  font-size: 14px;
  cursor: pointer;
}

.btn-text:hover {
  text-decoration: underline;
}

/* 语言切换器 */
.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.lang-switch-label {
    color: var(--ink-soft);
    margin-right: 2px;
}

.lang-option {
    padding: 3px 9px;
    border-radius: 999px;
    color: var(--ink-soft);
    border: 1px solid var(--line);
    background: #fff;
    line-height: 1.6;
    white-space: nowrap;
}

.lang-option:hover {
    text-decoration: none;
    border-color: var(--brand);
    color: var(--brand);
}

.lang-option.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
}

.lang-option.is-active:hover {
    color: #fff;
    background: var(--brand-dark);
}

/* 登录页：居中、置于表单底部 */
.lang-switch-inline {
    display: flex;
    justify-content: center;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

/* 后台顶栏：紧凑排布 */
.lang-switch-compact {
    margin-left: 10px;
}

.lang-switch-compact .lang-option {
    padding: 2px 8px;
    font-size: 13px;
}

/* 订阅状态提示条（欠费控制） */
.notice {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid var(--line);
    background: #fafbfc;
    color: var(--ink-soft);
}

.notice.warning {
    background: #fdf5e3;
    border-color: #f0d9a8;
    color: #8a5a00;
}

.notice.error {
    background: #fdecea;
    border-color: #f5c6c2;
    color: var(--danger);
}

/* 合规文档页（隐私政策 / 用户协议） */
.legal-wrap {
    padding: 32px 20px 64px;
    display: flex;
    justify-content: center;
}

.legal-card {
    width: 100%;
    max-width: 780px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 32px 36px 28px;
}

.legal-head { text-align: center; margin-bottom: 20px; }
.legal-head h1 { font-size: 22px; margin: 0 0 6px; }

.legal-note { text-align: left; }

.legal-section { margin-top: 26px; }
.legal-section h2 {
    font-size: 15px;
    margin: 0 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}

.legal-body {
    font-size: 14px;
    line-height: 1.75;
    color: var(--ink);
}

.legal-foot {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    text-align: center;
}

.legal-sep { color: var(--line); margin: 0 8px; }

/* 报表环比涨跌 */
.delta-up { color: var(--ok); }
.delta-down { color: var(--danger); }

/* 登录页与后台页脚的合规入口 */
.login-legal { margin-top: 14px; text-align: center; font-size: 13px; }
.app-footer { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; font-size: 13px; }

/* 登录验证码 */
.captcha-field { display: flex; align-items: center; gap: 8px; }
.captcha-field input { flex: 1 1 auto; min-width: 0; }
.captcha-img {
    flex: 0 0 auto;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
}
.captcha-img:active { transform: translateY(1px); }
