:root {
  --bg: #f4f5f1;
  --surface: #ffffff;
  --ink: #17201b;
  --muted: #6b756e;
  --line: #e2e6df;
  --green: #0d745a;
  --green-dark: #095b46;
  --mint: #d9f3e8;
  --amber: #b87512;
  --danger: #b23b3b;
  --shadow: 0 18px 50px rgba(23, 32, 27, .09);
  --radius: 16px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.6 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #edf0ea;
  color: var(--green-dark);
  font: 12px/1.4 Consolas, monospace;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-content: center;
  gap: 12px;
  justify-items: center;
  color: var(--muted);
  background: var(--bg);
}
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .15em;
}
.muted { color: var(--muted); }
.logo {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 16px;
  color: #eafff6;
  background: linear-gradient(145deg, #24aa82, #075944);
  box-shadow: 0 10px 28px rgba(2, 54, 39, .28);
  font-size: 24px;
  font-weight: 800;
}
.logo.small { width: 38px; height: 38px; border-radius: 11px; font-size: 17px; }

.login {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr);
}
.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 9vw;
  color: #effbf5;
  background:
    radial-gradient(circle at 12% 15%, rgba(55, 202, 151, .28), transparent 32%),
    radial-gradient(circle at 80% 85%, rgba(120, 179, 108, .2), transparent 34%),
    linear-gradient(145deg, #10251d, #0b3d30 58%, #082b23);
}
.login-brand .eyebrow { color: #74d7b4; margin-top: 36px; }
.login-brand h1 {
  max-width: 560px;
  margin: 0;
  font-size: clamp(34px, 4.4vw, 62px);
  line-height: 1.15;
  letter-spacing: -.04em;
}
.login-brand .muted { max-width: 460px; color: #a8c5b9; font-size: 15px; }
.brand-stats {
  display: flex;
  gap: 42px;
  margin-top: 54px;
  padding-top: 26px;
  border-top: 1px solid rgba(255, 255, 255, .13);
}
.brand-stats div { display: grid; gap: 2px; }
.brand-stats strong { font-size: 20px; }
.brand-stats span { color: #8fb8a8; font-size: 12px; }

.login-panel { display: grid; place-items: center; padding: 32px; }
.login-card {
  width: min(390px, 100%);
  padding: 38px;
  border: 1px solid rgba(23, 32, 27, .06);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-card h2 { margin: 0 0 4px; font-size: 28px; letter-spacing: -.03em; }
.login-card > .muted { margin: 0 0 26px; }
.login-card .field { margin-top: 16px; }
.hint { margin: 18px 0 0; color: #8a948d; text-align: center; font-size: 12px; }

.field { display: grid; gap: 7px; }
.field > span:first-child { color: #445048; font-size: 12px; font-weight: 650; }
.field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: #fbfcfa;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus {
  border-color: #58ad92;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(13, 116, 90, .1);
}
.field input:disabled { color: #657169; background: #f1f3ef; }
.field input.invalid { border-color: #d07a7a; background: #fffafa; }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 62px; }

.primary, .secondary, .ghost, .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 650;
  transition: background .15s, transform .1s, border-color .15s;
}
.primary { color: #fff; background: var(--green); box-shadow: 0 6px 16px rgba(13, 116, 90, .2); }
.primary:hover { background: var(--green-dark); }
.secondary { color: var(--green-dark); border-color: #bddbcf; background: #eff9f5; }
.secondary:hover { background: #e2f4ed; }
.ghost { color: #4f5b53; border-color: var(--line); background: #fff; }
.ghost:hover { border-color: #c8d0c9; background: #f8faf7; }
.danger { color: #fff; background: var(--danger); }
.danger:hover { background: #922d2d; }
.primary:active, .secondary:active, .ghost:active, .danger:active { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .55; transform: none !important; }
.block { width: 100%; height: 46px; margin-top: 24px; }
.mini {
  position: absolute;
  top: 5px;
  right: 5px;
  height: 32px;
  padding: 0 9px;
  border: 0;
  color: var(--green);
  background: transparent;
  font-size: 12px;
}

.form-error {
  margin: 14px 0 0;
  padding: 9px 12px;
  border: 1px solid #f0d2d2;
  border-radius: 8px;
  color: #9d3131;
  background: #fff5f5;
  font-size: 13px;
}
.form-note { margin: 16px 0 0; color: var(--muted); font-size: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid rgba(23, 32, 27, .07);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px);
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-row > div:last-child { display: grid; line-height: 1.25; }
.brand-row strong { font-size: 15px; }
.brand-row span { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #465149;
  background: #fbfcfa;
  font-size: 12px;
}
.user-chip i { width: 7px; height: 7px; border-radius: 50%; background: #20a77e; box-shadow: 0 0 0 3px #dff5ec; }

.container { max-width: 1240px; margin: 0 auto; padding: 38px 24px 64px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: clamp(30px, 4vw, 42px); letter-spacing: -.045em; }
.page-head .muted { margin: 6px 0 0; }
.page-head .primary { height: 44px; padding: 0 20px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  position: relative;
  overflow: hidden;
  padding: 18px 20px;
  border: 1px solid rgba(23, 32, 27, .07);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat::after {
  position: absolute;
  right: -20px;
  bottom: -34px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #e9efe9;
  content: "";
}
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 8px; font-size: clamp(23px, 2.8vw, 31px); letter-spacing: -.04em; }
.stat small { color: #9aa39c; font-size: 10px; }
.stat.accent { color: #f3fff9; border-color: transparent; background: linear-gradient(145deg, #106a53, #0a4638); }
.stat.accent span, .stat.accent small { color: #a8d9c8; }
.stat.accent::after { background: rgba(87, 205, 163, .14); }

.card {
  border: 1px solid rgba(23, 32, 27, .07);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(23, 32, 27, .035);
}
.list-card { overflow: hidden; }
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.list-head h2 { margin: 0; font-size: 17px; }
.list-head p { margin: 2px 0 0; font-size: 11px; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.filters input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfa;
  outline: none;
}
.filters input:focus { border-color: #58ad92; }
.filters input[type="search"] { width: 160px; }
.filters input[type="date"] { width: 140px; }
.filters .secondary, .filters .ghost { height: 36px; padding: 0 12px; font-size: 12px; }
.date-sep { color: #9ba49d; font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1080px; }
th, td { padding: 13px 16px; border-bottom: 1px solid #edf0eb; text-align: left; white-space: nowrap; }
th {
  color: #7b867e;
  background: #fafbf9;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
td { font-size: 13px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fbfcf9; }
tbody tr:last-child td { border-bottom: 0; }
.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.channel { font-weight: 650; }
.sub { display: block; margin-top: 1px; color: #98a29a; font-size: 10px; }
.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  color: #0c654f;
  background: #e7f6f0;
  font-size: 11px;
  font-weight: 650;
}
.rate { font-weight: 650; }
.rate.good { color: #0c7458; }
.rate.warn { color: #a96b0b; }
.rate.bad { color: #a53d3d; }
.actions-col { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.link-btn {
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  color: var(--green);
  background: transparent;
  font-size: 12px;
}
.link-btn:hover { background: #edf8f3; }
.link-btn.remove { color: #a34a4a; }
.link-btn.remove:hover { background: #fcf0f0; }
.empty { padding: 58px 20px; color: var(--muted); text-align: center; }
.empty strong { display: block; margin-bottom: 4px; color: #465149; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.pager label { display: flex; align-items: center; gap: 7px; }
.pager select {
  height: 30px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}
.pager-buttons { display: flex; align-items: center; gap: 10px; }
.pager .ghost { height: 30px; padding: 0 10px; font-size: 12px; }
#page-info { min-width: 60px; text-align: center; font-variant-numeric: tabular-nums; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 22, 17, .55);
  backdrop-filter: blur(4px);
}
.dialog {
  width: min(700px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: 19px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .25);
  animation: rise .18s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 24px 26px 0; }
.dialog-head h2, .confirm h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  color: #758078;
  background: #f1f3ef;
  font-size: 21px;
  line-height: 1;
}
.icon-btn:hover { background: #e8ebe5; }
#record-form { padding: 20px 26px 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid .span-2 { grid-column: span 2; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.confirm { width: min(400px, 100%); padding: 30px; text-align: center; }
.confirm .muted { margin: 7px 0 0; }
.confirm .dialog-actions { justify-content: center; }
.danger-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 50%;
  color: #a53333;
  background: #fbe8e8;
  font-size: 22px;
  font-weight: 800;
}

.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 80; display: grid; gap: 8px; }
.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 11px 15px;
  border-radius: 9px;
  color: #f3fff9;
  background: #173d31;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in .2s ease-out;
}
.toast.error { background: #8f3333; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; background: linear-gradient(160deg, #eef5ef, #f9faf7); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-head { align-items: flex-start; flex-direction: column; }
  .filters { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 14px; }
  .user-chip { display: none; }
  .container { padding: 26px 14px 44px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head .primary { width: 100%; }
  .stats { gap: 9px; }
  .stat { padding: 14px; }
  .stat strong { font-size: 23px; }
  .filters { width: 100%; }
  .filters input[type="search"], .filters input[type="date"] { width: calc(50% - 4px); }
  .date-sep { display: none; }
  .list-head { padding: 16px 14px; }
  .pager { align-items: flex-start; flex-direction: column; gap: 10px; padding: 12px 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .dialog-head { padding: 20px 18px 0; }
  #record-form { padding: 16px 18px 20px; }
  .login-card { padding: 28px 22px; }
}
