:root {
  --ink: #132238;
  --muted: #64748b;
  --line: #dfe6ee;
  --paper: #ffffff;
  --canvas: #f4f7fa;
  --navy: #122b45;
  --navy-2: #1b3b5b;
  --accent: #e56b3f;
  --success: #16845b;
  --danger: #b73d4a;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif; }
a { color: inherit; }
button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.auth-page {
  background:
    radial-gradient(circle at 18% 18%, rgba(229,107,63,.13), transparent 31%),
    radial-gradient(circle at 80% 76%, rgba(36,111,157,.14), transparent 34%),
    #edf2f6;
}
.auth-shell { min-height: 100vh; display: grid; place-content: center; gap: 18px; padding: 32px 18px; }
.auth-card { width: min(440px, calc(100vw - 36px)); background: rgba(255,255,255,.96); border: 1px solid rgba(19,34,56,.12); padding: 38px; box-shadow: 0 24px 70px rgba(18,43,69,.13); }
.install-card { width: min(560px, calc(100vw - 36px)); }
.brand-row { display: flex; align-items: center; gap: 12px; color: var(--navy); font-weight: 700; margin-bottom: 34px; }
.brand-mark { width: 52px; height: 52px; display: inline-grid; place-items: center; color: #fff; background: var(--navy); font: 800 17px/1 Georgia, serif; letter-spacing: .08em; }
.brand-mark.small { width: 40px; height: 40px; font-size: 13px; flex: 0 0 auto; }
.eyebrow { margin: 0 0 10px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .16em; }
.auth-card h1 { margin: 0 0 12px; font: 700 clamp(28px, 6vw, 38px)/1.15 Georgia, "Songti SC", serif; color: var(--navy); }
.auth-intro { margin: 0 0 26px; color: var(--muted); font-size: 14px; line-height: 1.75; }
.auth-intro code { font-size: 12px; background: #edf2f6; padding: 2px 5px; }
.auth-form { display: grid; gap: 17px; }
.auth-form label { display: grid; gap: 7px; color: #3b4b60; font-size: 13px; font-weight: 700; }
.auth-form input, .filter-form input, .filter-form select, .admin-form input, .admin-form select { width: 100%; border: 1px solid #cbd6e2; background: #fff; padding: 12px 13px; outline: 0; color: var(--ink); }
.auth-form input:focus, .filter-form input:focus, .filter-form select:focus, .admin-form input:focus, .admin-form select:focus { border-color: #527da4; box-shadow: 0 0 0 3px rgba(82,125,164,.12); }
.primary-button, .primary-link { border: 0; background: var(--navy); color: #fff; padding: 13px 18px; font-weight: 750; text-align: center; text-decoration: none; cursor: pointer; transition: .18s ease; }
.primary-button:hover, .primary-link:hover { background: var(--navy-2); }
.primary-link { display: block; margin-top: 18px; }
.notice { padding: 12px 14px; margin: 0 0 18px; font-size: 13px; line-height: 1.55; border-left: 3px solid; }
.notice.error { color: #812a35; background: #fff1f2; border-color: var(--danger); }
.notice.success { color: #126344; background: #ecfdf5; border-color: var(--success); }
.auth-foot { margin: 0; text-align: center; color: #718096; font-size: 12px; }

.dashboard-page { background: var(--canvas); }
.topbar { height: 72px; padding: 0 clamp(18px, 4vw, 54px); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.topbar-brand > span:last-child { display: grid; gap: 2px; }
.topbar-brand b { font-size: 15px; }
.topbar-brand small { color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 18px; font-size: 13px; }
.topbar-actions a { color: #41556d; text-decoration: none; font-weight: 650; }
.topbar-actions a:hover { color: var(--accent); }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; background: #eff4f8; color: #30455c; font-weight: 650; }
.user-chip i { width: 7px; height: 7px; border-radius: 50%; background: #2ea66f; box-shadow: 0 0 0 3px rgba(46,166,111,.12); }
.dashboard { width: min(1440px, 100%); margin: 0 auto; padding: clamp(26px, 4vw, 58px); }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 34px; }
.hero h1 { margin: 0 0 8px; font: 700 clamp(30px, 5vw, 48px)/1.1 Georgia, "Songti SC", serif; color: var(--navy); }
.hero p:not(.eyebrow) { margin: 0; color: var(--muted); }
.tool-search { width: min(360px, 100%); display: grid; gap: 7px; color: #526377; font-size: 12px; font-weight: 700; }
.tool-search input { border: 1px solid #cbd6e2; background: #fff; padding: 13px 14px; outline: 0; }
.tool-search input:focus { border-color: #527da4; }
.tool-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.tool-card { min-height: 245px; padding: 20px; display: flex; flex-direction: column; align-items: flex-start; text-align: left; border: 1px solid var(--line); background: var(--paper); cursor: pointer; position: relative; overflow: hidden; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.tool-card::after { content: ""; position: absolute; inset: auto -28px -44px auto; width: 110px; height: 110px; border: 18px solid var(--card-accent, #527da4); border-radius: 50%; opacity: .08; }
.tool-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--card-accent, #527da4) 45%, #dfe6ee); box-shadow: 0 15px 35px rgba(18,43,69,.08); }
.tool-card-top { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 27px; }
.tool-index { color: var(--card-accent, #527da4); font: 700 14px/1 Georgia, serif; }
.tool-category { color: #708195; font-size: 10px; letter-spacing: .08em; }
.tool-card strong { font-size: 20px; color: var(--navy); margin-bottom: 5px; }
.tool-short { color: var(--card-accent, #527da4); font-size: 12px; font-weight: 700; margin-bottom: 13px; }
.tool-description { color: var(--muted); font-size: 13px; line-height: 1.65; }
.tool-open { margin-top: auto; padding-top: 20px; color: #354b64; font-size: 12px; font-weight: 750; }
.tool-open b { color: var(--card-accent, #527da4); font-size: 16px; margin-left: 5px; }
.accent-blue { --card-accent: #2878b5; }.accent-green { --card-accent: #238a62; }.accent-amber { --card-accent: #b67b1d; }.accent-violet { --card-accent: #7058b4; }.accent-cyan { --card-accent: #148b9a; }.accent-orange { --card-accent: #d26837; }.accent-indigo { --card-accent: #4c62b0; }.accent-rose { --card-accent: #b54d68; }.accent-sky { --card-accent: #3485b6; }.accent-emerald { --card-accent: #16856c; }.accent-fuchsia { --card-accent: #a84a98; }.accent-teal { --card-accent: #167b80; }.accent-slate { --card-accent: #5f7083; }
.tool-empty { padding: 60px 20px; text-align: center; background: #fff; border: 1px dashed #cad5df; color: var(--muted); }

.tool-is-open { overflow: hidden; }
.tool-is-open .dashboard { max-width: none; padding: 0; }
.tool-workspace { height: calc(100vh - 72px); background: #fff; }
.workspace-bar { min-height: 74px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px; padding: 11px clamp(16px, 3vw, 36px); border-bottom: 1px solid var(--line); background: #f8fafc; }
.back-button { border: 0; background: transparent; color: #40566e; padding: 9px 0; cursor: pointer; font-weight: 700; }
.workspace-title { min-width: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; }
.workspace-title > span { grid-row: 1 / 3; color: var(--accent); font-size: 10px; font-weight: 800; writing-mode: vertical-rl; letter-spacing: .06em; }
.workspace-title strong { color: var(--navy); font-size: 17px; }
.workspace-title small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standalone-link { color: #40566e; font-size: 12px; font-weight: 700; text-decoration: none; }
.tool-workspace iframe { width: 100%; height: calc(100% - 74px); border: 0; background: #fff; display: block; }

.admin-shell { width: min(1400px, calc(100% - 36px)); margin: 30px auto 60px; }
.admin-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.admin-heading h1 { margin: 0; color: var(--navy); font: 700 34px/1.2 Georgia, "Songti SC", serif; }
.admin-heading p { margin: 7px 0 0; color: var(--muted); }
.admin-heading nav { display: flex; gap: 14px; }
.admin-heading nav a { color: #40566e; font-size: 13px; font-weight: 700; text-decoration: none; }
.admin-panel { background: #fff; border: 1px solid var(--line); padding: 22px; margin-bottom: 20px; }
.admin-panel h2 { margin: 0 0 18px; font-size: 18px; color: var(--navy); }
.admin-form, .filter-form { display: grid; grid-template-columns: repeat(5, minmax(120px,1fr)); gap: 12px; align-items: end; }
.admin-form label, .filter-form label { display: grid; gap: 6px; color: #53657a; font-size: 12px; font-weight: 700; }
.admin-form button, .filter-form button, .table-action { min-height: 42px; border: 0; padding: 10px 13px; cursor: pointer; background: var(--navy); color: #fff; font-weight: 700; }
.table-wrap { overflow: auto; border: 1px solid var(--line); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.admin-table th, .admin-table td { padding: 12px; border-bottom: 1px solid #e7edf3; text-align: left; white-space: nowrap; vertical-align: middle; }
.admin-table th { background: #f4f7fa; color: #526377; font-size: 11px; letter-spacing: .04em; position: sticky; top: 0; z-index: 1; }
.admin-table td.details { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-flex; padding: 4px 8px; font-size: 11px; font-weight: 750; background: #edf2f6; color: #496078; }
.badge.ok { background: #e9f8f1; color: #16714e; }.badge.bad { background: #fff0f1; color: #9f3541; }.badge.admin { background: #fff3e8; color: #a95625; }
.inline-actions { display: flex; gap: 7px; align-items: center; }
.inline-actions form { display: flex; gap: 6px; margin: 0; }
.inline-actions input { width: 130px; border: 1px solid #ccd7e2; padding: 8px; }
.table-action { min-height: auto; padding: 8px 10px; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; white-space: nowrap; }
.table-action.danger { background: #a83d49; }.table-action.muted { background: #627286; }
.table-action.permission { background: #167b80; }
.primary-link.compact { display: inline-block; margin-top: 0; }
.permission-shell { max-width: 1100px; }
.permission-mode { display: grid; gap: 10px; }
.permission-mode h2 { margin-bottom: 6px; }
.mode-option { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--line); cursor: pointer; }
.mode-option input { margin-top: 4px; }
.mode-option span { display: grid; gap: 4px; }
.mode-option small, .permission-item small { color: var(--muted); line-height: 1.5; }
.permission-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.permission-heading h2 { margin: 0; }
.small-control { border: 1px solid #cad5df; background: #fff; color: #40566e; padding: 7px 11px; margin-left: 6px; cursor: pointer; }
.permission-groups { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-top: 18px; transition: opacity .15s ease; }
.permission-groups.disabled { opacity: .42; }
.permission-group { border: 1px solid var(--line); padding: 12px; min-width: 0; }
.permission-group legend { color: var(--navy); font-size: 13px; font-weight: 800; padding: 0 7px; }
.permission-item { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 10px 8px; cursor: pointer; }
.permission-item + .permission-item { border-top: 1px solid #edf1f5; }
.permission-item input { margin-top: 4px; }
.permission-item span { display: grid; gap: 3px; }
.permission-item b { font-size: 13px; }
.permission-save { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 18px; background: #fff; border: 1px solid var(--line); box-shadow: 0 -12px 30px rgba(18,43,69,.08); padding: 15px 18px; }
.permission-save span { color: var(--muted); font-size: 12px; }

@media (max-width: 1120px) { .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .admin-form, .filter-form { grid-template-columns: repeat(3, minmax(140px,1fr)); } }
@media (max-width: 760px) {
  .topbar { height: auto; min-height: 68px; padding: 10px 16px; }
  .topbar-brand small { display: none; }
  .topbar-actions { gap: 10px; }
  .topbar-actions a { display: none; }
  .dashboard { padding: 26px 16px; }
  .hero { align-items: stretch; flex-direction: column; }
  .tool-grid { grid-template-columns: 1fr; }
  .tool-card { min-height: 215px; }
  .tool-workspace { height: calc(100vh - 68px); }
  .workspace-bar { min-height: 96px; grid-template-columns: 1fr auto; gap: 6px 14px; }
  .workspace-title { grid-column: 1 / -1; grid-row: 2; }
  .tool-workspace iframe { height: calc(100% - 96px); }
  .auth-card { padding: 28px 22px; }
  .admin-heading { align-items: flex-start; flex-direction: column; }
  .admin-form, .filter-form { grid-template-columns: 1fr; }
  .permission-groups { grid-template-columns: 1fr; }
  .permission-save { align-items: stretch; flex-direction: column; }
}
