@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:       #080c10;
  --surface:  #0d1117;
  --surface2: #161b22;
  --border:   #21262d;
  --text:     #e6edf3;
  --muted:    #7d8590;
  --subtle:   #30363d;
  --gold:     #d29922;
  --blue:     #58a6ff;
  --green:    #3fb950;
  --red:      #f78166;
  --purple:   #bc8cff;
}
html, body { background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; min-height: 100vh; }

/* nav */
.tool-nav { padding: 20px 24px 0; max-width: 1080px; margin: 0 auto; }
.nav-back { color: var(--muted); font-size: 13px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: color 0.15s; }
.nav-back:hover { color: var(--text); }

/* layout */
.app { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }

/* header */
.header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 32px; flex-wrap: wrap; }
.header-row h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.5px; margin-bottom: 4px; }
.header-row .subtitle { font-size: 14px; color: var(--muted); max-width: 560px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-top: 4px; }
@media (max-width: 540px) {
  .header-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-actions { width: 100%; }
}

/* save indicator */
.save-indicator { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 5px; opacity: 0; transition: opacity 0.3s; }
.save-indicator.show { opacity: 1; }
.save-indicator .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* buttons */
.reset-btn { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 6px; cursor: pointer; font-size: 12px; font-family: 'DM Sans', sans-serif; padding: 6px 12px; transition: all 0.15s; white-space: nowrap; }
.reset-btn:hover { border-color: var(--red); color: var(--red); }
.add-btn { display: flex; align-items: center; gap: 8px; background: none; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 13px; font-family: 'DM Sans', sans-serif; padding: 10px 16px; width: 100%; transition: all 0.15s; margin-top: 4px; }
.add-btn:hover { border-color: var(--blue); color: var(--blue); }
.primary-btn { background: var(--blue); border: none; color: #000; border-radius: 6px; cursor: pointer; font-size: 13px; font-family: 'DM Sans', sans-serif; font-weight: 600; padding: 8px 18px; transition: opacity 0.15s; }
.primary-btn:hover { opacity: 0.85; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 20px; }
.section-title { font-size: 11px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.sep { height: 1px; background: var(--border); margin: 18px 0; }

/* inputs */
.input-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.input-group { flex: 1 1 150px; }
.input-group label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.input-wrap { position: relative; }
.pfx { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-family: 'DM Mono', monospace; font-size: 12px; pointer-events: none; }
input[type=number], input[type=text], select {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-family: 'DM Mono', monospace; font-size: 13px;
  padding: 8px 10px 8px 22px; outline: none; transition: border-color 0.15s;
  -moz-appearance: textfield;
}
select { padding-left: 10px; cursor: pointer; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; }
input:focus, select:focus { border-color: var(--blue); }

/* stat cards */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-card { flex: 1 1 160px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; border-top: 2px solid var(--border); }
.stat-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-family: 'DM Mono', monospace; font-size: 15px; font-weight: 500; }
.stat-sub { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* chart */
.chart-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }

/* table */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead tr { border-bottom: 2px solid var(--border); }
th { padding: 10px 14px; color: var(--muted); font-weight: 500; text-align: right; white-space: nowrap; font-size: 11px; letter-spacing: 0.3px; }
th:first-child { text-align: left; }
td { padding: 9px 14px; text-align: right; color: var(--text); font-family: 'DM Mono', monospace; border-bottom: 1px solid var(--border); }
td:first-child { text-align: left; color: var(--muted); }
tr:last-child td { border-bottom: none; }
tr.highlight td { color: var(--gold); }
tr.positive td { color: var(--green); }

/* two-col layout */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 680px) { .two-col { grid-template-columns: 1fr; } }

/* result callout */
.callout { border-radius: 10px; padding: 16px 20px; margin-bottom: 20px; border: 1px solid; }
.callout.green { background: rgba(63,185,80,0.08); border-color: rgba(63,185,80,0.3); }
.callout.blue  { background: rgba(88,166,255,0.08); border-color: rgba(88,166,255,0.3); }
.callout.gold  { background: rgba(210,153,34,0.08); border-color: rgba(210,153,34,0.3); }
.callout.red   { background: rgba(247,129,102,0.08); border-color: rgba(247,129,102,0.3); }
.callout-title { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 6px; }
.callout-value { font-family: 'DM Mono', monospace; font-size: 22px; font-weight: 500; }
.callout-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.footer { margin-top: 24px; font-size: 11px; color: var(--subtle); text-align: center; }

/* tooltip shared config (via JS) */
.tooltip-dark { background: #0d1117; border: 1px solid #21262d; border-radius: 8px; padding: 10px 14px; font-size: 12px; }

/* ─── Global Nav ─────────────────────────────────────────────────────────── */
#global-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.gnav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.gnav-left  { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.gnav-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.gnav-brand { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.gnav-back  { font-size: 13px; color: var(--muted); text-decoration: none; white-space: nowrap; transition: color 0.15s; }
.gnav-back:hover { color: var(--text); }
.gnav-sep   { color: var(--subtle); font-size: 13px; padding: 0 4px; }
.gnav-tool  { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Nav Auth Area ──────────────────────────────────────────────────────── */
.nav-signin-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; cursor: pointer; font-size: 12px; font-family: 'DM Sans', sans-serif;
  font-weight: 500; padding: 5px 14px; transition: all 0.15s; white-space: nowrap;
}
.nav-signin-btn:hover { border-color: var(--blue); color: var(--blue); }

.nav-user { display: flex; align-items: center; gap: 8px; }
.nav-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--blue);
  color: #000; font-size: 11px; font-weight: 700; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.nav-email { font-size: 12px; color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-signout-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 12px; font-family: 'DM Sans', sans-serif; padding: 0;
  transition: color 0.15s;
}
.nav-signout-btn:hover { color: var(--red); }
.nav-sync { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.nav-sync.synced { background: var(--green); }
.nav-sync.error  { background: var(--red); }

/* ─── Auth Modal ─────────────────────────────────────────────────────────── */
.auth-modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; width: 100%; max-width: 400px; position: relative;
}
.auth-modal-close {
  position: absolute; top: 16px; right: 16px; background: none; border: none;
  color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1;
  transition: color 0.15s; padding: 4px 8px;
}
.auth-modal-close:hover { color: var(--text); }
.auth-title    { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.auth-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.auth-error   { font-size: 12px; color: var(--red);   background: rgba(247,129,102,0.1); border: 1px solid rgba(247,129,102,0.3); border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; }
.auth-success { font-size: 12px; color: var(--green); background: rgba(63,185,80,0.1);  border: 1px solid rgba(63,185,80,0.3);  border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; }
.auth-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.auth-tab {
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted);
  cursor: pointer; font-size: 13px; font-family: 'DM Sans', sans-serif; font-weight: 500;
  padding: 8px 16px; margin-bottom: -1px; transition: all 0.15s;
}
.auth-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.auth-field { margin-bottom: 14px; }
.auth-field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.auth-field input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-family: 'DM Mono', monospace; font-size: 13px;
  padding: 9px 12px; outline: none; transition: border-color 0.15s;
}
.auth-field input:focus { border-color: var(--blue); }
.auth-btn-primary {
  width: 100%; background: var(--blue); border: none; border-radius: 8px;
  color: #000; cursor: pointer; font-size: 13px; font-family: 'DM Sans', sans-serif;
  font-weight: 600; padding: 10px; transition: opacity 0.15s; margin-bottom: 8px;
}
.auth-btn-primary:hover:not(:disabled) { opacity: 0.85; }
.auth-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-btn-secondary {
  width: 100%; background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); cursor: pointer; font-size: 13px; font-family: 'DM Sans', sans-serif;
  font-weight: 500; padding: 9px; transition: all 0.15s;
}
.auth-btn-secondary:hover:not(:disabled) { border-color: var(--subtle); color: var(--text); }
.auth-btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
