/* Click Legal Compliance Calendar */

:root {
  --bg:      #f5f4fa;
  --panel:   #ffffff;
  --ink:     #1a202c;
  --muted:   #646b7d;
  --line:    #e3e1ee;
  --navy:    #1a202c;   /* Click Legal top bar */
  --navy-2:  #232b3b;
  --brand:   #7d39d2;   /* Click Legal purple */
  --brand-d: #6529b3;
  --brand-l: #f1eafc;
  --pink:    #d877eb;
  --cyan:    #3bc4dc;
  --head:    #f0eef7;   /* table headers */
  --danger:  #b3261e;
  --radius:  4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Manrope", "Segoe UI", Arial, Helvetica, sans-serif;
}

h1, h2, h3 { margin: 0 0 .5em; font-weight: 700; letter-spacing: -.2px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
p  { margin: 0 0 .6em; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono  { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 12px; }
.right { text-align: right; white-space: nowrap; }
.hint  { color: var(--muted); font-size: 12px; margin-top: .4em; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
.btn:hover   { background: var(--brand-l); }
.btn:disabled{ opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-d); }
.btn.ghost   { background: transparent; }
.btn.small   { padding: 3px 8px; font-size: 12px; margin-left: 4px; }
.btn.danger  { color: var(--danger); border-color: #e7c6c4; }

/* -------------------------------------------------------------------- login */
body.auth {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(125, 57, 210, .45), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(216, 119, 235, .18), transparent 60%),
    var(--navy);
}
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-logo { width: 240px; height: auto; display: block; margin: 0 auto; }
.login-tag {
  color: #c9c3e6;
  margin: 8px 0 0;
  font-size: 13px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
}
.login {
  width: 100%;
  max-width: 400px;
  padding: 30px 30px 24px;
  border: 0;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.login h1 { font-size: 22px; margin-bottom: 6px; }
.login .alt { margin: 16px 0 0; text-align: center; font-size: 13px; }
.login a { color: var(--brand); text-decoration: none; font-weight: 600; }
.login a:hover { text-decoration: underline; }
.login-foot { color: #8a8fa3; font-size: 12px; margin-top: 22px; text-align: center; }
.code-input { font-size: 24px !important; letter-spacing: 8px; text-align: center; font-weight: 700; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(26, 32, 44, .06);
}
.card.pad { padding: 18px; margin-bottom: 20px; }
.login label { display: block; margin: 14px 0; font-weight: 600; }
.login input, .field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  background: #fff;
  color: var(--ink);
}
.login input:focus, .field input:focus, .field select:focus, .field textarea:focus,
.filters input:focus, .filters select:focus {
  outline: 2px solid rgba(125, 57, 210, .35);
  border-color: var(--brand);
}
.login .btn { width: 100%; margin-top: 8px; padding: 11px 12px; }
.err {
  background: #fdecea;
  border: 1px solid #f5c6c2;
  color: var(--danger);
  padding: 8px 10px;
  border-radius: var(--radius);
  margin-bottom: 10px;
}

/* ------------------------------------------------------------------- topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: var(--navy);
  color: #fff;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 3px solid var(--brand);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.brand img { height: 26px; width: auto; display: block; }
.brand-sub {
  font-size: 11px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: #c9c3e6;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, .25);
}
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.tab {
  background: transparent;
  border: 0;
  color: #e3e1ee;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
}
.tab:hover  { background: rgba(255, 255, 255, .08); color: #fff; }
.tab.active { background: var(--brand); color: #fff; font-weight: 600; }
.who { display: flex; align-items: center; gap: 8px; }
.who .btn, .who select {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff;
  font: inherit;
  font-size: 13px;
  padding: 5px 9px;
  border-radius: var(--radius);
}
.who .btn:hover { background: rgba(255, 255, 255, .1); border-color: #fff; }
.who select option { color: var(--ink); }
#clientPick { max-width: 200px; border-color: var(--brand); background: rgba(125, 57, 210, .25); }
.client-name {
  font-weight: 700;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--radius);
  background: rgba(125, 57, 210, .3);
  white-space: nowrap;
}
.uname { font-size: 13px; white-space: nowrap; }
.uname small { display: block; color: #c9c3e6; font-size: 11px; }

.scope-bar {
  background: var(--brand-l);
  border-bottom: 1px solid #ddd0f5;
  color: #4a2a80;
  padding: 7px 18px;
  font-size: 12.5px;
}
.scope-bar.template { background: #fff7e0; border-color: #f0e0b0; color: #6d5410; }

main { padding: 16px; }
main.loading { color: var(--muted); }

/* ------------------------------------------------------------------ filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.filters input, .filters select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  background: #fff;
  max-width: 260px;
}
.filters input[type=search] { min-width: 220px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 10px; font-size: 12px; }
.legend-label { font-weight: 600; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border: 1px solid var(--line); border-radius: 3px; display: inline-block; }

/* -------------------------------------------------------------- spreadsheet */
.sheet-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  max-height: calc(100vh - 210px);
}
table.sheet { border-collapse: collapse; width: 100%; font-size: 12px; }
table.sheet th {
  position: sticky;
  top: 0;
  background: var(--head);
  border: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  font-size: 11px;
  letter-spacing: .3px;
  z-index: 2;
  white-space: nowrap;
}
table.sheet td {
  border: 1px solid var(--line);
  padding: 6px;
  vertical-align: top;
  max-width: 230px;
}
table.sheet tbody tr:nth-child(even) { background: #fafbfd; }
table.sheet tbody tr:hover { background: #f6f1fd; }
td.clip span {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
td.c-no, th.c-no { width: 38px; text-align: center; }
td.c-m,  th.c-m  { width: 30px; text-align: center; padding: 4px 2px; }
td.c-m.due { font-weight: 700; cursor: pointer; background: #f0eef7; }
td.c-m.due:hover { outline: 2px solid var(--brand); outline-offset: -2px; }
.count { margin: 8px; }

/* ----------------------------------------------------------------- calendar */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.cal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.cal-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--head);
  border-bottom: 1px solid var(--line);
}
.cal-card h3 { margin: 0; }
.pill {
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
}
.cal-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }
.cal-item {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #eef1f6;
  cursor: pointer;
}
.cal-item:hover { background: #f6f1fd; }
.cal-item .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; border: 1px solid var(--line); }
.cal-item strong { display: block; font-size: 13px; }
.cal-item .sub { display: block; color: var(--muted); font-size: 11.5px; }
.cal-item .officer { color: var(--brand); }
.cal-empty { padding: 14px 12px; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------- drawer */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-bg { position: absolute; inset: 0; background: rgba(26, 32, 44, .45); }
.drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(620px, 100%);
  background: var(--panel);
  box-shadow: -3px 0 18px rgba(15, 23, 35, .18);
  overflow: auto;
  padding: 22px 24px 40px;
}
.drawer-x {
  position: absolute;
  top: 10px; right: 14px;
  border: 0; background: transparent;
  font-size: 26px; line-height: 1;
  color: var(--muted); cursor: pointer;
}
body.drawer-open { overflow: hidden; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 4px; }
.field .value { white-space: pre-wrap; margin: 0; }
.field textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.inline-check { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.inline-check input { width: auto; }
.row-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

.month-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  border: 1px solid var(--line);
  background: #f6f8fb;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  color: #9aa4b2;
  cursor: default;
}
.chip.due { color: var(--ink); font-weight: 600; cursor: pointer; }
.chip.due:hover { border-color: var(--brand); }

.month-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.mcheck {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  background: #fff;
  font-size: 12px;
}
.mcheck input { width: auto; }

.lk-row { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.lk-row select { flex: 1 1 320px; padding: 7px 8px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; }
.lk-preview { flex: 1 1 100%; margin: 4px 0 0; font-size: 12px; color: var(--muted); white-space: pre-wrap; max-height: 120px; overflow: auto; }
.lk-preview p { margin: 0 0 4px; }

/* -------------------------------------------------------- reference links */
a.ext { color: var(--brand); text-decoration: none; font-weight: 600; overflow-wrap: anywhere; }
a.ext:hover { text-decoration: underline; }
a.ext::after { content: " \2197"; font-size: .85em; }
ul.ref-links { margin: 6px 0 0; padding-left: 18px; white-space: normal; }
ul.ref-links li { margin: 2px 0; }
.ref-links.compact { display: flex; flex-direction: column; gap: 1px; margin-top: 4px; font-size: 11px; }
.ref-links.compact a.ext { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; display: block; }
p.muted + .bar, table.grid + p.muted + .bar { margin-top: 28px; }
.mono-ish { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 12.5px; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; }
.tag.admin { background: var(--brand-l); color: var(--brand-d); }

/* -------------------------------------------------------------- admin grids */
.bar { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.subtabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.subtab { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 4px 12px; cursor: pointer; font: inherit; font-size: 12px; }
.subtab.active { background: var(--brand); border-color: var(--brand); color: #fff; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 18px;
}
table.grid th {
  background: var(--head);
  text-align: left;
  padding: 8px 10px;
  font-size: 11.5px;
  letter-spacing: .3px;
  border-bottom: 1px solid var(--line);
}
table.grid td { padding: 8px 10px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
table.grid td.wrap { white-space: pre-wrap; max-width: 620px; }
table.grid tr.muted-row td { color: var(--muted); font-style: italic; }
th.c-sort { width: 60px; }
th.c-used { width: 90px; }

/* -------------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  z-index: 80;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}
.toast.error { background: var(--danger); }

@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 14px; gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
}
@media (max-width: 760px) {
  .who { width: 100%; justify-content: flex-start; }
  .brand-sub { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .sheet-wrap { max-height: none; }
}
