/* [hidden] must win over component display rules (.login sets display:grid,
   which would otherwise override the UA [hidden]{display:none} and leave the
   login overlay on top of the dashboard). */
[hidden] { display: none !important; }

:root {
  --bg: #0E0E11;
  --bg-soft: #15151a;
  --bg-card: #17171d;
  --line: #26262f;
  --line-soft: #1d1d24;
  --ink: #F4F1EA;
  --ink-dim: #9a978f;
  --ink-faint: #5f5d58;
  --accent: #E8FF52;
  --accent-dim: rgba(232, 255, 82, 0.14);
  --green: #6fe39a;
  --amber: #f2c14e;
  --mono: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "Archivo", system-ui, sans-serif;
  --r: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(900px 500px at 88% -8%, rgba(232,255,82,0.05), transparent 60%),
    radial-gradient(700px 500px at -5% 110%, rgba(232,255,82,0.025), transparent 55%);
}

/* subtle film grain over everything */
.grain {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none; opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--accent); color: #0E0E11; }

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); }
.prompt { color: var(--accent); font-family: var(--mono); font-weight: 600; letter-spacing: -1px; }
.brandname { font-weight: 900; letter-spacing: -0.5px; font-size: 20px; }
.brandname .dot { color: var(--accent); }
.brand.sm .brandname { font-size: 16px; }
.brand .tab {
  font-family: var(--mono); font-size: 11px; color: var(--ink-dim);
  border-left: 1px solid var(--line); padding-left: 10px; margin-left: 4px;
  text-transform: lowercase; letter-spacing: 0.5px;
}

/* ============ LOGIN ============ */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-soft));
  border: 1px solid var(--line); border-radius: 16px;
  padding: 34px 30px 26px; position: relative;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.03);
  animation: rise 0.5s cubic-bezier(.2,.7,.2,1) both;
}
.login-card::before {
  content: ""; position: absolute; inset: 0; border-radius: 16px; padding: 1px;
  background: linear-gradient(160deg, rgba(232,255,82,0.5), transparent 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; opacity: 0.5;
}
.login .brand { font-size: 22px; }
.login-tag { color: var(--ink-dim); font-size: 12px; margin: 12px 0 26px; }
#login-form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-size: 11px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 1px; }
input {
  font-family: var(--mono); font-size: 14px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
button {
  font-family: var(--mono); cursor: pointer; border: none; font-size: 14px;
}
#login-btn {
  margin-top: 6px; background: var(--accent); color: #0E0E11; font-weight: 600;
  padding: 12px; border-radius: var(--r); letter-spacing: 0.3px;
  transition: transform .12s, box-shadow .2s; box-shadow: 0 8px 24px -8px rgba(232,255,82,0.5);
}
#login-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 30px -8px rgba(232,255,82,0.6); }
#login-btn:active { transform: translateY(0); }
#login-btn:disabled { opacity: .6; cursor: wait; }
.caret { transition: transform .15s; display: inline-block; }
#login-btn:hover .caret { transform: translateX(3px); }
.err { color: #ff6b6b; font-size: 12px; min-height: 16px; }
.login-foot { margin-top: 20px; font-size: 10px; color: var(--ink-faint); letter-spacing: 0.5px; }

/* ============ DASH ============ */
.dash { max-width: 1180px; margin: 0 auto; padding: 22px 24px 60px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 22px;
}
.ghost {
  background: transparent; color: var(--ink-dim); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 8px; font-size: 12px; transition: .15s;
}
.ghost:hover { color: var(--ink); border-color: var(--ink-dim); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 16px 14px; position: relative; overflow: hidden;
  animation: rise .45s cubic-bezier(.2,.7,.2,1) both;
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line);
}
.stat.accent::after { background: var(--accent); }
.stat .num { font-family: var(--display); font-weight: 900; font-size: 30px; line-height: 1; letter-spacing: -1px; }
.stat.accent .num { color: var(--accent); }
.stat .lbl { font-size: 10px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 1px; margin-top: 9px; }
.stat .sub { font-size: 11px; color: var(--ink-faint); margin-top: 3px; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.s-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--accent); font-weight: 600; }
#search { width: 100%; padding-left: 30px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--bg-card); color: var(--ink-dim); border: 1px solid var(--line);
  padding: 8px 13px; border-radius: 999px; font-size: 12px; transition: .15s; white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: var(--ink-dim); }
.chip.active { background: var(--accent); color: #0E0E11; border-color: var(--accent); font-weight: 600; }

/* table */
.table-wrap {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: var(--bg-card);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--ink-dim); padding: 13px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg-soft); font-weight: 500; white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sorted::after { content: " " attr(data-arrow); color: var(--accent); }
th.wide { width: 40%; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255,255,255,0.018); }
.col-date { color: var(--ink-dim); font-size: 12px; white-space: nowrap; }
.col-title { color: var(--ink); font-family: var(--display); font-weight: 500; font-size: 14px; }
.col-title .slug { display: block; color: var(--ink-faint); font-family: var(--mono); font-size: 10px; margin-top: 3px; font-weight: 400; }

/* status badge */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 4px 9px; border-radius: 6px; white-space: nowrap; border: 1px solid transparent; }
.badge.unused { color: var(--ink-faint); background: var(--bg-soft); border-color: var(--line); }
.badge.rendered { color: var(--amber); background: rgba(242,193,78,0.08); border-color: rgba(242,193,78,0.25); }
.badge.published { color: var(--green); background: rgba(111,227,154,0.08); border-color: rgba(111,227,154,0.28); }

/* format cell + per-platform chips */
.fmt { display: flex; flex-direction: column; gap: 5px; }
.fmt .none { color: var(--ink-faint); font-size: 12px; }
.fmt .count { font-size: 11px; color: var(--ink-dim); }
.plats { display: flex; gap: 5px; flex-wrap: wrap; }
.pchip {
  font-size: 9px; padding: 2px 6px; border-radius: 5px; letter-spacing: 0.5px;
  border: 1px solid var(--line); color: var(--ink-faint); background: var(--bg-soft);
  text-transform: uppercase;
}
.pchip.published, .pchip.posted { color: var(--green); border-color: rgba(111,227,154,0.35); background: rgba(111,227,154,0.07); }
.pchip.ready, .pchip.scheduled, .pchip.rendered { color: var(--amber); border-color: rgba(242,193,78,0.3); background: rgba(242,193,78,0.06); }

/* footer */
.botbar { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; font-size: 11px; color: var(--ink-dim); flex-wrap: wrap; }
.muted { color: var(--ink-faint); }
.empty { padding: 40px; text-align: center; color: var(--ink-faint); font-size: 13px; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---- lead + new table layout (redesign) ---- */
.lead { color: var(--ink-dim); font-size: 13px; line-height: 1.5; margin: -6px 0 18px; max-width: 760px; }
.lead strong { color: var(--ink); font-weight: 600; }

/* período (de/até) */
.daterange { display: flex; align-items: center; gap: 8px; color: var(--ink-dim); font-size: 12px; }
.dr-lbl { text-transform: uppercase; letter-spacing: 1px; font-size: 10px; color: var(--ink-faint); }
.dr-sep { color: var(--ink-faint); }
.daterange input[type="date"] {
  color-scheme: dark;
  background: var(--bg-card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; font-family: var(--mono); font-size: 12px;
}
.daterange input[type="date"]:focus { border-color: var(--accent); outline: none; }
.dr-clear { padding: 5px 9px; line-height: 1; font-size: 12px; }

.c-date { width: 104px; }
.c-status { width: 132px; }
.c-used { width: 24%; }
.c-pub { width: 168px; }

.col-ep { color: var(--ink); }
.ep-link {
  background: none; border: none; padding: 0; text-align: left; cursor: pointer;
  color: var(--ink); font-family: var(--display); font-weight: 500; font-size: 14px;
  line-height: 1.35; transition: color .12s;
}
.ep-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.col-ep .slug { display: block; color: var(--ink-faint); font-family: var(--mono); font-size: 10px; margin-top: 3px; }
.ep-row.open { background: rgba(232,255,82,0.04); }
.col-used { color: var(--ink-dim); font-size: 12px; }
.col-used .none, .col-pub .none { color: var(--ink-faint); }

/* publish badges (publicado em) */
.col-pub { display: flex; flex-wrap: wrap; gap: 5px; }
.pub {
  font-size: 10px; padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  border: 1px solid var(--line); color: var(--ink-faint); background: var(--bg-soft);
  text-decoration: none; display: inline-block;
}
a.pub:hover { filter: brightness(1.25); }
.pub.ok { color: var(--green); border-color: rgba(111,227,154,0.35); background: rgba(111,227,154,0.08); }
.pub.queued { color: var(--ink-dim); border-color: var(--line); }
.pub.sched { color: var(--amber); border-color: rgba(242,193,78,0.3); background: rgba(242,193,78,0.06); }

/* subtotal (por dia) */
tr.subtotal td { background: var(--bg-soft); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
tr.subtotal { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); }
tr.subtotal .col-date { color: var(--accent); }
tr.subtotal:hover { background: none; }

/* detail (expand) */
tr.detail-row td { padding: 0 16px 14px; border-bottom: 1px solid var(--line-soft); }
.detail-box { display: flex; flex-direction: column; gap: 7px; padding: 10px 14px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; }
.ditem { display: flex; gap: 10px; align-items: baseline; font-size: 12px; color: var(--ink-dim); flex-wrap: wrap; }
.ditem .dname { color: var(--ink); min-width: 150px; }
.ditem a, .detail-box a { color: var(--accent); text-decoration: none; }
.ditem a:hover { text-decoration: underline; }

/* responsive */
@media (max-width: 720px) {
  thead th.c-status, tbody td:nth-child(3) { display: none; }   /* status fica implícito em "publicado em" */
  .c-used { width: auto; }
  .controls { flex-direction: column; align-items: stretch; }
  .search-wrap { max-width: none; }
}
