:root {
  --navy: #00578C;
  --blue: #0899CC;
  --light-blue: #66ADE0;
  --ink: #1E1E1E;
  --ink-muted: #5C6672;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --border: #E1E6EC;
  --success: #1E9E5A;
  --error: #D6353D;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top nav ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar__brand img { height: 28px; display: block; }
.topbar__user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--ink-muted);
}

/* ---------- Auth (login/signup) layout ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--blue) 100%);
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 24px 60px -20px rgba(0, 30, 60, 0.45);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}
.auth-card__logo {
  display: block;
  height: 32px;
  margin: 0 auto 28px;
}
.auth-card h1 {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin: 0 0 4px;
}
.auth-card__subtitle {
  text-align: center;
  color: var(--ink-muted);
  font-size: 14px;
  margin: 0 0 28px;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
}
.field input:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(8, 153, 204, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 600;
  padding: 11px 20px;
  cursor: pointer;
  font-family: inherit;
}
.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:hover { background: #004472; }
.btn--primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--navy); border: 1px solid var(--border); }
.btn--ghost:hover { background: var(--bg); }
.btn--danger { background: transparent; color: var(--error); }
.btn--danger:hover { background: rgba(214, 53, 61, 0.08); }

.form-error {
  background: rgba(214, 53, 61, 0.08);
  color: var(--error);
  border: 1px solid rgba(214, 53, 61, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 18px;
  display: none;
}
.form-error.visible { display: block; }

.auth-card__footer {
  text-align: center;
  margin-top: 22px;
  font-size: 13.5px;
  color: var(--ink-muted);
}

/* ---------- Dashboard ---------- */
.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.page__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.page__header h1 { font-size: 24px; margin: 0; }
.page__header p { color: var(--ink-muted); margin: 4px 0 0; font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.add-device-form {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.add-device-form input {
  flex: 1;
  min-width: 160px;
  padding: 11px 14px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}
.add-device-form input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(8, 153, 204, 0.15);
}

.device-list { display: flex; flex-direction: column; gap: 12px; }
.device-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.device-row__status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #C7CDD6;
  flex: none;
}
.device-row__status--online { background: var(--success); box-shadow: 0 0 0 3px rgba(30, 158, 90, 0.18); }
.device-row__status--offline { background: #C7CDD6; }
.device-row__main { flex: 1; min-width: 0; }
.device-row__nickname {
  font-weight: 600;
  font-size: 15px;
  border: none;
  background: transparent;
  font-family: inherit;
  color: var(--ink);
  padding: 2px 0;
  width: 100%;
}
.device-row__nickname:focus {
  outline: none;
  border-bottom: 1px solid var(--blue);
}
.device-row__id {
  font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink-muted);
  letter-spacing: 0.03em;
}
.device-row__meta {
  font-size: 12.5px;
  color: var(--ink-muted);
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-muted);
}
.empty-state h3 { color: var(--ink); margin: 0 0 8px; font-size: 16px; }
.empty-state p { margin: 0 0 4px; font-size: 14px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* ---------- Top nav links (My Devices / Billing & Plans) ---------- */
.topbar__nav {
  display: flex;
  gap: 24px;
  font-size: 13.5px;
  font-weight: 600;
}
.topbar__nav a {
  color: var(--ink-muted);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.topbar__nav a:hover { color: var(--ink); text-decoration: none; }
.topbar__nav a.active { color: var(--navy); border-bottom-color: var(--navy); }

/* ---------- Billing & Plans ---------- */
.plancard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 26px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.plancard__tag {
  display: inline-block;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.plancard__price { font-size: 22px; font-weight: 800; }
.plancard__price span { font-size: 12.5px; font-weight: 600; color: var(--ink-muted); }
.plancard__usage { flex: 1; min-width: 220px; }
.usage__top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.usage__top b { font-weight: 700; }
.usage__bar { height: 7px; border-radius: 99px; background: var(--border); overflow: hidden; }
.usage__fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--blue), var(--navy)); }
.usage__note { font-size: 11.5px; color: var(--ink-muted); margin-top: 10px; }

.sectiontitle { font-size: 15px; font-weight: 800; margin: 30px 0 14px; }

.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.plan {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  position: relative;
}
.plan.current { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8, 153, 204, 0.12); }
.plan__badge {
  position: absolute;
  top: -11px;
  left: 20px;
  background: var(--blue);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
}
.plan__name { font-size: 15px; font-weight: 800; margin: 4px 0 2px; }
.plan__price { font-size: 26px; font-weight: 800; margin: 8px 0 2px; }
.plan__price span { font-size: 12.5px; color: var(--ink-muted); font-weight: 600; }
.plan__limits { font-size: 12.5px; color: var(--ink-muted); margin-bottom: 14px; }
.plan .btn { width: 100%; }
.plan .btn[disabled] { background: var(--border); color: var(--ink-muted); cursor: default; }

.tablewrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tablewrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tablewrap th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.tablewrap td { padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--ink); }
.tablewrap tr:last-child td { border-bottom: none; }
.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  display: inline-block;
}
.status-pill.paid { color: var(--success); background: rgba(30, 158, 90, 0.1); }
.status-pill.failed { color: var(--error); background: rgba(214, 53, 61, 0.1); }
.status-pill.refunded { color: var(--ink-muted); background: var(--bg); }
