/* Hedge Media Rank Tracker — full stylesheet.
   Brand palette lives in custom properties; nothing below hardcodes a colour. */

:root {
  --navy:        #1a365d;
  --navy-dark:   #0f2340;
  --navy-light:  #2c5282;
  --orange:      #ed8936;
  --orange-dark: #c05621;

  --text:        #2d3748;
  --muted:       #718096;
  --bg:          #ffffff;
  --bg-alt:      #f7fafc;
  --border:      #e2e8f0;

  --success:     #48bb78;
  --error:       #e53e3e;

  --radius-btn:  8px;
  --radius-card: 12px;

  --shadow-card: 0 1px 3px rgba(26, 54, 93, .08);
  --shadow-lift: 0 4px 12px rgba(26, 54, 93, .12);

  --nav-height:  60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-alt);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 .5rem;
  line-height: 1.3;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

a { color: var(--navy-light); }
a:hover { color: var(--orange-dark); }

p { margin: 0 0 1rem; }

/* Uppercase orange section label. */
.label {
  display: block;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--orange);
  margin-bottom: .35rem;
}

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.right { text-align: right; }
.centre { text-align: center; }
.nowrap { white-space: nowrap; }

/* --- Wordmark ---------------------------------------------------------- */

.wordmark {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -.02em;
  color: #fff;
  text-decoration: none;
  line-height: 1;
}
.wordmark span { color: var(--orange); }
.wordmark small {
  display: block;
  font-size: .6rem;
  font-weight: 400;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, .6);
  margin-top: 2px;
}

/* --- Navigation -------------------------------------------------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-height);
  background: var(--navy-dark);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
}

.nav-tabs {
  display: flex;
  gap: .25rem;
  margin: 0 auto;
}

.nav-tabs a {
  display: block;
  padding: .45rem .85rem;
  border-radius: var(--radius-btn);
  font-size: .88rem;
  font-weight: 500;
  color: rgba(255, 255, 255, .72);
  text-decoration: none;
  white-space: nowrap;
}
.nav-tabs a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-tabs a.active { background: var(--navy-light); color: #fff; }

.nav-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.nav-right select {
  background: var(--navy);
  color: #fff;
  border: 1px solid var(--navy-light);
  border-radius: var(--radius-btn);
  padding: .35rem .6rem;
  font-family: inherit;
  font-size: .85rem;
}

.nav-right .signout {
  font-size: .85rem;
  color: rgba(255, 255, 255, .72);
  text-decoration: none;
}
.nav-right .signout:hover { color: var(--orange); }

/* --- Layout ------------------------------------------------------------ */

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.grid {
  display: grid;
  gap: 1rem;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* --- Banners ----------------------------------------------------------- */

/* Page-wide notice. Orange left rule with the radius on the right only is the
   brand's accent-card treatment. */
.banner {
  margin-bottom: 1.5rem;
  padding: .85rem 1.1rem;
  background: var(--bg-alt);
  border: 2px solid var(--border);
  border-left: 4px solid var(--orange);
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
  font-size: .9rem;
  color: var(--text);
}

.banner strong {
  color: var(--navy);
  font-weight: 600;
}

/* --- Cards ------------------------------------------------------------- */

.card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card.tight { padding: 1rem; }
.card.flush { padding: 0; overflow: hidden; }

/* Big single number. */
.stat .value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}
.stat .delta { font-size: .82rem; font-weight: 500; }
.delta.up   { color: var(--success); }
.delta.down { color: var(--error); }
.delta.flat { color: var(--muted); }

/* --- Buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border: 2px solid transparent;
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); color: #fff; }

.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-light); color: #fff; }

.btn-ghost { background: transparent; color: var(--navy); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--navy-light); color: var(--navy-light); }

.btn-danger { background: transparent; color: var(--error); border-color: var(--border); }
.btn-danger:hover { background: var(--error); color: #fff; border-color: var(--error); }

.btn-sm { padding: .3rem .65rem; font-size: .78rem; }
.btn:disabled, .btn.is-loading { opacity: .55; cursor: not-allowed; }

.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* --- Badges ------------------------------------------------------------ */

.badge {
  display: inline-block;
  padding: .16rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-navy    { background: rgba(26, 54, 93, .1);   color: var(--navy); }
.badge-orange  { background: rgba(237, 137, 54, .15); color: var(--orange-dark); }
.badge-success { background: rgba(72, 187, 120, .15); color: #276749; }
.badge-error   { background: rgba(229, 62, 62, .12);  color: #9b2c2c; }
.badge-purple  { background: rgba(128, 90, 213, .14); color: #553c9a; }
.badge-muted   { background: var(--bg-alt); color: var(--muted); }

/* --- Tables ------------------------------------------------------------ */

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

thead th {
  /* Offset must be 0, not the nav height. overflow-x on .table-scroll makes
     that div the scroll container, so the header sticks relative to the div,
     not the viewport — a nav-height offset just pushes it down over the first
     row. Needs a stacking order too, or cell backgrounds paint over it. */
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-alt);
  text-align: left;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  padding: .6rem .75rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: var(--bg-alt); }
tbody tr:last-child td { border-bottom: none; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}

/* --- Forms ------------------------------------------------------------- */

.field { margin-bottom: 1rem; }

.field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: .3rem;
}

.field .hint {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  margin-top: .3rem;
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=search], input[type=date], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-btn);
  transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy-light);
}

input.error, select.error, textarea.error { border-color: var(--error); }

textarea { min-height: 120px; resize: vertical; line-height: 1.5; }

.field-row { display: flex; gap: 1rem; }
.field-row .field { flex: 1; }

.checkbox {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
}
.checkbox input { width: auto; }

/* --- Progress bar ------------------------------------------------------ */

.progress {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--navy-light);
  border-radius: 999px;
  transition: width .4s ease;
}

.progress.accent > span { background: var(--orange); }

/* --- Modal ------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 35, 64, .55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lift);
  width: 100%;
  max-width: 520px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 2px solid var(--border);
}

.modal-head h2 { margin: 0; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 .25rem;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 1.25rem; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: 1rem 1.25rem;
  border-top: 2px solid var(--border);
  background: var(--bg-alt);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}

/* --- Toasts ------------------------------------------------------------ */

.toasts {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: .7rem 1rem;
  border-radius: var(--radius-btn);
  border-left: 4px solid var(--navy-light);
  background: var(--bg);
  box-shadow: var(--shadow-lift);
  font-size: .88rem;
  animation: toast-in .2s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--error); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* --- Login ------------------------------------------------------------- */

body.login {
  background: linear-gradient(160deg, var(--navy-dark) 0%, var(--navy-light) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: var(--bg);
  border-radius: var(--radius-card);
  box-shadow: 0 12px 40px rgba(15, 35, 64, .35);
  width: 100%;
  max-width: 380px;
  padding: 2.25rem 2rem;
}

.login-card .brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-card .brand strong {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--navy);
}
.login-card .brand strong span { color: var(--orange); }

.login-card .brand em {
  display: block;
  font-style: normal;
  font-size: .72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--muted);
  margin-top: .4rem;
}

.login-card .btn { width: 100%; }

.alert {
  padding: .65rem .85rem;
  border-radius: var(--radius-btn);
  font-size: .85rem;
  margin-bottom: 1rem;
}
.alert-error   { background: rgba(229, 62, 62, .1);  color: #9b2c2c; }
.alert-success { background: rgba(72, 187, 120, .12); color: #276749; }

/* --- Responsive -------------------------------------------------------- */

@media (max-width: 640px) {
  .nav {
    height: auto;
    flex-wrap: wrap;
    padding: .75rem 1rem;
    gap: .75rem;
  }

  .nav-tabs {
    order: 3;
    width: 100%;
    margin: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-right { margin-left: auto; }

  thead th { position: static; }

  .wrap { padding: 1.25rem 1rem 3rem; }

  .page-head { flex-direction: column; align-items: flex-start; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .field-row { flex-direction: column; gap: 0; }

  .toasts { left: 1rem; right: 1rem; }
  .toast { max-width: none; }
}
