:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #18201d;
  --muted: #66706b;
  --line: #dce2df;
  --sidebar: #1d2723;
  --accent: #14865f;
  --accent-dark: #0f684a;
  --danger: #b52f3a;
  --warning: #9b6a12;
  --radius: 7px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--sidebar); color: #e8eeeb; padding: 22px 14px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 8px 22px; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; background: #2eaa7d; color: #fff; border-radius: 6px; font-size: 13px; }
nav { display: grid; gap: 4px; }
nav a { color: #bfc9c4; text-decoration: none; padding: 10px 12px; border-radius: 6px; }
nav a:hover, nav a.active { color: #fff; background: #2b3832; }
.logout-form { margin-top: auto; }
.text-button { width: 100%; border: 0; color: #bfc9c4; background: transparent; text-align: left; padding: 10px 12px; cursor: pointer; }
.main { min-width: 0; padding: 28px clamp(18px, 4vw, 52px) 60px; }
.page-header { min-height: 64px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 26px; line-height: 1.25; }
h2 { margin-bottom: 0; font-size: 17px; }
.page-header p, .muted { color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 8px; }
.metric span { color: var(--muted); }
.metric strong { font-size: 26px; }
.section-block, .form-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 22px; }
.section-title { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.section-title a { color: var(--accent-dark); text-decoration: none; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.empty { color: var(--muted); text-align: center; padding: 34px; }
.preview { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: #eef1f0; color: var(--muted); font-size: 12px; }
.status.authorized, .status.success { background: #e4f5ed; color: #0d714e; }
.status.awaiting_code, .status.awaiting_password { background: #fff4dc; color: #8b5b08; }
.status.failed, .status.expired { background: #fae8ea; color: #a3212e; }
.status.paused { background: #eef1f0; color: #64706a; }
.actions { display: flex; gap: 8px; }
.primary-button, .small-button, .danger-button { border: 0; border-radius: 6px; cursor: pointer; font-weight: 600; }
.primary-button { background: var(--accent); color: #fff; padding: 10px 15px; min-height: 40px; }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { opacity: .45; cursor: not-allowed; }
.link-button { display: inline-flex; align-items: center; text-decoration: none; }
.small-button { background: #edf1ef; color: #26302c; padding: 7px 10px; }
.danger-button { background: #fae8ea; color: var(--danger); }
.notice, .error-box, .success-box { padding: 12px 14px; border-radius: 6px; margin-bottom: 18px; }
.notice { color: #725018; background: #fff4dc; border: 1px solid #f2dda8; }
.error-box { color: #9b1f2b; background: #fae8ea; border: 1px solid #efc6cb; }
.success-box { color: #0d6849; background: #e4f5ed; border: 1px solid #bfe5d5; }
.form-section { padding: 24px; }
.form-section.narrow { max-width: 660px; }
.stack-form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid #cbd3cf; border-radius: 6px; padding: 10px 11px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(20, 134, 95, .12); }
textarea { resize: vertical; line-height: 1.5; }
.form-hint { color: var(--muted); font-size: 12px; line-height: 1.55; margin-bottom: 0; }
.message-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 30px; }
.form-column { display: grid; align-content: start; gap: 16px; }
.schedule-panel { border-left: 1px solid var(--line); padding-left: 28px; }
#scheduleFields { display: grid; gap: 16px; }
#scheduleFields[hidden], #intervalField[hidden] { display: none; }
dialog { width: min(460px, calc(100vw - 28px)); border: 1px solid var(--line); border-radius: 8px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.22); }
dialog::backdrop { background: rgba(17, 25, 21, .55); }
dialog form { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.close-button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: #eef1f0; cursor: pointer; font-size: 22px; line-height: 1; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: 380px; padding: 12px 15px; color: #fff; background: #1d2723; border-radius: 7px; box-shadow: 0 10px 30px rgba(0,0,0,.22); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9b1f2b; }
.error-text { color: var(--danger); font-size: 12px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #e9eeeb; }
.login-panel { width: min(390px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 30px; box-shadow: 0 16px 45px rgba(29, 39, 35, .12); }
.login-brand { padding: 0 0 28px; }
.login-panel h1 { font-size: 22px; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .brand { padding-bottom: 12px; }
  nav { grid-template-columns: repeat(3, 1fr); }
  nav a { text-align: center; padding: 8px 5px; font-size: 13px; }
  .logout-form { display: none; }
  .main { padding: 22px 14px 42px; }
  .metrics { grid-template-columns: 1fr; }
  .message-grid { grid-template-columns: 1fr; }
  .schedule-panel { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: 22px; }
  .page-header { align-items: center; }
  h1 { font-size: 22px; }
}

