* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f3f1ea;
  color: #173b34;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }

.login-view {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 16% 18%, rgba(46, 139, 104, 0.52), transparent 38%),
    radial-gradient(circle at 86% 82%, rgba(13, 79, 120, 0.55), transparent 42%),
    linear-gradient(135deg, #0d3a33 0%, #0b2f4a 78%);
}

.login-view::before {
  content: '';
  position: absolute;
  width: 520px;
  height: 520px;
  right: -190px;
  top: -170px;
  border-radius: 50%;
  border: 1px solid rgba(232, 211, 164, 0.16);
  box-shadow: 0 0 0 70px rgba(255, 255, 255, 0.025), 0 0 0 140px rgba(255, 255, 255, 0.018);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 430px;
  padding: 44px 46px 40px;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: linear-gradient(180deg, #fffdf8 0%, #faf7f0 100%);
  box-shadow: 0 32px 90px rgba(3, 24, 33, 0.35), 0 2px 8px rgba(15, 59, 52, 0.08);
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 26px;
  right: 26px;
  height: 4px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, #2e8b68, #0d4f78 62%, #c79a4b);
}

.login-logo {
  position: relative;
  width: 108px;
  height: 108px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0%, #f2f7f1 62%, #e7f0e9 100%);
  box-shadow: inset 0 0 0 1px rgba(199, 154, 75, 0.32), 0 14px 30px rgba(13, 59, 52, 0.12);
}

.login-logo img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  display: block;
}

.login-brand { margin-top: 22px; text-align: center; }
.login-kicker { color: #8b9d93; font-size: 10px; letter-spacing: 2.4px; }
.login-card h1 { margin: 8px 0 2px; font-size: 26px; line-height: 1.3; letter-spacing: 1px; color: #123b34; }
.login-subtitle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #9a7027;
  font-size: 14px;
  letter-spacing: 6px;
}
.login-subtitle::before,
.login-subtitle::after { content: ''; width: 28px; height: 1px; background: #dcc79c; }
.login-card p { margin: 16px 0 26px; text-align: center; color: #89938d; font-size: 13px; }
.login-card label { display: block; margin: 14px 0 8px; font-size: 13px; color: #5b6b64; }

.login-card input,
.form-panel input,
.form-panel select,
.form-panel textarea,
.search,
.select,
.endpoint-box input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #dfe5de;
  border-radius: 10px;
  background: #fff;
  color: #173b34;
  outline: none;
}

.login-card input:focus,
.form-panel input:focus,
.form-panel select:focus,
.form-panel textarea:focus,
.search:focus,
.select:focus { border-color: #1e6b5a; box-shadow: 0 0 0 3px rgba(30, 107, 90, 0.1); }

button.primary,
button.ghost,
button.link {
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-weight: 600;
}

button.primary { background: linear-gradient(135deg, #1e6b5a, #0d4f78); color: #fff; }
button.primary:hover { background: linear-gradient(135deg, #175445, #0a3f62); transform: translateY(-1px); }
button.ghost { background: #fff; color: #3f6a61; border: 1px solid #d6e0d8; }
button.link { background: transparent; color: #1e6b5a; padding: 6px; }
button.small { padding: 8px 16px; font-size: 13px; }

.login-card button.primary {
  width: 100%;
  margin-top: 26px;
  padding: 14px;
  border-radius: 12px;
  letter-spacing: 4px;
  box-shadow: 0 12px 24px rgba(13, 79, 120, 0.22);
}
.error-text { margin-top: 14px; text-align: center; color: #b8524a; font-size: 13px; }

.app-view { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: none;
  padding: 28px 18px;
  background: linear-gradient(180deg, #0f3b34 0%, #0b2f4a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 30px; }
.brand-mark {
  width: 46px;
  height: 46px;
  flex: none;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(199, 154, 75, 0.28);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-name { font-size: 14px; font-weight: 600; line-height: 1.35; }
.brand-sub { margin-top: 3px; font-size: 10px; color: rgba(232, 211, 164, 0.58); letter-spacing: 1px; }

.nav-item {
  width: 100%;
  margin-bottom: 6px;
  padding: 13px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: rgba(255,255,255,0.68);
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.07); }
.nav-item.active { background: rgba(255,255,255,0.13); color: #fff; font-weight: 600; box-shadow: inset 3px 0 #c79a4b; }
.sidebar-foot { margin-top: auto; }
.sidebar-foot button { width: 100%; background: transparent; color: rgba(255,255,255,0.72); border-color: rgba(255,255,255,0.18); }

.main { flex: 1; padding: 28px 36px 60px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; }
.topbar-actions { display: flex; gap: 10px; }
.topbar h2 { margin: 0; font-size: 26px; }
.page-desc { margin-top: 6px; color: #8a908b; font-size: 13px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stat-card { padding: 24px; border-radius: 18px; background: #fffdf8; border: 1px solid #e7ded0; }
.stat-label { color: #8a908b; font-size: 13px; }
.stat-value { margin-top: 12px; font-size: 34px; font-weight: 600; color: #1e6b5a; }

.panel {
  margin-top: 22px;
  padding: 24px;
  border-radius: 18px;
  background: #fffdf8;
  border: 1px solid #e7ded0;
}
.panel h3 { margin: 0 0 18px; font-size: 17px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h3 { margin: 0 0 18px; }

.toolbar { display: flex; gap: 12px; margin-bottom: 18px; }
.toolbar .search { max-width: 360px; }
.toolbar .select { width: 160px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid #f0e9dc; white-space: nowrap; }
th { color: #8a908b; font-weight: 500; background: #faf7f0; }
tr.clickable:hover { background: #f7faf6; cursor: pointer; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; background: #edf4ef; color: #1e6b5a; font-size: 11px; }
.badge.warn { background: #fbf2df; color: #9a7027; }
.badge.danger { background: #fbeeec; color: #b8524a; }
.muted { color: #8a908b; font-size: 13px; }

.pager { margin-top: 16px; text-align: right; color: #8a908b; font-size: 13px; }
.pager button { margin-left: 8px; }

.form-panel { max-width: 960px; }
.form-section-title { margin: 0 0 20px; padding-left: 12px; border-left: 3px solid #c79a4b; font-size: 15px; font-weight: 600; color: #123b34; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
.form-grid label { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: #5b6b64; }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.checkbox { flex-direction: row; align-items: center; }
.form-grid label.checkbox input { width: auto; }
.form-actions { margin-top: 26px; display: flex; align-items: center; gap: 16px; }
.hint { color: #8a908b; font-size: 13px; }

.endpoint-box { display: flex; gap: 12px; margin: 20px 0; }
.notice-box { padding: 16px; border-radius: 12px; background: #fbf5e7; color: #8a6a2f; font-size: 13px; line-height: 1.8; }
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.check-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px; border: 1px solid #e7ded0; border-radius: 12px; background: #fffdf8; }
.check-name { font-size: 14px; font-weight: 600; color: #173b34; }
.check-detail { margin-top: 5px; font-size: 12px; line-height: 1.6; color: #8a908b; word-break: break-all; }
.check-status { flex: none; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.check-status.ok { background: #edf4ef; color: #1e6b5a; }
.check-status.warn { background: #fbf2df; color: #9a7027; }
code { background: rgba(0,0,0,0.05); padding: 2px 6px; border-radius: 4px; }

.modal { position: fixed; inset: 0; background: rgba(10,30,26,0.45); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-card { width: min(900px, 92vw); max-height: 82vh; display: flex; flex-direction: column; background: #fffdf8; border-radius: 18px; padding: 24px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; }
.modal-card pre { overflow: auto; padding: 18px; border-radius: 12px; background: #f5f2ea; font-size: 12px; line-height: 1.6; }
.modal-actions { display: flex; gap: 8px; }
.report-modal-card { width: min(1100px, 94vw); height: 88vh; }
.report-modules { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.report-module-btn { border: 1px solid #d6e0d8; background: #fff; color: #3f6a61; border-radius: 999px; padding: 6px 12px; font-size: 12px; }
.report-module-btn.active { background: #1e6b5a; color: #fff; border-color: #1e6b5a; }
.report-frame-wrap { flex: 1; margin-top: 12px; border: 1px solid #e7ded0; border-radius: 12px; overflow: hidden; background: #f5f2ea; }
.report-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.report-hint { margin-top: 10px; color: #8a6a2f; font-size: 12px; }

.user-modal-card { width: min(1040px, 94vw); overflow-y: auto; }
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-avatar { flex: none; width: 58px; height: 58px; border-radius: 50%; overflow: hidden; background: linear-gradient(135deg, #1e6b5a, #c79a4b); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; font-weight: 600; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-main { flex: 1; min-width: 0; }
.profile-name { font-size: 18px; font-weight: 600; color: #173b34; }
.profile-main .muted { margin-top: 5px; word-break: break-all; }
.profile-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.profile-stat { min-width: 86px; padding: 10px 14px; border: 1px solid #e7ded0; border-radius: 12px; background: #faf7f0; text-align: center; }
.profile-stat strong { display: block; font-size: 20px; color: #1e6b5a; }
.profile-stat span { display: block; margin-top: 4px; font-size: 12px; color: #8a908b; }
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.profile-item { padding: 12px 14px; border: 1px solid #e7ded0; border-radius: 12px; background: #faf7f0; }
.profile-label { color: #8a908b; font-size: 12px; }
.profile-value { margin-top: 6px; color: #173b34; font-size: 14px; word-break: break-all; }
.subsection { margin: 20px 0 10px; padding-left: 12px; border-left: 3px solid #c79a4b; font-size: 14px; font-weight: 600; color: #173b34; }
.user-modal-card .table-wrap { border: 1px solid #e7ded0; border-radius: 12px; }
.user-modal-card th, .user-modal-card td { white-space: normal; }
.empty-state { padding: 18px; color: #8a908b; font-size: 13px; }

.system-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0; }
.system-stat-grid .stat-card { padding: 18px; }
.stat-value.compact { margin-top: 8px; font-size: 22px; }
.stat-value.compact.time { font-size: 16px; }
.update-method { margin-top: 18px; padding-top: 18px; border-top: 1px dashed #e7ded0; }
.update-method .endpoint-box { margin: 14px 0 8px; }
.system-update-panel .subsection { margin-top: 22px; }
.table-wrap td.wrap { white-space: normal; word-break: break-all; min-width: 280px; }
#updatePackageFile { padding: 10px; }

button.link.danger { color: #b8524a; }

.password-modal-card { width: min(460px, 92vw); }
.password-modal-card .form-panel { max-width: none; margin: 18px 0 0; padding: 0; }
.password-modal-card .form-actions { margin-top: 20px; }

.toast { position: fixed; right: 28px; bottom: 28px; padding: 12px 20px; border-radius: 10px; background: #123b34; color: #fff; font-size: 13px; z-index: 30; }

@media (max-width: 900px) {
  .sidebar { width: 180px; }
  .main { padding: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .profile-head { flex-wrap: wrap; }
  .profile-stats { width: 100%; }
  .profile-grid { grid-template-columns: 1fr 1fr; }
}
