:root {
  --nf-ink: #17212b;
  --nf-muted: #687780;
  --nf-teal: #18a996;
  --nf-cyan: #149fbd;
  --nf-green: #22996d;
  --nf-coral: #e86571;
  --nf-violet: #7559b8;
  --nf-line: rgba(255, 255, 255, 0.72);
}

html { color-scheme: light; }
body { min-height: 100%; letter-spacing: 0; }
body::before { background: rgba(9, 14, 20, 0.26); }
button, input, select { letter-spacing: 0; }
[hidden] { display: none !important; }
.spin { animation: nf-spin .8s linear infinite; }
@keyframes nf-spin { to { transform: rotate(360deg); } }

.qf-wallpaper-scrim {
  background: linear-gradient(110deg, rgba(5, 11, 17, .42), rgba(16, 25, 31, .18) 48%, rgba(5, 11, 17, .36));
}

.nf-login {
  width: min(460px, 100%);
  padding: 30px;
  border-radius: 24px;
}
.nf-login .login-title { margin: 10px 0 4px; }
.nf-login .login-sub { margin-bottom: 24px; }
.qf-brand-photo { overflow: hidden; padding: 0; }
.qf-brand-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nf-login .login-head { width: 70px; height: 70px; margin: 0 auto; border-radius: 50%; }
.verify-row { display: grid; grid-template-columns: minmax(0, 1fr) 142px; gap: 10px; align-items: stretch; }
.captcha-box {
  min-width: 0;
  height: 46px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #fff;
  border-radius: 14px;
  background: rgba(255,255,255,.72);
  color: var(--nf-muted);
  cursor: pointer;
}
.captcha-box svg { display: block; width: 100%; height: 100%; }
.captcha-box.verified { color: var(--nf-green); font-weight: 700; cursor: default; }
.verify-button { width: 142px; padding: 0 10px; font-size: 13px; }
.field-hint { margin-top: 6px; color: var(--nf-muted); font-size: 12px; line-height: 1.6; }
.login-submit { width: 100%; }

.nf-shell { grid-template-columns: 258px minmax(0, 1fr); gap: 18px; max-width: 1800px; margin: 0 auto; }
.nf-sidebar { position: sticky; top: 20px; height: calc(100dvh - 40px); border-radius: 22px; overflow: hidden; }
.nf-brand { padding: 3px 2px 12px; }
.nf-brand .brand-logo { width: 46px; height: 46px; flex: none; }
.nf-brand .icon-button { margin-left: auto; }
.nf-sidebar .nav-item {
  width: 100%;
  border: 0;
  text-align: left;
  font: inherit;
  letter-spacing: 0;
}
.nf-sidebar .nav-item i { width: 19px; font-size: 18px; text-align: center; }
.nf-sidebar .nav-item.active::after { content: ""; width: 6px; height: 6px; margin-left: auto; border-radius: 50%; background: var(--nf-teal); box-shadow: 0 0 12px rgba(24,169,150,.7); }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
.api-state-line { display: flex; align-items: center; gap: 8px; padding: 11px 12px; color: var(--nf-muted); font-size: 12px; background: rgba(255,255,255,.38); border: 1px solid rgba(255,255,255,.58); border-radius: 14px; }
.state-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #9aa5ab; }
.state-dot.on { background: var(--nf-green); box-shadow: 0 0 10px rgba(34,153,109,.55); }
.state-dot.off { background: var(--nf-coral); box-shadow: 0 0 10px rgba(232,101,113,.45); }
.logout-button { width: 100%; }

.nf-main { min-width: 0; }
.nf-topbar { position: sticky; top: 20px; z-index: 20; min-height: 70px; border-radius: 20px; }
.topbar-start, .topbar-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-subtitle { margin-top: 3px; font-size: 12px; color: var(--nf-muted); }
.user-chip strong, .user-chip small { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { font-size: 13px; }
.user-chip small { color: var(--nf-muted); font-size: 11px; margin-top: 2px; }
.icon-button {
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid #fff;
  border-radius: 12px;
  background: rgba(255,255,255,.68);
  color: var(--nf-ink);
  box-shadow: 0 4px 14px rgba(20, 30, 40, .07);
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}
.icon-button:hover { transform: translateY(-1px); background: rgba(255,255,255,.9); }
.icon-button.mini { width: 32px; height: 32px; font-size: 14px; }
.mobile-only { display: none; }

.view-panel { min-width: 0; padding-bottom: 20px; }
.view-panel h2, .view-panel h3, .modal h2 { color: var(--nf-ink); letter-spacing: 0; }
.view-panel h2 { margin: 0; font-size: 22px; }
.view-panel p { margin: 5px 0 0; color: var(--nf-muted); font-size: 13px; line-height: 1.6; }
.dashboard-head, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.dashboard-head { min-height: 62px; }
.section-heading h2, .section-heading h3 { margin: 0; }
.section-heading h3 { font-size: 16px; }

.api-switch { min-width: 340px; display: flex; align-items: center; justify-content: flex-end; gap: 14px; cursor: pointer; }
.api-switch > span:first-child { text-align: right; }
.api-switch strong, .api-switch small { display: block; }
.api-switch small { margin-top: 3px; color: var(--nf-muted); font-size: 11px; }
.api-switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 48px; height: 26px; flex: none; position: relative; border-radius: 999px; background: #aeb8bd; transition: background .2s ease; }
.switch-track::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.18); transition: transform .2s ease; }
.api-switch input:checked + .switch-track { background: var(--nf-green); }
.api-switch input:checked + .switch-track::after { transform: translateX(22px); }
.api-readonly { padding: 9px 13px; border-radius: 12px; font-size: 12px; font-weight: 700; background: rgba(255,255,255,.58); border: 1px solid #fff; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-item { min-height: 112px; display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 18px; overflow: hidden; }
.stat-item small, .stat-item strong { display: block; }
.stat-item small { color: var(--nf-muted); font-size: 12px; }
.stat-item strong { margin-top: 7px; color: var(--nf-ink); font-size: 25px; line-height: 1; overflow-wrap: anywhere; }
.stat-icon { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 14px; color: #fff; font-size: 21px; }
.stat-icon.teal { background: #1aa895; }
.stat-icon.green { background: #258e64; }
.stat-icon.coral { background: #df6672; }
.stat-icon.violet { background: #7057ae; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.dashboard-grid .panel { min-height: 320px; border-radius: 20px; }
.dashboard-prices { margin-top: 18px; }
.section-heading.compact { margin-bottom: 10px; }
.dashboard-price-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dashboard-price-card { min-height: 82px; display: flex; align-items: center; gap: 13px; padding: 15px 17px; border-radius: 16px; }
.dashboard-price-card small, .dashboard-price-card strong { display: block; }
.dashboard-price-card small { color: var(--nf-muted); font-size: 11px; }
.dashboard-price-card strong { margin-top: 5px; color: var(--nf-ink); font-size: 19px; }

.service-breakdown { display: grid; gap: 10px; }
.service-row { display: grid; grid-template-columns: 54px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(104,119,128,.15); }
.service-row:last-child { border-bottom: 0; }
.service-metrics strong, .service-metrics small { display: block; }
.service-metrics small { color: var(--nf-muted); margin-top: 4px; }
.service-cost { text-align: right; }
.service-cost strong, .service-cost small { display: block; }
.service-cost small { margin-top: 4px; color: var(--nf-muted); font-size: 11px; }
.service-badge { display: inline-flex; min-width: 46px; height: 26px; padding: 0 9px; align-items: center; justify-content: center; border-radius: 8px; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: 0; }
.service-badge.v6 { background: #18aaab; }
.service-badge.fdl { background: #6d5bb5; }
.service-badge.frp { background: #df7658; }
.service-badge.unknown { background: #66727a; }

.trend-chart { height: 238px; display: grid; grid-template-columns: repeat(7, minmax(32px, 1fr)); gap: 9px; align-items: end; padding-top: 16px; }
.trend-item { height: 100%; min-width: 0; display: grid; grid-template-rows: minmax(0,1fr) auto auto; align-items: end; gap: 7px; text-align: center; }
.trend-bar-wrap { height: 100%; display: flex; align-items: end; justify-content: center; }
.trend-bar { width: min(32px, 68%); min-height: 4px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, #1fc9e7, #35bfab); box-shadow: 0 8px 20px rgba(31,201,231,.2); }
.trend-item strong { font-size: 11px; overflow-wrap: anywhere; }
.trend-item small { color: var(--nf-muted); font-size: 10px; }
.empty-state { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--nf-muted); text-align: center; }
.empty-state i { font-size: 30px; opacity: .7; }

.log-panel { border-radius: 20px; }
.log-heading { align-items: end; }
.log-date-control { width: 180px; }
.log-date-control label { display: block; margin-bottom: 6px; color: var(--nf-muted); font-size: 12px; }
.filter-row { display: grid; grid-template-columns: minmax(260px, 1fr) 130px 130px auto; gap: 10px; margin-bottom: 16px; }
.search-box { position: relative; }
.search-box i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--nf-muted); z-index: 1; }
.search-box .input { padding-left: 42px; }
.logs-list { display: grid; min-height: 280px; }
.log-row { display: grid; grid-template-columns: 72px minmax(0,1.4fr) minmax(130px,.7fr) 108px 118px 36px; gap: 12px; align-items: center; padding: 14px 8px; border-top: 1px solid rgba(104,119,128,.15); cursor: pointer; transition: background .15s ease; }
.log-row:hover { background: rgba(255,255,255,.35); }
.log-row:first-child { border-top: 0; }
.log-primary { min-width: 0; }
.log-primary strong, .log-primary small { display: block; }
.log-primary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.log-primary small, .log-cell small { margin-top: 5px; color: var(--nf-muted); font-size: 11px; }
.log-cell strong, .log-cell small { display: block; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.success { color: var(--nf-green); }
.status-pill.error { color: var(--nf-coral); }
.status-pill.blocked { color: var(--nf-violet); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; color: var(--nf-muted); font-size: 12px; }

.folder-layout, .settings-layout { min-width: 0; }
.folder-tree { display: grid; gap: 18px; }
.year-group > h3 { margin: 0 0 10px; color: #fff; font-size: 18px; text-shadow: 0 2px 12px rgba(0,0,0,.28); }
.month-group { margin-bottom: 12px; overflow: hidden; border: 1px solid rgba(255,255,255,.72); border-radius: 18px; background: rgba(255,255,255,.42); backdrop-filter: blur(20px) saturate(150%); box-shadow: 0 10px 30px rgba(16,25,34,.08); }
.month-head { display: flex; align-items: center; gap: 9px; padding: 14px 16px; border-bottom: 1px solid rgba(104,119,128,.14); font-weight: 700; color: var(--nf-ink); }
.month-head i { color: var(--nf-teal); }
.day-row { display: grid; grid-template-columns: minmax(170px,1fr) minmax(110px,.7fr) minmax(160px,1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border-top: 1px solid rgba(104,119,128,.12); }
.day-row:first-of-type { border-top: 0; }
.day-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.day-title i { color: #d99038; font-size: 21px; }
.day-title strong, .day-title small { display: block; }
.day-title small { color: var(--nf-muted); margin-top: 3px; }
.day-cost strong, .day-cost small { display: block; }
.day-cost small { color: var(--nf-muted); margin-top: 3px; font-size: 11px; }
.day-services { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-service { padding: 5px 7px; border-radius: 7px; background: rgba(255,255,255,.58); color: var(--nf-muted); font-size: 11px; }
.day-actions { display: flex; gap: 7px; }
.day-actions .open-day { width: auto; padding: 0 12px; gap: 7px; }

.price-form, .profile-form { max-width: 980px; border-radius: 20px; }
.price-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.price-field { display: grid; gap: 10px; padding: 14px; border: 1px solid rgba(255,255,255,.72); border-radius: 16px; background: rgba(255,255,255,.34); }
.price-field .service-badge { justify-self: start; }
.price-field strong { font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.profile-form { max-width: 680px; }

.account-list { display: grid; }
.account-row { display: grid; grid-template-columns: minmax(150px,1fr) minmax(210px,1.2fr) 110px 150px auto; gap: 14px; align-items: center; padding: 14px 4px; border-top: 1px solid rgba(104,119,128,.15); }
.account-row:first-child { border-top: 0; }
.account-name strong, .account-name small { display: block; }
.account-name small { margin-top: 4px; color: var(--nf-muted); }
.role-pill { justify-self: start; padding: 5px 9px; border-radius: 8px; background: rgba(24,169,150,.12); color: #147c70; font-size: 11px; font-weight: 700; }
.role-pill.viewer { background: rgba(117,89,184,.12); color: #634b9f; }
.account-status { font-size: 12px; font-weight: 700; color: var(--nf-green); }
.account-status.off { color: var(--nf-coral); }

.modal-backdrop { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 20px; background: rgba(5,9,14,.56); backdrop-filter: blur(10px); }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 40px); overflow: auto; padding: 22px; border-radius: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.modal-head > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.modal-head h2 { margin: 0; font-size: 18px; }
.detail-modal { width: min(940px, 100%); }
.detail-meta { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; margin-bottom: 16px; }
.detail-meta-item { min-width: 0; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.45); border: 1px solid rgba(255,255,255,.7); }
.detail-meta-item small, .detail-meta-item strong { display: block; }
.detail-meta-item small { color: var(--nf-muted); font-size: 10px; }
.detail-meta-item strong { margin-top: 5px; overflow-wrap: anywhere; font-size: 12px; }
.detail-block { margin-top: 13px; }
.detail-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; color: var(--nf-muted); font-size: 12px; font-weight: 700; }
.detail-block pre { max-height: 240px; margin: 0; padding: 14px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 14px; background: rgba(13,19,25,.9); color: #e7edf1; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.65; }
.error-detail { margin-top: 13px; padding: 12px 14px; border-radius: 12px; background: rgba(232,101,113,.12); color: #a93643; overflow-wrap: anywhere; }
.password-modal, .confirm-modal { max-width: 480px; text-align: center; }
.password-modal p, .confirm-modal p { color: var(--nf-muted); line-height: 1.7; }
.password-modal form { text-align: left; margin-top: 20px; }
.modal-symbol { width: 54px; height: 54px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 16px; background: #168f81; color: #fff; font-size: 25px; }
.modal-symbol.danger { background: var(--nf-coral); }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.check-row { display: flex; align-items: center; gap: 9px; color: var(--nf-ink); font-size: 13px; cursor: pointer; }
.check-row input { width: 17px; height: 17px; accent-color: var(--nf-teal); }

.toast-wrap {
  position: fixed !important;
  z-index: 300 !important;
  top: max(14px, env(safe-area-inset-top)) !important;
  right: max(14px, env(safe-area-inset-right)) !important;
  left: auto !important;
  bottom: auto !important;
  width: min(390px, calc(100vw - 28px));
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  pointer-events: none;
}
.toast {
  width: 100%;
  max-width: none;
  min-height: 48px;
  padding: 13px 15px 13px 18px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 1px solid rgba(255,255,255,.9);
  border-left: 4px solid var(--nf-green);
  background: rgba(250,253,253,.96);
  color: #17212b;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: normal;
  box-shadow: 0 16px 42px rgba(8,18,26,.24);
  pointer-events: auto;
}
.toast > i { margin-top: 2px; color: var(--nf-green); font-size: 18px; }
.toast.error > i { color: var(--nf-coral); }
.toast-title, .toast-message { display: block; }
.toast-title { color: #17212b; font-size: 13px; line-height: 1.35; }
.toast-message { margin-top: 3px; color: #53636d; font-weight: 550; line-height: 1.55; }
.toast.error .toast-title { color: #8f2632; }
.toast.error .toast-message { color: #6d3a40; }
.toast.error { border-color: rgba(255,255,255,.9); border-left-color: var(--nf-coral); color: #8f2632; }
.toast.success { border-left-color: var(--nf-green); }
.readonly-badge { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border-radius: 10px; background: rgba(117,89,184,.12); color: #5e4897; font-size: 12px; font-weight: 750; }
.price-form.is-readonly .price-field { background: rgba(255,255,255,.48); }
.price-form.is-readonly .input:disabled { opacity: 1; color: var(--nf-ink); cursor: default; -webkit-text-fill-color: var(--nf-ink); }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-row { grid-template-columns: minmax(240px,1fr) 120px 120px; }
  .filter-row .btn { grid-column: 3; }
  .log-row { grid-template-columns: 64px minmax(0,1fr) 110px 100px 36px; }
  .log-row .log-time { display: none; }
  .day-row { grid-template-columns: minmax(160px,1fr) minmax(100px,.7fr) auto; }
  .day-services { display: none; }
  .account-row { grid-template-columns: minmax(140px,1fr) minmax(190px,1fr) 100px auto; }
  .account-row .account-last { display: none; }
}

@media (max-width: 900px) {
  .mobile-only { display: inline-grid; }
  .nf-shell { display: block; padding: 12px; }
  .nf-sidebar { position: fixed; z-index: 80; inset: 12px auto 12px 12px; top: 12px; width: min(288px, calc(100vw - 52px)); height: auto; transform: translateX(calc(-100% - 24px)); transition: transform .22s ease; }
  .nf-sidebar.open { transform: translateX(0); }
  .nf-main { gap: 14px; }
  .nf-topbar { top: 12px; min-height: 62px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .api-switch { min-width: 0; }
  .dashboard-head { align-items: flex-start; }
  .detail-meta { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 640px) {
  .center-wrap { padding: 12px; }
  .nf-login { padding: 22px 18px; }
  .verify-row { grid-template-columns: minmax(0,1fr) 124px; }
  .verify-button { width: 124px; font-size: 12px; }
  .nf-topbar { padding: 11px 12px; }
  .topbar .title { font-size: 16px; }
  .user-chip { padding: 4px 6px; }
  .user-chip > div:last-child { display: none; }
  .dashboard-head, .section-heading { align-items: stretch; flex-direction: column; }
  .api-switch { width: 100%; justify-content: space-between; }
  .api-switch > span:first-child { text-align: left; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-item { min-height: 96px; padding: 13px; gap: 9px; }
  .stat-icon { width: 38px; height: 38px; border-radius: 12px; font-size: 18px; }
  .stat-item strong { font-size: 19px; }
  .panel { padding: 16px; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .filter-row .search-box { grid-column: 1 / -1; }
  .filter-row .btn { grid-column: auto; }
  .log-date-control { width: 100%; }
  .log-row { grid-template-columns: 56px minmax(0,1fr) 80px 32px; gap: 8px; padding: 13px 2px; }
  .log-row .log-status { display: none; }
  .log-cell strong { font-size: 11px; }
  .day-row { grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
  .day-row .day-cost { grid-column: 1; }
  .day-actions { grid-column: 2; grid-row: 1 / span 2; }
  .day-actions .open-day { width: 38px; padding: 0; }
  .day-actions .open-day span { display: none; }
  .price-grid { grid-template-columns: 1fr; }
  .dashboard-price-grid { grid-template-columns: 1fr; }
  .account-row { grid-template-columns: minmax(0,1fr) auto; }
  .account-row .account-email, .account-row .role-pill { grid-column: 1; }
  .account-row .account-edit { grid-column: 2; grid-row: 1 / span 3; }
  .account-row .account-status { grid-column: 2; }
  .detail-meta { grid-template-columns: 1fr 1fr; }
  .modal { padding: 17px; }
  .toast-wrap {
    top: max(10px, env(safe-area-inset-top)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    width: min(350px, calc(100vw - 20px));
  }
}
