/* ==========================================================================
   OttenSocial - folha de estilos principal
   Cores da marca (--c-header, --c-primary, --c-accent, --c-rail) são
   injetadas pelo layout a partir de Administração > Personalização.
   ========================================================================== */

:root {
  --c-header: #1f4e84;
  --c-primary: #1a73e8;
  --c-accent: #f5871f;
  --c-rail: #f4f5f7;

  --bg: #e9ecf0;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eef1f4;
  --border: #dde1e6;
  --border-strong: #c7cdd4;
  --text: #25303b;
  --text-2: #5b6772;
  --text-3: #8a949d;
  --rail-text: #2b333b;
  --rail-hover: #e3e6ea;
  --rail-active: #d5dae0;
  --flyout: #eaecef;
  --input-bg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-pop: 0 8px 28px rgba(16, 24, 40, .18);
  --ok: #2e7d4f;
  --ok-bg: #e7f4ec;
  --warn: #9a5b00;
  --warn-bg: #fff4e0;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --info-bg: #e8f1fd;

  --header-h: 52px;
  --rail-w: 64px;
  --rail-w-open: 200px;
  --flyout-w: 272px;
  --radius: 4px;
  --font: "Segoe UI", Roboto, "Helvetica Neue", Verdana, Arial, sans-serif;

  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #14181d;
  --surface: #1c2229;
  --surface-2: #222a32;
  --surface-3: #28313a;
  --border: #313b46;
  --border-strong: #3e4a56;
  --text: #e3e8ed;
  --text-2: #a8b3bd;
  --text-3: #7c8893;
  --c-rail: #181d23;
  --rail-text: #d3dae0;
  --rail-hover: #242c35;
  --rail-active: #2d3741;
  --flyout: #1f262e;
  --input-bg: #161b21;
  --ok-bg: #173325;
  --warn-bg: #3a2a10;
  --danger-bg: #3d1c19;
  --info-bg: #172a42;
  --ok: #6fcf97;
  --warn: #f2c14e;
  --danger: #ff8a7a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-pop: 0 8px 28px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #14181d; --surface: #1c2229; --surface-2: #222a32; --surface-3: #28313a;
    --border: #313b46; --border-strong: #3e4a56; --text: #e3e8ed; --text-2: #a8b3bd; --text-3: #7c8893;
    --c-rail: #181d23; --rail-text: #d3dae0; --rail-hover: #242c35; --rail-active: #2d3741; --flyout: #1f262e;
    --input-bg: #161b21; --ok-bg: #173325; --warn-bg: #3a2a10; --danger-bg: #3d1c19; --info-bg: #172a42;
    --ok: #6fcf97; --warn: #f2c14e; --danger: #ff8a7a;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-pop: 0 8px 28px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* Tamanho da letra escolhido pelo usuário (acessibilidade) */
html.fs-grande body { font-size: 14.5px; }
html.fs-maior body { font-size: 16px; }
html.fs-grande .table, html.fs-grande .input, html.fs-grande .btn { font-size: 13.5px; }
html.fs-maior .table, html.fs-maior .input, html.fs-maior .btn { font-size: 15px; }

/* ---------- Cabeçalho ---------- */
.hdr {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 6px;
  padding: 0 14px 0 6px;
  background: var(--c-header);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.12);
}
.hdr-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; min-width: 36px; padding: 0 8px;
  border: 0; border-radius: var(--radius); background: transparent; color: #fff; cursor: pointer;
  position: relative;
}
.hdr-btn:hover, .hdr-btn[aria-expanded="true"] { background: rgba(255,255,255,.14); text-decoration: none; }
.hdr-btn .ic { width: 21px; height: 21px; }
.hdr-burger .ic { width: 24px; height: 24px; }
.hdr-brand { display: flex; align-items: center; gap: 8px; color: #fff; padding: 0 10px 0 4px; margin-right: 18px; }
.hdr-brand:hover { text-decoration: none; }
.hdr-brand img { width: 30px; height: 30px; object-fit: contain; background: #fff; border-radius: 50%; padding: 2px; }
.hdr-brand b { display: block; font-size: 17px; font-weight: 700; letter-spacing: -.2px; line-height: 1.05; font-style: italic; }
.hdr-brand small { display: block; font-size: 8.5px; letter-spacing: .6px; text-transform: uppercase; opacity: .85; }
.hdr-menus { display: flex; gap: 14px; }
.hdr-menus .hdr-btn { font-size: 13px; padding: 0 10px; }
.hdr-menus .hdr-btn .ic { width: 16px; height: 16px; }
.hdr-spacer { flex: 1; }
.hdr-actions { display: flex; align-items: center; gap: 4px; }
.badge {
  position: absolute; top: 1px; right: -2px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: #dd5a43; color: #fff; font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
}
.hdr-user { gap: 10px; padding: 0 6px 0 10px; margin-left: 8px; height: 44px; }
.hdr-user .avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; letter-spacing: .3px;
}
.hdr-user .avatar-img { object-fit: cover; padding: 0; background: #fff; }
.hdr-user .who { text-align: left; line-height: 1.15; }
.hdr-user .who b { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-user .who small { display: block; font-size: 11px; opacity: .85; }

/* dropdowns do cabeçalho */
.dd { position: relative; }
.dd-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  min-width: 260px; max-height: 70vh; overflow: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop);
  padding: 6px 0;
}
.dd-panel.right { left: auto; right: 0; }
.dd-panel h6 { margin: 8px 14px 4px; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.dd-panel a, .dd-panel button.dd-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 14px; border: 0; background: none; text-align: left; cursor: pointer;
  color: var(--text); font-size: 13px;
}
.dd-panel a:hover, .dd-panel button.dd-item:hover, .dd-panel a.active { background: var(--surface-3); text-decoration: none; }
.dd-panel .ic { width: 16px; height: 16px; color: var(--text-2); }
.dd-panel hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.dd-panel .dd-search { padding: 6px 10px 8px; }
.dd-panel .empty { padding: 10px 14px; color: var(--text-3); }
.dd-user-card { padding: 10px 14px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dd-user-card b { display: block; font-size: 14px; }
.dd-user-card span { display: block; color: var(--text-2); font-size: 12px; }

/* ---------- Trilho lateral ---------- */
.rail {
  position: fixed; top: var(--header-h); bottom: 0; left: 0; z-index: 30;
  width: var(--rail-w);
  background: var(--c-rail);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width .18s ease;
  overflow: hidden;
}
.rail-system {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 6px 10px; color: var(--rail-text); text-align: center;
}
.rail-system .sys-icon {
  width: 38px; height: 38px; border-radius: 8px; border: 1.5px solid var(--rail-text);
  display: grid; place-items: center; position: relative; background: var(--surface);
}
.rail-system .sys-icon img { width: 28px; height: 28px; object-fit: contain; }
.rail-system .sys-icon em {
  position: absolute; right: -8px; bottom: -6px; font-style: normal;
  background: var(--c-header); color: #fff; font-size: 8px; font-weight: 700; padding: 1px 3px; border-radius: 3px;
}
.rail-system span { font-size: 11px; display: none; }
.rail-nav { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 4px 0; scrollbar-width: none; -ms-overflow-style: none; }
.rail-nav::-webkit-scrollbar { display: none; }

body.preload *, body.preload *::before, body.preload *::after { transition: none !important; }
.rail-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; height: 50px; padding: 0 20px;
  border: 0; background: none; cursor: pointer; color: var(--rail-text);
  font-size: 12px; text-align: left; white-space: nowrap;
}
.rail-item .ic { width: 23px; height: 23px; stroke-width: 1.6; }
.rail-item span { opacity: 0; transition: opacity .12s; }
.rail-item:hover { background: var(--rail-hover); text-decoration: none; }
.rail-item { position: relative; }
/* Área da tela atual: barra à esquerda. Área aberta no menu: fundo destacado. */
.rail-item.current::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c-header); }
.rail-item.current { color: var(--c-header); }
html[data-theme="dark"] .rail-item.current { color: #8fb6e8; }
html[data-theme="dark"] .rail-item.current::before { background: #8fb6e8; }
.rail-item[aria-expanded="true"] { background: var(--rail-active); }
.rail-foot { padding: 10px 6px 12px; text-align: center; color: var(--text-2); font-size: 10.5px; line-height: 1.3; }
.rail-foot img { width: 40px; height: 48px; object-fit: contain; display: block; margin: 0 auto 4px; }
.rail-foot span { display: none; }

body.rail-open .rail { width: var(--rail-w-open); }
body.rail-open .rail-item span { opacity: 1; }
body.rail-open .rail-system span, body.rail-open .rail-foot span { display: block; }

/* painel flutuante (submenu com busca) */
.flyout {
  position: fixed; top: var(--header-h); bottom: 0; z-index: 29;
  left: var(--rail-w); width: var(--flyout-w);
  background: var(--flyout); border-right: 1px solid var(--border);
  box-shadow: 6px 0 18px rgba(0,0,0,.08);
  display: flex; flex-direction: column;
  transition: left .18s ease;
}
body.rail-open .flyout { left: var(--rail-w-open); }
.flyout-head { padding: 12px 10px 8px; }
.flyout-back { display: none; }
.flyout-body { flex: 1; overflow-y: auto; padding-bottom: 20px; }
.flyout-group { border-bottom: 1px solid var(--border-strong); padding: 8px 0 10px; }
.flyout-group:last-child { border-bottom: 0; }
.flyout-group h4 { margin: 4px 14px 6px; font-size: 13.5px; font-weight: 600; color: var(--text); }
.flyout-link {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 14px 4px 22px; color: var(--text); font-size: 12px;
}
.flyout-link:hover { background: rgba(0,0,0,.05); text-decoration: none; }
html[data-theme="dark"] .flyout-link:hover { background: rgba(255,255,255,.06); }
.flyout-link .ic { width: 14px; height: 14px; color: #b0473f; }
.flyout-link.soon { color: var(--text-2); }
.flyout-link.soon .ic { color: var(--text-3); }
.flyout-link mark { background: #ffff99; color: #333; padding: 0; }
.flyout-empty { padding: 16px; color: var(--text-3); }

/* ---------- Área de trabalho ---------- */
.main {
  margin-left: var(--rail-w);
  padding: calc(var(--header-h) + 14px) 22px 40px;
  min-height: 100vh;
  transition: margin-left .18s ease;
}
body.rail-open .main { margin-left: var(--rail-w-open); }
.page-title {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 2px 0 16px; font-size: 22px; font-weight: 500; color: var(--text);
}
.page-title .ic { width: 22px; height: 22px; color: var(--text); }
.page-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.page-head h1 { margin: 0; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.page-head h1 .ic { color: var(--c-header); }
.page-head .crumbs { color: var(--text-3); font-size: 12px; }
.page-head .grow { flex: 1; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* portlets (blocos do painel) */
.portlets { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.portlet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.portlet.span-2 { grid-column: span 2; }
.pt-head { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-bottom: 1px solid var(--border); }
.pt-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-title .ic { width: 15px; height: 15px; color: var(--text-2); }
.pt-title em { font-style: normal; font-weight: 400; color: var(--text-2); }
.pt-tools { display: flex; gap: 2px; }
.pt-tools .icon-btn .ic { width: 15px; height: 15px; }
.pt-body { padding: 12px 14px; }
.portlet.collapsed .pt-body { display: none; }
.portlet.collapsed .pt-collapse .ic { transform: rotate(180deg); }

/* painéis de formulário estilo "fieldset" */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; box-shadow: var(--shadow); }
.panel > h2, .panel-title {
  margin: 0; padding: 8px 14px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-3); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; gap: 8px;
}
.panel > h2 .ic { width: 15px; height: 15px; color: var(--text-2); }
.panel-body { padding: 14px; }
.panel-foot { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- Formulários ---------- */
.grid { display: grid; gap: 12px 14px; grid-template-columns: repeat(12, 1fr); }
.col-1 { grid-column: span 1; } .col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-9 { grid-column: span 9; } .col-10 { grid-column: span 10; } .col-11 { grid-column: span 11; } .col-12 { grid-column: span 12; }
.field label, .label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.field .req { color: var(--danger); }
.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.field .error, .error-text { font-size: 12px; color: var(--danger); margin-top: 3px; }
.input, select.input, textarea.input {
  width: 100%; height: 32px; padding: 5px 9px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--input-bg); color: var(--text); font: inherit; font-size: 13px;
}
textarea.input { height: auto; min-height: 72px; resize: vertical; }
.input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 20%, transparent); }
.input.is-invalid { border-color: var(--danger); }
.input-sm { height: 28px; font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; }
.check input { width: 15px; height: 15px; accent-color: var(--c-primary); }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type=color] { width: 42px; height: 32px; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 2px; background: var(--input-bg); cursor: pointer; }
.color-field .input { width: 110px; font-family: ui-monospace, Consolas, monospace; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--c-primary) 85%, #000); }
.btn-success { background: #2e7d4f; border-color: #2e7d4f; color: #fff; }
.btn-success:hover { background: #256641; }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { height: 27px; padding: 0 10px; font-size: 12px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border: 0; border-radius: var(--radius); background: none; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.icon-btn.danger:hover { color: var(--danger); }
.inline { display: inline; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--text-2);
  background: var(--surface-3); border-bottom: 1px solid var(--border-strong);
  padding: 7px 10px; white-space: nowrap;
}
.table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:nth-child(even) td { background: var(--surface-2); }
.table tbody tr:hover td { background: color-mix(in srgb, var(--c-primary) 7%, var(--surface)); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .muted, .muted { color: var(--text-3); }
.table-empty { padding: 34px 10px; text-align: center; color: var(--text-3); }

.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.danger { background: var(--danger-bg); color: var(--danger); }
.tag.info { background: var(--info-bg); color: var(--c-primary); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filters .field { min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 220px; }

/* paginação */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.pager nav { display: flex; gap: 3px; flex-wrap: wrap; max-width: 100%; }
.pager a, .pager span.pg { min-width: 28px; height: 28px; padding: 0 8px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--surface); }
.pager a:hover { background: var(--surface-3); text-decoration: none; }
.pager span.pg.current { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.pager span.pg.disabled { color: var(--text-3); }

/* alertas */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid transparent; font-size: 13px; }
.alert .ic { margin-top: 1px; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-info { background: var(--info-bg); color: var(--text); border-color: color-mix(in srgb, var(--c-primary) 25%, transparent); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 16px; font-weight: 700; letter-spacing: 1px; background: var(--surface); color: var(--text); padding: 2px 10px; border-radius: 3px; border: 1px dashed var(--border-strong); user-select: all; }

/* ---------- Painel (dashboard) ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { display: block; color: inherit; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); }
a.kpi:hover { border-color: var(--c-primary); text-decoration: none; }
.kpi small { display: block; font-size: 11.5px; color: var(--text-2); }
.kpi b { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi.alert-kpi b { color: var(--danger); }

.cal-head { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; }
.cal-head strong { min-width: 150px; text-align: center; font-weight: 600; }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { font-size: 11px; font-weight: 600; color: var(--text-2); padding: 4px 0; border-bottom: 1px solid var(--border); }
.cal td { height: 38px; border: 1px solid var(--border); text-align: right; vertical-align: top; padding: 3px 6px; font-size: 12px; color: var(--text); position: relative; }
.cal td.out { color: var(--text-3); background: var(--surface-2); }
.cal td.today { font-weight: 700; }
.cal td.today span { background: var(--c-primary); color: #fff; border-radius: 10px; padding: 1px 6px; }
.cal td.has-task::after { content: ""; position: absolute; left: 6px; bottom: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--c-accent); }

.task-form { display: flex; gap: 6px; margin-bottom: 10px; }
.task-form .input:first-child { flex: 1; }
.task-form input[type=date] { width: 140px; }
.task-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); max-height: 290px; overflow-y: auto; }
.task-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.task-list li:last-child { border-bottom: 0; }
.task-list li.done .desc { text-decoration: line-through; color: var(--text-3); }
.task-list .desc { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task-list .due { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.task-list .due.late { color: var(--danger); font-weight: 600; }
.task-empty { display: grid; place-items: center; min-height: 160px; color: var(--text-3); font-size: 14px; }
.check-btn { width: 18px; height: 18px; border: 1.5px solid var(--border-strong); border-radius: 3px; background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0; }
.check-btn .ic { width: 13px; height: 13px; color: #fff; }
li.done .check-btn { background: var(--ok); border-color: var(--ok); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 36px; gap: 8px; align-items: center; font-size: 12px; }
.bar-track { display: block; height: 12px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--c-header); border-radius: 2px; }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.mini-list li:last-child { border-bottom: 0; }

/* página em desenvolvimento */
.pending-box { max-width: 640px; margin: 40px auto; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px 30px; box-shadow: var(--shadow); }
.pending-box .ic { width: 40px; height: 40px; color: var(--c-accent); }
.pending-box h2 { margin: 12px 0 6px; font-size: 18px; }
.pending-box p { color: var(--text-2); margin: 0 0 18px; }

/* personalização */
.brand-images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.brand-image { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.brand-image .tag { align-self: flex-start; }
.brand-image .preview { height: 110px; display: grid; place-items: center; background: repeating-conic-gradient(var(--surface-3) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; border-radius: 3px; border: 1px solid var(--border); }
.brand-image .preview img { max-height: 96px; max-width: 90%; object-fit: contain; }
.bg-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.bg-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.bg-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.bg-card.inactive img { filter: grayscale(1) opacity(.55); }
.bg-card form { padding: 10px; display: grid; gap: 8px; }
.bg-card .row { display: flex; gap: 8px; align-items: center; }
.preview-header { height: 40px; border-radius: 3px; display: flex; align-items: center; gap: 8px; padding: 0 12px; color: #fff; font-weight: 700; font-style: italic; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.swatch { width: 22px; height: 22px; border-radius: 3px; border: 1px solid var(--border-strong); cursor: pointer; padding: 0; }

/* matriz de permissões */
.perm-table td, .perm-table th { text-align: center; }
.perm-col { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; font-weight: 600; }
.perm-table input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--c-primary); cursor: pointer; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.role-block { scroll-margin-top: 70px; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; position: relative; overflow-x: hidden; color: #fff; background: #1b2a3a; display: flex; flex-direction: column; }
.login-bg { position: fixed; inset: 0; }
.login-bg figure { position: absolute; inset: 0; margin: 0; opacity: 0; transition: opacity 1.2s ease; }
.login-bg figure.on { opacity: 1; }
.login-bg img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.04); transition: transform 7s linear; }
.login-bg figure.on img { transform: scale(1); }
.login-bg::after { content: ""; position: absolute; inset: 0; background: rgba(10, 18, 28, var(--login-overlay)); }
.login-top { position: relative; z-index: 2; flex: none; display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 22px 0; }
.login-brand { display: inline-flex; align-items: center; background: rgba(255,255,255,.92); border-radius: 6px; padding: 6px 12px; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.login-brand img { height: 42px; width: auto; display: block; }
.login-center { position: relative; z-index: 2; flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 16px 28px; }
.login-crest { background: #fff; padding: 6px 10px; border-radius: 3px; box-shadow: 0 2px 12px rgba(0,0,0,.3); }
.login-crest img { height: 92px; width: auto; display: block; }
.login-entity { margin: 14px 0 0; font-size: 19px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.login-entity-sub { font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; opacity: .92; text-shadow: 0 1px 3px rgba(0,0,0,.5); text-align: center; }
.login-card {
  width: 100%; max-width: 360px; margin-top: 18px;
  background: rgba(20, 28, 38, .5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.1); border-radius: 4px; padding: 26px 26px 18px;
}
.login-card h1 { margin: 0 0 4px; font-size: 15px; font-weight: 600; text-align: center; }
.login-card .lead { margin: 0 0 16px; font-size: 12px; text-align: center; opacity: .85; }
.login-field { position: relative; margin-bottom: 14px; }
.login-field .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #5d6b78; width: 17px; height: 17px; pointer-events: none; }
.login-input {
  width: 100%; height: 44px; padding: 0 44px 0 38px;
  border: 1px solid transparent; border-radius: 4px; background: #e8f0fe; color: #1d2733;
  font: inherit; font-size: 14px;
}
.login-input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
.login-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: none; color: #1d2733; cursor: pointer; display: grid; place-items: center; border-radius: 3px; }
.login-eye .ic { position: static; transform: none; color: #1d2733; width: 20px; height: 20px; }
.login-submit { width: 100%; height: 42px; border: 0; border-radius: 4px; background: #11a8e8; background: var(--c-primary); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 4px; }
.login-submit:hover { filter: brightness(1.08); }
.login-links { display: flex; justify-content: flex-end; margin-top: 14px; font-size: 12px; }
.login-links a { color: #fff; font-weight: 600; }
.login-msg { font-size: 12.5px; padding: 9px 11px; border-radius: 4px; margin-bottom: 14px; display: flex; gap: 8px; align-items: flex-start; }
.login-msg .ic { width: 16px; height: 16px; margin-top: 1px; }
.login-msg.err { background: rgba(192, 57, 43, .88); }
.login-msg.ok { background: rgba(46, 125, 79, .9); }
.login-foot { position: relative; z-index: 2; flex: none; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 14px 22px; font-size: 11.5px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.login-foot .caption { opacity: .85; }
.login-dots { display: flex; gap: 6px; }
.login-dots button { width: 9px; height: 9px; border-radius: 50%; border: 1px solid #fff; background: transparent; padding: 0; cursor: pointer; }
.login-dots button.on { background: #fff; }
.login-rules { font-size: 11.5px; opacity: .9; margin: -4px 0 12px; padding-left: 16px; }


/* ---------- Prontuário: abas, dados, linha do tempo ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-strong); margin: 0 0 14px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tabs a { padding: 9px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; color: var(--text-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.tabs a.on { background: var(--surface); border-color: var(--border-strong); color: var(--c-header); box-shadow: inset 0 -2px 0 var(--c-header); }
.tabs .count { background: var(--surface-3); color: var(--text-2); border-radius: 9px; padding: 0 6px; font-size: 10.5px; }
.data-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 18px; margin: 0; }
.data-grid div { min-width: 0; }
.data-grid dt { font-size: 11.5px; color: var(--text-3); margin-bottom: 1px; }
.data-grid dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.summary-bar { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; }
.summary-bar .big { font-size: 18px; font-weight: 600; }
.restricted { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-2); background: var(--surface-2); font-size: 12.5px; }
.restricted .ic { width: 16px; height: 16px; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.55; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 7px 0; }
.timeline .dot { width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); display: grid; place-items: center; z-index: 1; }
.timeline .dot .ic { width: 14px; height: 14px; color: var(--c-header); }
.timeline .when { font-size: 11.5px; color: var(--text-3); }
.timeline .what { font-weight: 600; font-size: 13px; }
.timeline .desc { font-size: 12.5px; color: var(--text-2); }
.timeline li.k-atendimento .dot { border-color: var(--c-primary); }
.timeline li.k-acompanhamento .dot { border-color: #7b61c9; }
.timeline li.k-encaminhamento .dot { border-color: var(--c-accent); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px 14px; }
.input-group { display: flex; gap: 6px; }
.input-group .input { flex: 1; }
.cep-status { font-size: 11.5px; margin-top: 3px; min-height: 16px; }
.cep-status.ok { color: var(--ok); } .cep-status.err { color: var(--danger); }
.pill-conf { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: #8a1c1c; background: #fde2e2; border-radius: 10px; padding: 1px 8px; }
html[data-theme="dark"] .pill-conf { color: #ffb4b4; background: #4a1f1f; }
.pill-conf .ic { width: 12px; height: 12px; }
.row-late td { background: color-mix(in srgb, var(--danger) 7%, var(--surface)) !important; }
.person-card { display: flex; justify-content: space-between; gap: 12px; }


/* Login em telas baixas (notebooks com zoom, janelas reduzidas) */
@media (max-height: 820px) {
  .login-center { padding-top: 4px; padding-bottom: 16px; }
  .login-top { padding-top: 12px; }
  .login-crest img { height: 70px; }
  .login-entity { margin-top: 10px; font-size: 17px; }
  .login-card { margin-top: 12px; padding: 20px 24px 14px; }
  .login-card h1 { font-size: 14px; }
  .login-card .lead { margin-bottom: 12px; }
  .login-field { margin-bottom: 10px; }
  .login-input { height: 40px; }
  .login-rules { margin: -2px 0 8px; }
}
@media (max-height: 700px) {
  .login-crest { padding: 4px 7px; }
  .login-crest img { height: 58px; }
  .login-entity { margin-top: 8px; font-size: 16px; }
  .login-center { padding-top: 0; }
  .login-card { margin-top: 10px; padding-top: 16px; }
  .login-card .lead { margin-bottom: 10px; }
}
@media (max-height: 560px) {
  .login-crest img { height: 44px; }
}

/* Perfil */
.profile-photo { width: 132px; height: 132px; border-radius: 50%; object-fit: cover; border: 3px solid var(--border); display: inline-block; }
.profile-initials { display: inline-grid; place-items: center; background: var(--c-header); color: #fff; font-size: 40px; font-weight: 700; }

/* ---------- Janela de confirmação (estilo GRP) ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(20, 28, 38, .35); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 4px; box-shadow: var(--shadow-pop); overflow: hidden; }
.modal-head { background: var(--c-header); color: #fff; padding: 9px 14px; font-weight: 600; font-size: 13.5px; }
.modal-body { display: flex; gap: 14px; align-items: flex-start; padding: 20px 18px 8px; font-size: 13.5px; color: var(--text); }
.modal-body .q { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--c-header); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.modal-body .q.danger { background: var(--danger); }
.modal-body p { margin: 7px 0 0; }
.modal-foot { display: flex; justify-content: center; gap: 12px; padding: 18px 16px 18px; }
.modal-foot .btn { min-width: 110px; }

/* ---------- Faixa de ambiente de demonstração ---------- */
.demo-banner {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 7px 16px; text-align: center;
  background: repeating-linear-gradient(-45deg, #f5b300 0 18px, #ffc629 18px 36px);
  color: #1d1d1d; font-size: 12.5px; box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.demo-banner strong { font-size: 13.5px; letter-spacing: .4px; }
.login-page .demo-banner { flex: none; }
.demo-banner-app { position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 41; padding: 4px 16px; font-size: 11.5px; }
.demo-banner-app strong { font-size: 12px; }
body.has-demo { --demo-h: 26px; }
body.has-demo .rail, body.has-demo .flyout { top: calc(var(--header-h) + var(--demo-h)); }
body.has-demo .main { padding-top: calc(var(--header-h) + var(--demo-h) + 14px); }

/* Telas baixas: itens mais compactos para caber sem rolagem */
@media (max-height: 760px) {
  .rail-item { height: 44px; }
  .rail-system { padding: 8px 6px 6px; }
  .rail-foot { padding: 6px 6px 8px; }
  .rail-foot img { width: 32px; height: 38px; }
}
@media (max-height: 620px) {
  .rail-item { height: 40px; }
  .rail-item .ic { width: 21px; height: 21px; }
}
@media (max-width: 420px) {
  .hdr-theme { display: none; } /* o tema continua em Meu perfil */
  .hdr-brand b { font-size: 15px; }
  .hdr-btn { padding: 0 8px; }
}
@media (max-height: 540px) {
  .rail-foot img { display: none; }
}
/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .portlet.span-2 { grid-column: auto; }
  .brand-images { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .hdr-menus, .hdr-user .who, .hdr-brand small { display: none; }
  .hdr-actions { gap: 0; }
  /* Garantia: nada do conteúdo alarga a página além da tela (o celular reduziria o zoom) */
  .main { max-width: 100vw; overflow-x: hidden; }
  .rail { transform: translateX(-100%); transition: transform .18s ease; width: var(--rail-w-open); }
  body.rail-open .rail { transform: none; }
  .rail-item span, .rail-system span, .rail-foot span { opacity: 1; display: block; }
  /* Celular: o painel de opções cobre o menu lateral (antes abria por baixo dele) */
  .flyout, body.rail-open .flyout { left: 0; width: 100%; max-width: none; z-index: 31; }
  .flyout-back { display: flex; align-items: center; gap: 6px; width: 100%; margin-bottom: 8px; padding: 10px 8px;
    border: 0; border-radius: 6px; background: var(--surface-3); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
  .flyout-link { padding-top: 10px; padding-bottom: 10px; }
  .main, body.rail-open .main { margin-left: 0; padding: calc(var(--header-h) + 12px) 12px 30px; }
  body.has-demo { --demo-h: 44px; }
  body.has-demo .main { padding-top: calc(var(--header-h) + var(--demo-h) + 12px); }
  .grid > [class*="col-"] { grid-column: span 12; }
  .portlets { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .login-top { padding: 12px 12px 0; justify-content: center; }
  .login-brand img { height: 34px; }
  .demo-banner { font-size: 11px; padding: 6px 10px; gap: 2px 8px; }
  .demo-banner strong { font-size: 11.5px; }
  .login-foot { flex-direction: column; align-items: center; text-align: center; }
}
@media print {
  .hdr, .rail, .flyout, .toolbar, .filters, .pager { display: none !important; }
  .main { margin: 0; padding: 0; }
}

/* Edição em linha (details/summary) nas tabelas de cadastro */
details.inline-edit { position: relative; display: inline-block; }
details.inline-edit > summary { list-style: none; cursor: pointer; }
details.inline-edit > summary::-webkit-details-marker { display: none; }
details.inline-edit[open] > form { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,.14); text-align: left; }
.panel-foot details.inline-edit[open] > form { position: static; box-shadow: none; border: 0; }
/* Linhas de detalhe (histórico) dentro de tabelas */
.table tr.sub td { background: var(--surface-2); font-size: 12px; }
.table tr.sub td:first-child { padding-left: 26px; }
.table tr.reversed td { text-decoration: line-through; color: var(--text-2); }
.table tfoot td { font-weight: 600; border-top: 2px solid var(--border-strong); }
