/* Shield main.css — "Sky + Slate" theme (v3.9)
   Soft sky-blue bg, slate ink text, sky-500 accent. Matches marketing.css. */

:root {
  --bg:        #F0F9FF;        /* sky-50 — soft blue-white */
  --bg-2:      #E0F2FE;        /* sky-100 — soft blue for sections / aside */
  --bg-3:      #BAE6FD;        /* sky-200 — deeper blue for hovers / inputs */
  --fg:        #0F172A;        /* slate-900 ink */
  --fg-2:      #475569;        /* slate-600 */
  --accent:    #0EA5E9;        /* sky-500 — primary accent */
  --accent-2:  #0284C7;        /* sky-600 — hover */
  --accent-ink: #0F172A;       /* slate-900 for trust CTAs */
  --warn:      #C2410C;        /* orange-700 */
  --ok:        #047857;        /* emerald-700 */
  --danger:    #B91C1C;        /* red-700 */
  --border:    #7DD3FC;        /* sky-300 — visible border */
  --radius:    6px;
  --shadow:    0 2px 8px rgba(14, 165, 233, 0.08);
  --font:      ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:      ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
aside { background: var(--bg-2); border-right: 1px solid var(--border); padding: 1.5rem 0.75rem; }
main  { padding: 1.5rem 2rem; overflow: auto; }
.brand { font-size: 1.1rem; font-weight: 700; padding: 0 .25rem 1rem .25rem; color: var(--fg); display: flex; align-items: center; gap: .5rem; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }
nav a { display: block; padding: .55rem .75rem; color: var(--fg-2); border-radius: var(--radius); margin-bottom: 2px; }
nav a:hover { background: var(--bg-3); color: var(--fg); text-decoration: none; }
nav a.active { background: var(--bg-3); color: var(--accent); }

header.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
header.topbar h1 { font-size: 1.4rem; margin: 0; }
.user-pill { display: flex; align-items: center; gap: .5rem; color: var(--fg-2); font-size: .9rem; }
.user-pill .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-3); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent); }

/* cards & grid */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 .35rem 0; font-size: .8rem; color: var(--fg-2); text-transform: uppercase; letter-spacing: .08em; }
.card .v { font-size: 1.8rem; font-weight: 700; }
.card .sub { font-size: .8rem; color: var(--fg-2); margin-top: .25rem; }
.card.danger .v { color: var(--danger); }
.card.warn   .v { color: var(--warn); }
.card.ok     .v { color: var(--ok); }

.panel { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem; }
.panel h2 { margin: 0 0 1rem 0; font-size: 1.05rem; }

/* forms */
input, select, textarea, button {
  font: inherit; color: var(--fg);
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .55rem .75rem; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
button  { background: var(--accent); color: #06222a; border: none; font-weight: 600; cursor: pointer; width: auto; }
button:hover { filter: brightness(1.07); }
button.secondary { background: var(--bg-3); color: var(--fg); border: 1px solid var(--border); }
button.danger    { background: var(--danger); color: #fff; }
button.warn      { background: var(--warn);   color: #2a1c00; }
label { display: block; font-size: .85rem; color: var(--fg-2); margin-bottom: .25rem; margin-top: .5rem; }
.field { margin-bottom: .75rem; }
.field .err { color: var(--danger); font-size: .8rem; margin-top: .25rem; }
.row   { display: flex; gap: .75rem; }
.row > .field { flex: 1; }

/* table */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .55rem .65rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--fg-2); font-weight: 600; text-transform: uppercase; font-size: .75rem; letter-spacing: .05em; }
tr:hover td { background: var(--bg-3); }
td .pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .72rem; font-weight: 600; background: var(--bg-3); color: var(--fg-2); }
td .pill.ok    { background: rgba(139,209,124,.15); color: var(--ok); }
td .pill.warn  { background: rgba(246,193,119,.15); color: var(--warn); }
td .pill.danger{ background: rgba(255,92,92,.15); color: var(--danger); }
td .pill.info  { background: rgba(77,208,225,.15); color: var(--accent); }

/* flash */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.flash.ok  { background: rgba(139,209,124,.15); color: var(--ok); }
.flash.err { background: rgba(255,92,92,.15);  color: var(--danger); }
.flash.info{ background: rgba(77,208,225,.12); color: var(--accent); }

/* progress bar */
.bar { background: var(--bg-3); height: 8px; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.warn > span { background: var(--warn); }
.bar.danger > span { background: var(--danger); }

/* site-health dot — topbar live indicator */
.site-health-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin: 0 .35rem;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
  transition: background-color .25s ease;
}
.site-health-dot.ok      { background: var(--ok); }
.site-health-dot.warn    { background: var(--warn); }
.site-health-dot.danger  { background: var(--danger); }
.site-health-dot.unknown { background: #555; }

/* operator notes modal — note cards inside #notesModal */
.note-card {
  background: var(--bg-3);
  border-left: 3px solid var(--accent);
  padding: .55rem .75rem;
  border-radius: 0 6px 6px 0;
  margin-bottom: .4rem;
}
.note-card .note-body {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: .9rem;
  line-height: 1.4;
}
.note-card button { float: right; }

/* compact "Actions ▾" menu — replaces the per-row action button bar in
   the takedown table. Popup is positioned below the button. */
.td-menu { position: relative; display: inline-block; }
.td-menu-btn {
  font-size: .78rem;
  font-weight: 600;
  padding: .25rem .6rem;
  background: var(--glass-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-1);
  cursor: pointer;
}
.td-menu-popup {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 50;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  padding: .25rem;
  display: flex;
  flex-direction: column;
  min-width: 200px;
}
.td-menu-popup button {
  text-align: left;
  background: transparent;
  border: 0;
  padding: .4rem .6rem;
  border-radius: 4px;
  color: var(--fg);
  font-size: .85rem;
  cursor: pointer;
}
.td-menu-popup button:hover { background: var(--bg-3); }

/* compact kvrow used in admin: 4 columns, no excess padding */
.kvrow {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.kvrow:last-child { border-bottom: 0; }
.kvrow > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kvrow .right { text-align: right; }
.kvrow .small-text { font-size: .8rem; }
.userrow:hover { background: var(--bg-3); }

/* utility */
.muted { color: var(--fg-2); }
.mono  { font-family: var(--mono); }
.tight td, .tight th { padding: .35rem .5rem; }
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 980px; }
.takedowns-table { table-layout: fixed; }
.takedowns-table th:nth-child(1), .takedowns-table td:nth-child(1) { width: 42px; }
.takedowns-table th:nth-child(2), .takedowns-table td:nth-child(2) { width: 86px; }
.takedowns-table th:nth-child(3), .takedowns-table td:nth-child(3) { width: 150px; }
.takedowns-table th:nth-child(4), .takedowns-table td:nth-child(4) { width: 240px; }
.takedowns-table th:nth-child(5), .takedowns-table td:nth-child(5) { width: 120px; }
.takedowns-table th:nth-child(6), .takedowns-table td:nth-child(6) { width: 185px; }
.takedowns-table th:nth-child(7), .takedowns-table td:nth-child(7),
.takedowns-table th:nth-child(8), .takedowns-table td:nth-child(8),
.takedowns-table th:nth-child(9), .takedowns-table td:nth-child(9) { width: 150px; }
.takedowns-table th:nth-child(10), .takedowns-table td:nth-child(10) { width: 210px; }
.takedowns-table th:nth-child(11), .takedowns-table td:nth-child(11) { width: 230px; }
.flex { display: flex; gap: .5rem; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.small-text { font-size: .8rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.row-actions .pill { white-space: nowrap; }

/* URL cell: middle-ellipsis when long, full URL on hover via title attr */
.url-cell {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.url-cell a {
  color: var(--fg-1);
  text-decoration: none;
  border-bottom: 1px dotted var(--fg-2);
}
.url-cell a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* auth pages */
.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
.auth .panel { width: 100%; max-width: 420px; }
.auth h1 { margin: 0 0 1rem 0; text-align: center; }
.auth .sub { color: var(--fg-2); text-align: center; margin-bottom: 1.5rem; }

/* admin grid */
.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }

/* dashboard outcome panels */
.compact-heading {
  font-size: .98rem;
  margin: 0;
}

.dashboard-split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 1rem;
}

.outcome-cards {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.domain-stats {
  display: grid;
  gap: .75rem;
}

.domain-row {
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-3);
}

.domain-row strong {
  font-size: .92rem;
}

.domain-row .bar {
  margin-top: .55rem;
}

.domain-meta {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  margin-top: .4rem;
  color: var(--fg-2);
  font-size: .78rem;
}

.domain-empty {
  padding: 2rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

@media (max-width: 980px) {
  .dashboard-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--border); }
  main { padding: 1rem; }
  header.topbar, .between { align-items: flex-start; gap: .75rem; flex-direction: column; }
  .table-scroll { overflow: visible; }
  .table-scroll table { min-width: 0; }
  .takedowns-table thead { display: none; }
  .takedowns-table,
  .takedowns-table tbody,
  .takedowns-table tr,
  .takedowns-table td {
    display: block;
    width: 100% !important;
  }
  .takedowns-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-2);
    margin-bottom: .75rem;
    overflow: hidden;
  }
  .takedowns-table td {
    border-bottom: 1px solid var(--border);
    padding: .6rem .75rem;
    white-space: normal;
  }
  .takedowns-table td:last-child { border-bottom: 0; }
  .takedowns-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--fg-2);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .2rem;
  }
  .takedowns-table .url-cell {
    max-width: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* =====================================================================
   Responsive system — mobile / tablet / wide
   Breakpoints:
     xs:  ≤ 480px   (phones portrait)
     sm:  ≤ 640px   (phones landscape / phablets)
     md:  ≤ 900px   (tablets portrait)
     lg:  ≤ 1200px  (tablets landscape / small laptops)
   xl:  > 1200px   (desktop, default)
   ===================================================================== */

/* ------- XL — Desktop (1200px and up) : nothing to override ------- */

/* ------- LG — Small laptops / tablet landscape (≤ 1200px) ------- */
@media (max-width: 1200px) {
  main { padding: 1.25rem 1.5rem; }
  .url-cell { max-width: 280px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  header.topbar h1 { font-size: 1.3rem; }
}

/* ------- MD — Tablets (≤ 900px) ------- */
@media (max-width: 900px) {
  html, body { font-size: 14.5px; }
  .app { grid-template-columns: 200px 1fr; }
  aside { padding: 1.25rem 0.6rem; }
  main { padding: 1.25rem 1.25rem; }
  header.topbar h1 { font-size: 1.25rem; }
  .panel { padding: 1rem; }
  .dashboard-split { grid-template-columns: 1fr; }
  .cards { gap: .75rem; }
  .row { flex-wrap: wrap; }
  .row > .field { min-width: 220px; }
  .url-cell { max-width: 220px; }
  .auth { padding: 1.25rem; }
}

/* ------- SM — Phablets / phones landscape (≤ 640px) ------- */
@media (max-width: 640px) {
  html, body { font-size: 14px; }
  /* App layout flips: sidebar becomes a horizontal top nav */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  aside {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: .75rem .75rem .5rem .75rem;
  }
  .brand { padding: 0 0 .5rem 0; font-size: 1rem; }
  nav {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
  }
  nav a {
    display: inline-flex;
    align-items: center;
    padding: .35rem .65rem;
    margin: 0;
    font-size: .82rem;
    background: var(--bg-3);
  }
  nav a.active { background: var(--accent); color: #06222a; }
  /* #logout stays as last item, full width on phones */
  nav a#logout { width: 100%; justify-content: center; margin-top: .35rem; }

  main { padding: 1rem .85rem 2rem .85rem; }

  /* Topbar: stack title above user pill */
  header.topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: 1rem;
  }
  header.topbar h1 { font-size: 1.15rem; }
  .user-pill { align-self: flex-end; font-size: .82rem; }

  /* Cards: always 1 column on phone */
  .cards { grid-template-columns: 1fr; gap: .65rem; margin-bottom: 1.25rem; }
  .card { padding: .85rem 1rem; }
  .card .v { font-size: 1.5rem; }

  /* Panels */
  .panel { padding: .85rem; margin-bottom: 1rem; }
  .panel h2 { font-size: 1rem; }

  /* Forms: full width, stacked rows */
  .row { flex-direction: column; gap: 0; }
  .row > .field { min-width: 0; }
  input, select, textarea, button {
    font-size: 16px;       /* avoid iOS zoom on focus */
    padding: .65rem .8rem;
  }
  .field { margin-bottom: .65rem; }

  /* Buttons: full width on phone for primary CTAs */
  button, .button, a.button, a.card {
    min-height: 44px;      /* iOS / WCAG touch target */
  }
  main button,
  main .button,
  main a.button {
    width: 100%;
  }
  .row-actions button,
  .row-actions .button,
  .panel-toolbar button,
  .panel-toolbar .button,
  form.inline button,
  .no-stretch button,
  .no-stretch .button {
    width: auto;
    min-height: 36px;
  }

  /* Tables: convert to stacked card layout */
  .table-scroll { overflow: visible; }
  .table-scroll > table,
  .table-scroll table {
    min-width: 0;
    display: block;
    width: 100%;
  }
  .table-scroll > table thead,
  .table-scroll table thead {
    display: none;
  }
  .table-scroll > table tbody,
  .table-scroll table tbody {
    display: block;
    width: 100%;
  }
  .table-scroll > table tr,
  .table-scroll table tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-2);
    margin-bottom: .65rem;
    overflow: hidden;
  }
  .table-scroll > table td,
  .table-scroll table td {
    display: block;
    width: 100% !important;
    border-bottom: 1px solid var(--border);
    padding: .55rem .75rem;
    white-space: normal;
  }
  .table-scroll > table td:last-child,
  .table-scroll table td:last-child { border-bottom: 0; }
  .table-scroll > table td::before,
  .table-scroll table td::before {
    content: attr(data-label);
    display: block;
    color: var(--fg-2);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .15rem;
  }
  .url-cell { max-width: none; white-space: normal; overflow-wrap: anywhere; }

  /* Headers inside tables/panels */
  .row-actions { width: 100%; }
  .row-actions .pill,
  .row-actions button { flex: 1 1 auto; }

  /* Domain / outcome rows */
  .domain-row { padding: .65rem; }
  .domain-meta { flex-direction: column; gap: .15rem; }

  /* Auth forms */
  .auth { padding: 1rem; align-items: flex-start; padding-top: 2rem; }
  .auth .panel { padding: 1.1rem; }
  .auth h1 { font-size: 1.25rem; }

  /* Toolbar / search row wraps */
  .toolbar, .search-row, .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: .5rem;
  }
  .toolbar > *, .search-row > *, .filter-bar > * { width: 100%; }
  .toolbar input, .toolbar select, .toolbar button { width: 100%; }

  /* Hide secondary columns on tiny screens via class hook */
  .hide-sm { display: none !important; }
}

/* ------- XS — Small phones (≤ 480px) ------- */
@media (max-width: 480px) {
  html, body { font-size: 13.5px; }
  main { padding: .85rem .65rem 1.5rem .65rem; }
  .panel { padding: .75rem; }
  .card { padding: .75rem .85rem; }
  .card .v { font-size: 1.35rem; }
  header.topbar h1 { font-size: 1.05rem; }
  .pill { font-size: .68rem; padding: 1px 7px; }
  .flash { font-size: .82rem; padding: .6rem .75rem; }
  .hide-xs { display: none !important; }
}

/* ------- Touch / accessibility niceties (all sizes) ------- */
@media (hover: none) {
  /* On touch devices, drop hover-only decorations that look broken */
  tr:hover td { background: transparent; }
}

/* Print: hide chrome, expand content */
@media print {
  aside, header.topbar, .flash, .row-actions, .toolbar, nav, button { display: none !important; }
  .app { display: block; }
  main { padding: 0; }
  .panel, .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; color: #000; }
}
