:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #14213d;
  background: #f3f6fb;
  font-synthesis: none;
  --blue: #176ff2;
  --blue-dark: #0f5fd4;
  --blue-soft: #eaf2ff;
  --ink: #14213d;
  --muted: #6c7890;
  --line: #dfe6f1;
  --card: #ffffff;
  --soft: #f7f9fc;
  --green: #1a9a6c;
  --orange: #b56b12;
  --danger: #d64545;
  --shadow: 0 18px 52px rgba(28, 52, 92, .09);
  --shadow-strong: 0 32px 90px rgba(24, 48, 90, .16);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #f3f6fb; }
body { margin: 0; min-height: 100vh; background: #f3f6fb; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
[hidden], .hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 24px;
  background:
    radial-gradient(circle at 12% 12%, rgba(42, 125, 247, .15), transparent 34%),
    radial-gradient(circle at 88% 86%, rgba(92, 113, 246, .13), transparent 36%),
    linear-gradient(145deg, #f8fbff 0%, #eef3fb 100%);
}

.login-card {
  width: min(580px, 100%);
  padding: 56px;
  border: 1px solid rgba(206, 218, 235, .92);
  border-radius: 30px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow-strong);
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--blue), #536dfe);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(23, 111, 242, .28);
}

.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 15px; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 12px; font-weight: 850; letter-spacing: 1.7px; }
.login-card .eyebrow { margin-top: 24px; }
.login-card h1 { margin: 0 0 12px; font-size: 38px; line-height: 1.15; letter-spacing: -1px; }
.login-card > .muted { margin-bottom: 32px; font-size: 15px; line-height: 1.8; }
.login-card label { display: grid; gap: 10px; color: #263956; font-size: 14px; font-weight: 750; }
.login-card input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid #d7e0ed;
  border-radius: 13px;
  outline: none;
}
.login-card input:focus { border-color: #6ea5f8; box-shadow: 0 0 0 4px rgba(23, 111, 242, .1); }
.form-message { min-height: 22px; margin: 14px 0 0; color: var(--danger); font-size: 13px; }

.button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid #d8e1ee;
  border-radius: 12px;
  background: #fff;
  color: #263956;
  font-weight: 720;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.button:hover { border-color: #aebfda; background: #f9fbff; transform: translateY(-1px); }
.button.primary { border-color: var(--blue); background: var(--blue); color: #fff; box-shadow: 0 10px 24px rgba(23, 111, 242, .22); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { background: #edf4ff; border-color: #d7e6ff; color: #1763ca; }
.button.ghost { background: transparent; }
.button.full { width: 100%; margin-top: 18px; }
.button.compact { min-height: 36px; padding: 0 12px; border-radius: 9px; font-size: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
}
.brand { display: flex; align-items: center; gap: 13px; padding: 0 8px 30px; }
.brand div { display: grid; gap: 3px; }
.brand strong { font-size: 16px; }
.brand small { color: #8390a4; font-size: 11px; }
.sidebar nav { display: grid; gap: 7px; }
.nav-item {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 15px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: #64728a;
  text-align: left;
}
.nav-item span { width: 21px; text-align: center; color: #8290a8; }
.nav-item:hover { background: #f4f7fc; color: var(--ink); }
.nav-item.is-active { background: var(--blue-soft); color: var(--blue); font-weight: 780; }
.nav-item.is-active span { color: var(--blue); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 11px; padding: 18px 10px 4px; border-top: 1px solid var(--line); }
.sidebar-foot div { display: grid; gap: 3px; }
.sidebar-foot b { font-size: 12px; }
.sidebar-foot small { color: #8995a7; font-size: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #aeb7c6; box-shadow: 0 0 0 4px rgba(174, 183, 198, .15); }
.status-dot.is-online { background: #24b883; box-shadow: 0 0 0 4px rgba(36, 184, 131, .14); }

.main { width: min(1560px, 100%); margin: 0 auto; padding: 44px 54px 80px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.topbar h1 { margin: 0 0 7px; font-size: 34px; letter-spacing: -.7px; }
.topbar p { margin-bottom: 0; }
.top-actions, .inline-actions, .toolbar, .form-footer { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }

.view { display: none; }
.view.is-active { display: block; }
.hero {
  min-height: 190px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 40px 42px;
  border-radius: 25px;
  background: linear-gradient(128deg, #1769df 0%, #558cf4 100%);
  color: #fff;
  box-shadow: 0 24px 56px rgba(23, 105, 223, .2);
}
.hero h2 { margin: 14px 0 10px; font-size: 31px; }
.hero p { max-width: 740px; margin: 0; color: #e8f0ff; font-size: 14px; line-height: 1.75; }
.hero-label { display: inline-flex; padding: 6px 10px; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; background: rgba(255,255,255,.1); font-size: 11px; font-weight: 750; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin: 22px 0; }
.metric { min-height: 146px; display: flex; flex-direction: column; padding: 24px; border: 1px solid var(--line); border-radius: 19px; background: var(--card); box-shadow: var(--shadow); }
.metric span { color: #6f7e96; font-size: 12px; }
.metric strong { margin: 12px 0 7px; font-size: 31px; line-height: 1; }
.metric small { margin-top: auto; color: #8b97a9; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(360px, .88fr); gap: 22px; }

.panel { padding: 28px; border: 1px solid var(--line); border-radius: 21px; background: var(--card); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 20px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 22px; }
.panel-heading h2 { margin: 0 0 6px; font-size: 21px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.section-intro { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 22px; padding: 27px 30px; border: 1px solid #d5e4fb; border-radius: 20px; background: linear-gradient(135deg, #f4f8ff, #eef5ff); }
.section-intro h2 { margin: 9px 0 7px; font-size: 27px; }
.section-intro p { margin: 0; color: #667792; line-height: 1.65; }
.tag { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; background: #eaf2ff; color: #3371c7; font-size: 11px; }
.count-chip { padding: 7px 11px; border-radius: 999px; background: #edf4ff; color: #2368c4; font-size: 12px; font-weight: 750; }
.toolbar { justify-content: flex-end; margin-bottom: 18px; }
.search { min-width: 310px; flex: 1; position: relative; }
.search span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #8491a7; }
.search input { padding-left: 38px !important; }

.stack { display: grid; gap: 20px; }
.field-grid { display: grid; gap: 18px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }
form label, .dialog-form label, .panel > label { display: grid; gap: 8px; color: #30425e; font-size: 13px; font-weight: 720; }
input, textarea, select {
  width: 100%;
  border: 1px solid #d8e2ef;
  border-radius: 12px;
  background: #fff;
  color: #172943;
  outline: none;
}
input, select { height: 45px; padding: 0 13px; }
textarea { padding: 13px; resize: vertical; line-height: 1.65; }
input:focus, textarea:focus, select:focus { border-color: #78aaf5; box-shadow: 0 0 0 4px rgba(23, 111, 242, .08); }
.inline-status { display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #718097; font-size: 12px; }
.form-footer { justify-content: space-between; padding-top: 4px; }

.check { display: inline-flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 8px !important; font-weight: 600 !important; }
.check input { width: 16px; height: 16px; margin: 0; }
.switch { display: inline-flex !important; grid-template-columns: auto auto auto; align-items: center; gap: 10px !important; }
.switch input, .toggle-card input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span, .toggle-card > span { position: relative; width: 44px; height: 25px; border-radius: 999px; background: #cbd5e4; transition: .2s; }
.switch > span::after, .toggle-card > span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.18); transition: .2s; }
.switch input:checked + span, .toggle-card input:checked + span { background: var(--blue); }
.switch input:checked + span::after, .toggle-card input:checked + span::after { transform: translateX(19px); }
.toggle-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.toggle-card { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 14px !important; padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: #fbfcff; }
.toggle-card div { display: grid; gap: 4px; }
.toggle-card small { color: #7a879b; font-weight: 500; }

.disclosure { border: 1px solid var(--line); border-radius: 16px; background: #fbfcff; }
.disclosure summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 20px; cursor: pointer; list-style: none; font-weight: 760; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary > span { color: var(--blue); font-size: 12px; }
.disclosure-body { display: grid; gap: 18px; padding: 0 20px 20px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 15px; }
table { width: 100%; min-width: 780px; border-collapse: collapse; }
th, td { padding: 16px 18px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; line-height: 1.55; }
th { background: #f5f8fc; color: #69778e; font-size: 12px; font-weight: 750; }
tbody tr:hover { background: #fbfdff; }
tr:last-child td { border-bottom: 0; }
.empty-cell { padding: 42px 18px; color: #8995a8; text-align: center; }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.status-badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; background: #e8f7f1; color: #19795c; font-size: 11px; font-weight: 720; }
.status-badge.warn { background: #fff3df; color: #a56517; }
.status-badge.off, .status-badge.danger { background: #fff0f0; color: #c34444; }
.permission-list, .tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.tabs { display: flex; gap: 7px; margin-bottom: 20px; padding: 5px; border-radius: 13px; background: #f2f5fa; }
.tab { min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: #69788f; font-weight: 700; }
.tab.is-active { background: #fff; color: var(--blue); box-shadow: 0 4px 12px rgba(37, 61, 101, .08); }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.secret-box { padding: 14px; border: 1px solid #f0d7b1; border-radius: 12px; background: #fff7e8; color: #875516; }
.notice { padding: 14px 16px; border: 1px solid #b9d5ff; border-radius: 13px; background: #edf5ff; color: #235d9e; font-size: 13px; line-height: 1.6; }
.notice.error { border-color: #f1c5c5; background: #fff1f1; color: #a43737; }
.empty { padding: 34px 20px; border: 1px dashed #cdd9e9; border-radius: 14px; color: #8793a5; text-align: center; }
.task-list { display: grid; gap: 9px; }
.task-list > div:not(.empty) { padding: 14px; border-radius: 12px; background: var(--soft); }
.status-list { display: grid; gap: 0; margin: 0; }
.status-list > div { display: flex; justify-content: space-between; gap: 24px; padding: 14px 0; border-bottom: 1px solid #edf1f6; }
.status-list > div:last-child { border-bottom: 0; }
.status-list dt { color: #718097; }
.status-list dd { margin: 0; font-weight: 750; text-align: right; }

.dialog-form { width: min(760px, calc(100vw - 36px)); padding: 0; border: 0; border-radius: 22px; box-shadow: var(--shadow-strong); }
.dialog-form::backdrop { background: rgba(14, 30, 55, .42); backdrop-filter: blur(4px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 24px 26px 18px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 23px; }
.dialog-form > .field-grid, .dialog-form > label, .dialog-form > .permission-grid, .dialog-form > .tabs, .dialog-form > .secret-box, .dialog-form > .form-message { margin-left: 26px; margin-right: 26px; }
.dialog-form > .field-grid, .dialog-form > label, .dialog-form > .permission-grid, .dialog-form > .secret-box { margin-top: 18px; }
.dialog-form > .tabs { margin-top: 18px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding: 18px 26px 24px; border-top: 1px solid var(--line); }
.icon-button { width: 40px; height: 40px; border: 0; border-radius: 11px; background: #f1f4f8; color: #6d7a90; font-size: 22px; }
.upload-button { display: inline-flex !important; place-items: center; min-height: 44px; padding: 0 18px; border: 1px solid #d8e1ee; border-radius: 12px; background: #fff; color: #263956; cursor: pointer; }
.upload-button input { display: none; }
.toast { position: fixed; right: 28px; bottom: 28px; z-index: 30; max-width: 420px; padding: 14px 18px; border-radius: 13px; background: #14213d; color: #fff; box-shadow: var(--shadow-strong); }
.toast.danger { background: #b93636; }
.danger { color: var(--danger); }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 92px minmax(0, 1fr); }
  .sidebar { padding: 24px 13px; }
  .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .brand div, .sidebar-foot div { display: none; }
  .nav-item { justify-content: center; padding: 0; font-size: 0; }
  .nav-item span { width: auto; font-size: 17px; }
  .sidebar-foot { justify-content: center; }
  .main { padding: 38px 34px 70px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .field-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .login-card { padding: 36px 26px; border-radius: 24px; }
  .login-card h1 { font-size: 31px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; overflow-x: auto; }
  .brand, .sidebar-foot { display: none; }
  .sidebar nav { display: flex; min-width: max-content; }
  .nav-item { width: auto; min-width: 86px; padding: 0 12px; font-size: 12px; }
  .nav-item span { display: none; }
  .main { padding: 25px 15px 60px; }
  .topbar, .section-intro, .hero { display: grid; }
  .topbar h1 { font-size: 29px; }
  .top-actions { justify-content: flex-start; }
  .hero { min-height: 0; padding: 27px; }
  .metric-grid, .field-grid.two, .field-grid.three, .toggle-grid, .permission-grid { grid-template-columns: 1fr; }
  .panel { padding: 21px; }
  .search { min-width: 100%; }
  .dialog-form > .field-grid, .dialog-form > label, .dialog-form > .permission-grid, .dialog-form > .tabs, .dialog-form > .secret-box, .dialog-form > .form-message { margin-left: 18px; margin-right: 18px; }
}
