:root {
  --bg: #eef7ff;
  --surface: #ffffff;
  --surface-2: #e6f3ff;
  --ink: #102d44;
  --muted: #587187;
  --line: #d5e7f4;
  --primary: #1b74b7;
  --primary-deep: #14649c;
  --sun: #f0932b;
  --danger: #c44a32;
  --grad: linear-gradient(112deg, #2d95d8, #74c4ef 70%, #ffc078 150%);
  --shadow: 0 16px 36px -22px rgba(18, 68, 108, 0.38);
  --radius: 18px;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; color: inherit; }
code, pre, .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
code { background: var(--surface-2); border-radius: 5px; padding: 1px 5px; font-size: 11.5px; }

.ambient {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(700px 420px at 8% -10%, rgba(126, 198, 238, 0.48), transparent 64%),
    radial-gradient(620px 380px at 96% 0%, rgba(255, 196, 120, 0.3), transparent 62%),
    linear-gradient(180deg, #e9f5ff, #f6fbff 46%, #eef7ff);
}

 
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 26px 24px;
  box-shadow: var(--shadow);
}
.gate-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.gate-brand img { width: 44px; height: 44px; border-radius: 50%; }
.gate-brand b { display: block; font-size: 19px; letter-spacing: 0.06em; }
.gate-brand span { font-size: 10.5px; color: var(--muted); letter-spacing: 0.08em; }
.gate-card h1 { margin: 0 0 6px; font-size: 24px; }
.gate-note { margin: 0 0 16px; font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.gate-err {
  margin: 10px 0 0; padding: 8px 10px; border-radius: 10px;
  background: rgba(196, 74, 50, 0.1); color: var(--danger); font-size: 12px;
}
.gate-back { display: inline-block; margin-top: 14px; font-size: 12px; color: var(--primary-deep); }

 
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: #26485f; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7fcff;
  padding: 10px 12px;
  font-size: 13.5px;
  outline: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field textarea { resize: vertical; min-height: 76px; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 127, 196, 0.14);
  background: #fff;
}
.field input::placeholder, .field textarea::placeholder { color: #8ba6ba; }

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; align-self: end; padding-bottom: 9px; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .span2 { grid-column: span 2; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

 
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 11px;
  padding: 10px 16px; font-size: 13px; font-weight: 700;
  transition: transform 0.14s ease, filter 0.14s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-block { width: 100%; }
.btn.small { padding: 7px 11px; font-size: 11.5px; border-radius: 9px; }
.btn-solid { background: var(--grad); color: #fff; box-shadow: 0 10px 22px -14px rgba(31, 127, 196, 0.7); }
.btn-mint { background: var(--primary); color: #fff; }
.btn-ghost { background: var(--surface); border-color: #b9d9ee; color: var(--primary-deep); }
.btn-danger { background: rgba(196, 74, 50, 0.09); color: var(--danger); border-color: rgba(196, 74, 50, 0.24); }
.link-btn { border: 0; background: transparent; color: var(--primary-deep); font-size: 11.5px; font-weight: 700; padding: 2px; }

 
.console { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  padding: 18px 14px;
  background: rgba(255, 255, 255, 0.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 14px;
  z-index: 30;
}
.side-brand { display: flex; align-items: center; gap: 9px; padding: 0 6px; }
.side-brand img { width: 36px; height: 36px; border-radius: 50%; }
.side-brand b { display: block; font-size: 16px; }
.side-brand span { font-size: 9.5px; letter-spacing: 0.1em; color: var(--muted); }
.side-nav { display: grid; gap: 3px; }
.nav-btn {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: #47657a;
}
.nav-btn:hover { background: rgba(31, 127, 196, 0.07); }
.nav-btn.is-on { background: var(--surface-2); color: var(--primary-deep); }
.side-foot { margin-top: auto; display: grid; gap: 7px; padding: 0 6px; }
.side-user b { display: block; font-size: 12.5px; }
.side-user span { font-size: 10.5px; color: var(--muted); word-break: break-all; }
.side-link { border: 0; background: transparent; text-align: left; padding: 0; font-size: 11.5px; color: var(--primary-deep); }

.console-main { padding: 22px 26px 60px; min-width: 0; }
.console-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.kicker { font-size: 10.5px; font-weight: 700; letter-spacing: 0.16em; color: var(--primary); }
.console-head h1 { margin: 4px 0 2px; font-size: 26px; }
.console-head p { margin: 0; font-size: 12px; color: var(--muted); }
.head-actions { display: flex; align-items: center; gap: 8px; }
.live { font-size: 10px; letter-spacing: 0.1em; color: var(--primary-deep); background: var(--surface-2); padding: 4px 9px; border-radius: 999px; font-weight: 700; }
.side-toggle { display: none; }

.panel { display: none; animation: panelIn 0.24s ease both; }
.panel.is-on { display: block; }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

 
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: 0 10px 24px -22px rgba(18, 68, 108, 0.5);
  display: flex; flex-direction: column; gap: 2px; justify-content: center;
}
.stat span { font-size: 11px; color: var(--muted); order: 2; }
.stat b { font-size: 24px; color: var(--primary-deep); line-height: 1.2; order: 1; }
.stat b.small-value { font-size: 18px; }
.c-lime { color: #b9680d !important; }
.c-coral { color: var(--danger) !important; }
.c-mint { color: #147a59 !important; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.block {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 17px; box-shadow: 0 10px 26px -24px rgba(18, 68, 108, 0.5);
  margin-bottom: 12px;
}
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.block-head h2, .block h2 { margin: 0; font-size: 15px; }
.hint { font-size: 11px; color: var(--muted); line-height: 1.6; }
.form-note { font-size: 12px; color: var(--muted); font-weight: 600; padding-top: 4px; }
.pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 2px 2px; }
.pager .btn { min-width: 64px; }
.pager-info { font-size: 12px; color: var(--muted); }
.pager-total { font-size: 12px; color: var(--muted); margin-left: auto; }
.pager-host:empty { display: none; }

.matomo-mini .mini-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mini-cell { background: #f4faff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.mini-cell b { display: block; font-size: 18px; color: var(--primary-deep); }
.mini-cell span { font-size: 10.5px; color: var(--muted); }

 
.list { display: grid; gap: 8px; }
.item {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px 12px;
  background: #fbfdff;
}
.item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.item-title { font-size: 13px; font-weight: 700; min-width: 0; }
.item-meta { font-size: 11.5px; color: var(--muted); white-space: pre-line; margin-top: 4px; line-height: 1.55; }
.item-actions { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.item-actions .field { flex: 1; min-width: 150px; }
.item-actions .btn { flex: none; }
.attach { display: inline-block; margin-top: 6px; font-size: 11.5px; color: var(--primary-deep); text-decoration: underline; text-underline-offset: 2px; }
.empty { padding: 18px; text-align: center; color: var(--muted); font-size: 12px; white-space: pre-line; border: 1px dashed #b9d9ee; border-radius: 12px; }

.pill { flex: none; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.pill.pending { background: rgba(255, 157, 61, 0.18); color: #a8631a; }
.pill.approved, .pill.active, .pill.published, .pill.granted { background: rgba(31, 150, 110, 0.14); color: #147a59; }
.pill.rejected, .pill.disabled, .pill.closed, .pill.rejected { background: rgba(120, 140, 155, 0.14); color: #5d7486; }
.pill.open { background: rgba(31, 127, 196, 0.13); color: var(--primary-deep); }
.pill.processing { background: rgba(255, 157, 61, 0.18); color: #a8631a; }
.pill.draft, .pill.used { background: rgba(120, 140, 155, 0.14); color: #5d7486; }

 
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 11.5px;
}
.chip.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }

 
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 26px -24px rgba(18, 68, 108, 0.5); }
table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 760px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #f4faff; font-size: 11px; color: var(--muted); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.mono { font-size: 11px; color: #47657a; }

.code-block {
  background: #0f2f47;
  color: #dbeefa;
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 11.5px;
  line-height: 1.7;
  overflow-x: auto;
}

 
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  z-index: 80; max-width: min(86vw, 460px);
  padding: 10px 16px; border-radius: 11px;
  background: rgba(16, 45, 68, 0.94); color: #f2f9ff;
  font-size: 12.5px; opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: rgba(150, 44, 28, 0.95); }

 
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(9, 30, 45, 0.45);
}
.modal-box {
  width: min(680px, 100%); max-height: 88vh; overflow: auto;
  background: #fff; border-radius: 16px; padding: 18px;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.5);
}
.modal-box h2 { font-size: 16px; margin: 0 0 12px; }
.perm-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 4px 0; }
.perm-row .check { display: flex; align-items: center; gap: 6px; font-size: 12px; }

 
@media (max-width: 1080px) {
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .console { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 236px; height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 18px 0 40px -30px rgba(18, 68, 108, 0.6);
    background: var(--surface);
  }
  .sidebar.is-open { transform: none; }
  .side-toggle { display: inline-flex; }
  .console-main { padding: 16px 14px 40px; }
  .console-head h1 { font-size: 22px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .matomo-mini .mini-grid { grid-template-columns: repeat(2, 1fr); }
  .item-actions .field { min-width: 100%; }
  .head-actions { flex: none; }
}
