/* Dematech Marketing Command Centre — responsive dashboard styles.
   No external fonts, no CDN, no inline styles: the page works offline and under
   the application's strict Content-Security-Policy. */

:root {
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #ffffff;
  --canvas: #f2f5fa;
  --sidebar: #0b1220;
  --sidebar-ink: #c7d2e3;
  --sidebar-active: #18233a;
  --accent: #0e7c86;
  --accent-strong: #0a5f67;
  --accent-soft: #e0f2f3;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --warning: #8a5a00;
  --warning-soft: #fff4d6;
  --ok: #166534;
  --ok-soft: #e6f4ea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
  --sidebar-width: 264px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.35rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }

a { color: var(--accent-strong); }

.muted { color: var(--muted); }
.small { font-size: .8rem; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: .5rem .75rem;
  z-index: 100;
}
.skip-link:focus { left: .5rem; top: .5rem; }

/* ---------- Authentication page ---------- */

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 15% -10%, #123047 0%, transparent 60%),
    radial-gradient(700px 420px at 110% 110%, #0e4d55 0%, transparent 55%),
    #0b1220;
}

.auth-shell { width: 100%; max-width: 430px; }

.auth-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 24px 70px rgba(2, 8, 20, .45);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0e7c86, #0b3b52);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .04em;
  flex: none;
}

.brand-name { font-weight: 700; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-size: .78rem; }

.auth-card h1 { margin-bottom: .35rem; }
.auth-card .muted { margin-bottom: 1.5rem; font-size: .9rem; }

.stack { display: grid; gap: 1rem; }

.field { display: grid; gap: .35rem; font-size: .85rem; font-weight: 600; }
.field input, .field select {
  font: inherit;
  font-weight: 400;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field select:focus, .btn:focus-visible, .nav a:focus-visible {
  outline: 3px solid rgba(14, 124, 134, .35);
  outline-offset: 1px;
  border-color: var(--accent);
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 10px;
  padding: .6rem .75rem;
  font-size: .85rem;
}

.auth-foot { margin-top: 1.5rem; color: var(--muted); font-size: .75rem; text-align: center; }

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

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: .62rem 1rem;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { border-color: var(--line); }
.btn-ghost:hover { background: #f8fafc; }
.btn-block { width: 100%; }
.btn-small { padding: .35rem .65rem; font-size: .8rem; }

.icon-btn {
  border: 0;
  background: transparent;
  color: inherit;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.15rem;
}
.icon-btn:hover { background: rgba(148, 163, 184, .18); }

/* ---------- App shell ---------- */

.app-body { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex: none;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1.1rem 1rem .9rem;
}
.sidebar-title { flex: 1; }
.sidebar .brand-name { color: #fff; font-size: .95rem; }
.sidebar .brand-sub { color: #8fa3c0; }
.sidebar-close { display: none; color: var(--sidebar-ink); }

.nav { display: grid; gap: 2px; padding: .4rem .6rem; overflow-y: auto; flex: 1; }

.nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .7rem;
  border-radius: 10px;
  color: var(--sidebar-ink);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
}
.nav a svg { flex: none; opacity: .85; }
.nav a:hover { background: rgba(148, 163, 184, .12); color: #fff; }
.nav a[aria-current="page"] {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-foot { padding: .8rem; border-top: 1px solid rgba(148, 163, 184, .16); display: grid; gap: .45rem; }
.user-chip { display: flex; align-items: center; gap: .6rem; }
.user-meta { display: grid; flex: 1; line-height: 1.25; min-width: 0; }
.user-meta span:first-child { color: #fff; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .icon-btn { color: var(--sidebar-ink); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #1d3149; color: #fff; display: inline-grid; place-items: center;
  font-size: .78rem; font-weight: 700; flex: none;
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.5rem;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.15rem; }
.topbar-actions { display: flex; align-items: center; gap: .8rem; }

.brand-select { display: flex; align-items: center; gap: .5rem; }
.brand-select select {
  font: inherit;
  font-size: .85rem;
  padding: .45rem .6rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  max-width: 230px;
}

.tz-pill {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: .25rem .55rem;
}

.menu-btn { display: none; }

.content { padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; }

.loading { color: var(--muted); padding: 2rem 0; }

/* ---------- Cards & grids ---------- */

.grid { display: grid; gap: 1rem; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.card-head p { color: var(--muted); font-size: .8rem; }

.kpi-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; margin-top: .35rem; }
.kpi-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.kpi-foot { color: var(--muted); font-size: .78rem; margin-top: .35rem; }

.section { margin-top: 1.2rem; }
.section:first-child { margin-top: 0; }

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

.table-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
caption { text-align: left; color: var(--muted); font-size: .8rem; padding-bottom: .5rem; }
th, td { text-align: left; padding: .6rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: .78rem; }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Chips & states ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 999px;
  padding: .18rem .55rem;
  background: #eef2f7;
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warning-soft); color: var(--warning); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--accent-soft); color: var(--accent-strong); }

.dot { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; display: inline-block; }

.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink-soft); margin-bottom: .25rem; }

.alert {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f3c3bd;
  border-radius: 10px;
  padding: .7rem .9rem;
  margin-bottom: 1rem;
  font-size: .88rem;
}
.alert-info { background: var(--accent-soft); color: var(--accent-strong); border-color: #bfe3e6; }

.tag-list { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ---------- Settings ---------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; }
.form-grid .field input, .form-grid .field select { width: 100%; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .4rem; }
.check { display: flex; align-items: center; gap: .45rem; font-size: .85rem; font-weight: 500; }

.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .8rem; }
.role-card { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; }
.role-card h3 { text-transform: capitalize; }
.role-card p { color: var(--muted); font-size: .8rem; margin: .2rem 0 .5rem; }

/* ---------- Mobile ---------- */

.scrim { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 8; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 9;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 0 20px 60px rgba(2, 8, 20, .5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-grid; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: .7rem 1rem; }
  .content { padding: 1rem; }
  .brand-select span { display: none; }
  .brand-select select { max-width: 150px; }
}

@media (max-width: 560px) {
  .topbar-title h1 { font-size: 1rem; }
  .tz-pill { display: none; }
  .kpi-value { font-size: 1.45rem; }
  .auth-card { padding: 1.5rem; }
}

@media print {
  .sidebar, .topbar, .scrim { display: none; }
  .content { padding: 0; }
  .card { box-shadow: none; }
}

/* ---------- Section E: calendar views, campaign, content and approval controls ---------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.toolbar-tight { gap: .5rem; align-items: center; margin-top: .6rem; }
.field-inline { min-width: 180px; }
.field textarea,
.field input[type="datetime-local"],
.field input[type="date"],
.field input[type="number"],
.field input[type="text"] { width: 100%; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn {
  font: inherit; font-size: .8rem; padding: .4rem .7rem; border: 0;
  border-right: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer;
}
.seg-btn:last-child { border-right: 0; }
.seg-btn-on { background: var(--accent); color: #fff; }

.cal-months { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; }
.cal-month {
  display: flex; flex-direction: column; gap: .15rem; text-align: left; font: inherit;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .7rem; cursor: pointer;
}
.cal-month:hover { border-color: var(--accent); }
.cal-month-name { font-weight: 700; font-size: .9rem; }

.bucket { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .7rem; }
.bucket-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem; border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.bucket-head h3 { font-size: .95rem; margin: 0; }
.bucket-list { list-style: none; margin: .3rem 0 0; padding: 0; }
.bucket-item { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.bucket-item:last-child { border-bottom: 0; }
.bucket-item-campaign { background: linear-gradient(90deg, rgba(0, 159, 246, .08), transparent 70%); }

.deadline-pill {
  display: inline-block; min-width: 64px; text-align: center; font-size: .72rem; font-weight: 700;
  padding: .1rem .4rem; border-radius: 999px; background: var(--line); color: var(--muted);
}
.deadline-pill-overdue { background: var(--danger-soft); color: var(--danger); }

.pane-list { list-style: none; margin: 0; padding: 0; }
.pane-list li { display: flex; gap: .6rem; align-items: flex-start; padding: .4rem 0; border-bottom: 1px dashed var(--line); }
.pane-list li:last-child { border-bottom: 0; }

.diff {
  margin: .6rem 0 0; max-height: 320px; overflow: auto; background: #10161c; color: #e6edf3;
  border-radius: 8px; padding: .6rem .8rem; font-size: .76rem; line-height: 1.45;
  white-space: pre-wrap;
}
.diff-added { color: #7ee2a8; }
.diff-removed { color: #ff9a9a; }
.diff-context { color: #9fb0c0; }

.pipeline { display: flex; flex-wrap: wrap; gap: .25rem; margin: .5rem 0; }
.pipeline-step {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .04em;
  padding: .15rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.pipeline-step-on { background: var(--accent); border-color: var(--accent); color: #fff; }

.integrity-ok { background: var(--ok-soft); color: var(--ok); padding: .4rem .6rem; border-radius: 8px; font-size: .82rem; }
.integrity-bad { background: var(--danger-soft); color: var(--danger); padding: .4rem .6rem; border-radius: 8px; font-size: .82rem; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: #f0c2c4; }
