:root {
  --ink: #15201e;
  --muted: #65716e;
  --line: #d9dfdd;
  --surface: #ffffff;
  --soft: #f4f7f6;
  --green: #087f5b;
  --green-dark: #056246;
  --blue: #2166c1;
  --amber: #b56205;
  --red: #b42318;
  --shadow: 0 12px 36px rgba(17, 32, 29, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--soft); }
body { margin: 0; min-height: 100vh; background: var(--soft); }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(22px, calc((100vw - 1120px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 720; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; background: var(--ink); color: white; font-size: 15px; font-weight: 800; }
.brand-mark.compact { width: 34px; height: 34px; font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--muted); font-size: 14px; }

.tabs {
  height: 49px;
  display: flex;
  align-items: end;
  gap: 28px;
  padding: 0 max(22px, calc((100vw - 1120px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tab { height: 49px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 0 2px; font-size: 14px; font-weight: 650; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--green); border-bottom-color: var(--green); }

.main-shell { width: min(1120px, calc(100% - 44px)); margin: 0 auto; padding: 34px 0 70px; }
.view { display: none; }
.view.active { display: block; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 780; letter-spacing: 0; }
h1 { margin: 0; font-size: 28px; line-height: 1.18; letter-spacing: 0; }
h2 { margin: 0 0 14px; font-size: 16px; letter-spacing: 0; }

.button { min-height: 38px; border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; background: white; color: var(--ink); font-weight: 680; font-size: 14px; }
.button:hover { border-color: #aab4b1; }
.button.primary { border-color: var(--green); background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { background: #eaf2fc; border-color: #bfd3ee; color: #164f96; }
.button.quiet { background: transparent; }
.button.danger { color: var(--red); border-color: #edc5c2; background: #fff8f7; }
.button.full { width: 100%; }

.ip-lookup-form { display: grid; grid-template-columns: minmax(240px, 1fr) auto; align-items: end; gap: 14px; margin: -4px 0 24px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.ip-lookup-form .button { height: 40px; white-space: nowrap; }

.loading-band, .empty-state { min-height: 136px; display: flex; align-items: center; justify-content: center; gap: 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid #cbd4d1; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

.result-layout { display: grid; gap: 22px; }
.ip-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 154px; padding: 25px 28px; background: var(--ink); color: white; border-radius: 6px; }
.field-label { color: #aab8b4; font-size: 12px; }
.ip-address { margin: 7px 0 5px; font: 720 clamp(28px, 5vw, 46px)/1.05 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; letter-spacing: 0; }
.location-line { margin: 0; color: #c5cfcc; font-size: 14px; }
.risk-gauge { flex: 0 0 96px; width: 96px; height: 96px; border-radius: 50%; display: grid; place-content: center; text-align: center; border: 7px solid #3da77e; background: #1f2b28; }
.risk-gauge[data-level="medium"] { border-color: #d58b2e; }
.risk-gauge[data-level="high"] { border-color: #e16055; }
.risk-gauge strong { font-size: 29px; line-height: 1; }
.risk-gauge span { margin-top: 5px; color: #c5cfcc; font-size: 11px; }

.metrics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden; }
.metric { min-height: 92px; padding: 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric:nth-child(3n) { border-right: 0; }
.metric:nth-last-child(-n+3) { border-bottom: 0; }
.metric span { display: block; margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.metric strong { display: block; font-size: 15px; overflow-wrap: anywhere; }

.signal-section { padding: 20px 0; }
.signal-list { display: flex; flex-wrap: wrap; gap: 8px; }
.signal { display: inline-flex; align-items: center; min-height: 32px; padding: 6px 10px; border-radius: 5px; font-size: 12px; font-weight: 650; }
.signal.clear { background: #e9f6f0; color: #116548; border: 1px solid #bfe2d2; }
.signal.flagged { background: #fff0ee; color: var(--red); border: 1px solid #f0c2bd; }

.privacy-badge { display: inline-flex; align-items: center; height: 31px; padding: 0 10px; border: 1px solid #bfe2d2; border-radius: 5px; background: #e9f6f0; color: #116548; font-size: 12px; font-weight: 700; }
.remote-form { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.form-grid { display: grid; gap: 15px; align-items: start; }
.address-grid { grid-template-columns: minmax(240px, 1fr) 130px 148px; }
.credentials-grid { grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) 148px; margin-top: 18px; }
label > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
input { width: 100%; height: 40px; border: 1px solid #cdd5d2; border-radius: 5px; background: white; color: var(--ink); padding: 0 11px; outline: none; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8, 127, 91, .12); }
.align-end { align-self: end; height: 40px; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--red); font-size: 13px; }
.fingerprint-box { margin-top: 18px; padding: 14px; background: #f2f6fb; border-left: 3px solid var(--blue); }
.fingerprint-box > span { display: block; color: var(--muted); font-size: 12px; }
.fingerprint-box code { display: block; margin: 7px 0 12px; color: #173f71; overflow-wrap: anywhere; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: 16px; height: 16px; }
.check-row span { margin: 0; color: var(--ink); }

.terminal-panel, .report-panel { margin-top: 22px; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); }
.terminal-head { display: flex; justify-content: space-between; padding: 10px 14px; background: #1a2422; color: #aebbb7; font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
.terminal-body { min-height: 105px; padding: 24px; background: #101715; color: #b8f1d9; font: 13px ui-monospace, SFMono-Regular, Consolas, monospace; }
.terminal-cursor { display: inline-block; width: 8px; height: 14px; margin-right: 5px; vertical-align: -2px; background: #4dd49f; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.report-panel { border: 1px solid var(--line); background: white; box-shadow: none; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.report-head span { display: block; color: var(--muted); font-size: 12px; }
.report-head strong { display: block; margin-top: 3px; }
.report-panel pre { max-height: 520px; margin: 0; padding: 18px; overflow: auto; background: #f7f9f8; color: #24312e; font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.history-list { border-top: 1px solid var(--line); }
.history-row { width: 100%; min-height: 72px; display: grid; grid-template-columns: 52px minmax(0, 1fr) 110px; align-items: center; gap: 14px; padding: 12px 8px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; color: var(--ink); }
.history-row:hover { background: #eef3f1; }
.history-kind { justify-self: start; padding: 5px 7px; border-radius: 4px; color: white; font-size: 11px; font-weight: 760; }
.history-kind.current { background: var(--green); }
.history-kind.manual { background: var(--amber); }
.history-kind.remote { background: var(--blue); }
.history-main { min-width: 0; }
.history-main strong, .history-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-main span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.history-row time { color: var(--muted); font-size: 12px; text-align: right; }

.toast { position: fixed; right: 22px; bottom: 22px; transform: translateY(16px); opacity: 0; pointer-events: none; padding: 11px 14px; border-radius: 5px; background: var(--ink); color: white; font-size: 13px; transition: .18s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.footer { width: min(1120px, calc(100% - 44px)); margin: -38px auto 24px; color: #7a8582; font-size: 11px; }
.footer a { color: #52635e; }

.login-page { display: grid; place-items: center; padding: 24px; background: #edf2f0; }
.login-shell { width: min(820px, 100%); min-height: 480px; display: grid; grid-template-columns: 1.25fr .75fr; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.login-panel { padding: 58px 64px; }
.login-panel h1 { margin-top: 5px; font-size: 32px; }
.login-form { display: grid; gap: 17px; margin-top: 42px; }
.login-aside { display: flex; flex-direction: column; justify-content: end; padding: 36px; background: var(--ink); color: white; }
.login-aside p { margin: 12px 0 4px; font-weight: 720; }
.login-aside span { color: #9fb0ab; font-size: 12px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #35c991; box-shadow: 0 0 0 6px rgba(53, 201, 145, .13); }

@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .tabs { gap: 20px; padding: 0 16px; overflow-x: auto; }
  .main-shell { width: min(100% - 28px, 1120px); padding-top: 25px; }
  .section-heading { align-items: center; }
  .ip-lookup-form { grid-template-columns: 1fr; }
  .ip-lookup-form .button { width: 100%; }
  h1 { font-size: 23px; }
  .ip-hero { align-items: flex-start; padding: 22px; }
  .risk-gauge { width: 78px; height: 78px; flex-basis: 78px; border-width: 6px; }
  .risk-gauge strong { font-size: 24px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(3n) { border-right: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-last-child(-n+3) { border-bottom: 1px solid var(--line); }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .address-grid, .credentials-grid { grid-template-columns: 1fr 110px; }
  .address-grid .wide { grid-column: 1 / -1; }
  .credentials-grid label:nth-child(2) { grid-column: 1 / -1; }
  .history-row { grid-template-columns: 48px minmax(0, 1fr); }
  .history-row time { grid-column: 2; text-align: left; }
  .login-shell { min-height: 0; grid-template-columns: 1fr; }
  .login-panel { padding: 40px 28px; }
  .login-aside { display: none; }
}

@media (max-width: 480px) {
  .user-name { display: none; }
  .ip-hero { min-height: 180px; flex-direction: column; }
  .metrics-grid { grid-template-columns: 1fr; }
  .metric, .metric:nth-child(2n), .metric:nth-child(3n), .metric:nth-last-child(-n+2), .metric:nth-last-child(-n+3) { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .address-grid, .credentials-grid { grid-template-columns: 1fr; }
  .address-grid .wide, .credentials-grid label:nth-child(2) { grid-column: auto; }
  .align-end { width: 100%; }
}
