:root{
  /* Tipografia */
  --font-family:'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --line-height:1.45;

  /* Layout */
  --sidebar-width:244px;
  --content-padding-y:24px;
  --content-padding-x:28px;
  --panel-gap:18px;

  /* Radius */
  --radius-xs:8px;
  --radius-sm:10px;
  --radius-md:12px;
  --radius-pill:999px;

  /* Espaçamento */
  --space-1:4px;
  --space-2:6px;
  --space-3:8px;
  --space-4:10px;
  --space-5:12px;
  --space-7:16px;
  --space-8:18px;
  --space-9:20px;

  /* Cores base */
  --bg:#f3f6fb;
  --bg-soft:#f7f9fd;
  --surface:#f8fafc;
  --surface-soft:#fafcff;
  --surface-muted:#fbfcfe;
  --surface-strong:#ffffff;

  --text:#0f172a;
  --text-strong:#172230;
  --text-soft:#475569;
  --text-muted:#748091;
  --text-faint:#8b95a1;
  --white:#ffffff;

  --line:#e8eef5;
  --line-strong:#dce5ee;
  --line-soft:#edf2f7;

  --primary:#1e4262;
  --primary-contrast:#ffffff;
  --primary-ring:rgba(59,130,246,.10);
  --secondary:#556f86;

  --danger:#c0392b;
  --danger-soft:#fee2e2;
  --danger-border:#f4c7c3;

  --success:#15803d;
  --success-soft:#eaf8ee;
  --success-border:#cdeed7;

  --warning:#9a6700;
  --warning-soft:#fff4db;
  --warning-border:#fde7b0;

  --info:#1d4ed8;
  --info-soft:#e8f1ff;
  --info-border:#cfe0ff;

  --focus:#3b82f6;
  --overdue:#ef4444;
  --today:#f59e0b;
  --future:#22c55e;

  --timeline:#e7edf4;
  --dot-neutral:#94a3b8;

  /* Sombras */
  --shadow-xs:0 1px 2px rgba(0,0,0,.04);
  --shadow-sm:0 3px 10px rgba(15,23,42,.04);
  --shadow-md:0 4px 12px rgba(15,23,42,.04);
  --shadow-xl:0 10px 18px rgba(15,23,42,.06);
  --shadow-hover:0 6px 16px rgba(15,23,42,.12);

  /* Menu */
  --menu-bg:var(--primary);
  --menu-border:rgba(255,255,255,.07);
  --menu-overlay:rgba(2,10,21,.52);
  --menu-soft-bg:rgba(255,255,255,.08);
  --menu-soft-bg-hover:rgba(255,255,255,.12);
  --menu-card-bg:rgba(255,255,255,.07);
  --menu-card-border:rgba(255,255,255,.08);
  --menu-text:#c9d4df;
  --menu-text-strong:#ffffff;

  /* Pills / badges */
  --pill-bg:#eef2f7;
  --pill-text:#334155;
  --pill-border:transparent;

  --warning-badge-bg:var(--warning-soft);
  --warning-badge-text:var(--warning);
  --warning-badge-border:var(--warning-border);

  --info-badge-bg:var(--info-soft);
  --info-badge-text:var(--info);
  --info-badge-border:var(--info-border);

  --success-badge-bg:var(--success-soft);
  --success-badge-text:var(--success);
  --success-badge-border:var(--success-border);

  --ticket-mini-bg:linear-gradient(180deg,#fafcff 0%, #f6f9fc 100%);
}

body[data-theme="dark"]{
  --bg:#15181d;
  --bg-soft:#1a1e24;
  --surface:#20252c;
  --surface-soft:#242a32;
  --surface-muted:#1d2229;
  --surface-strong:#2a3038;

  --text:#e6e9ee;
  --text-strong:#f5f7fa;
  --text-soft:#b4bcc8;
  --text-muted:#939dab;
  --text-faint:#7f8998;

  --line:#313842;
  --line-strong:#3c4551;
  --line-soft:#2a313b;

  --primary:#4f6479;
  --primary-contrast:#ffffff;
  --primary-ring:rgba(120,138,160,.18);
  --secondary:#6b7785;

  --danger:#e07a69;
  --danger-soft:rgba(224,122,105,.12);
  --danger-border:rgba(224,122,105,.20);

  --success:#63c38b;
  --success-soft:rgba(99,195,139,.12);
  --success-border:rgba(99,195,139,.20);

  --warning:#d8b15a;
  --warning-soft:rgba(216,177,90,.12);
  --warning-border:rgba(216,177,90,.20);

  --info:#7ea6d9;
  --info-soft:rgba(126,166,217,.12);
  --info-border:rgba(126,166,217,.20);

  --focus:#7f97b3;
  --overdue:#df6b6b;
  --today:#d2a85a;
  --future:#5fb784;

  --timeline:#3a424d;
  --dot-neutral:#7f8a99;

  --shadow-xs:0 1px 2px rgba(0,0,0,.18);
  --shadow-sm:0 3px 10px rgba(0,0,0,.20);
  --shadow-md:0 4px 12px rgba(0,0,0,.24);
  --shadow-xl:0 10px 18px rgba(0,0,0,.30);
  --shadow-hover:0 8px 20px rgba(0,0,0,.34);

  --menu-bg:linear-gradient(180deg,#1a1e24 0%, #161a20 100%);
  --menu-border:rgba(255,255,255,.05);
  --menu-overlay:rgba(0,0,0,.45);
  --menu-soft-bg:rgba(255,255,255,.05);
  --menu-soft-bg-hover:rgba(255,255,255,.08);
  --menu-card-bg:rgba(255,255,255,.04);
  --menu-card-border:rgba(255,255,255,.06);
  --menu-text:#b8c0cb;
  --menu-text-strong:#f3f5f7;

  --pill-bg:rgba(255,255,255,.06);
  --pill-text:#d8dee7;
  --pill-border:var(--line);

  --ticket-mini-bg:linear-gradient(180deg,var(--surface-soft) 0%, var(--surface) 100%);
}

/* ============================= */
/* RESET / BASE */
/* ============================= */

*{ box-sizing:border-box; }

html,
body{
  margin:0;
  padding:0;
}

html{
  scroll-behavior:smooth;
}

::-webkit-resizer {
  display: none;
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--surface); /* Dark background color */
}

::-webkit-scrollbar-thumb {
  background-color: var(--text-faint); /* Medium grey scrollbar color */
  border-radius: 10px; /* Optional: rounded corners */
  border: 2px solid var(--text-faint); /* Optional: creates padding around the thumb */
}

body{
  font-family:var(--font-family);
  line-height:var(--line-height);
  background:var(--bg);
  color:var(--text);
  transition:background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

body.menu-open{ overflow:hidden; }

a{
  color:inherit;
  text-decoration:none;
}

h1,h2,h3,h4{
  margin:0 0 var(--space-5);
  color:var(--text-strong);
  letter-spacing:-.01em;
}

p{ margin:0; }
small{ color:var(--text-muted); }

button,
input,
textarea,
select{
  font:inherit;
}

[hidden]{ display:none !important; }

/* ============================= */
/* TOKENS DE COMPONENTE / BASE */
/* ============================= */

.surface,
.card,
.client-card,
.dashboard-col,
.side-block,
.tickets-sidebar,
.tickets-view,
.task-column,
.modal-content{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-md);
}

.item-card,
.mini-card,
.ticket-dashboard-item,
.ticket-mini-card,
.note-mini-card,
.ticket-thread-item{
  border-radius:var(--radius-md);
  transition:transform .2s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
}

.pill,
.badge,
.status-badge,
.ticket-status-badge,
.pill--tiny,
.ticket-mini-badge,
.dashboard-badge,
.ticket-thread-count,
.ticket-count{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:var(--radius-pill);
  white-space:nowrap;
  font-weight:700;
}

.scroll-area,
.list,
.task-column-body,
.side-block-body,
.ticket-mensagens,
.tickets-list{
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
}

.flex-between,
.dashboard-col-header,
.tasks-header,
.side-header,
.ticket-dashboard-top,
.ticket-thread-top,
.ticket-mini-top,
.ticket-mini-bottom,
.ticket-thread-bottom,
.ticket-dashboard-meta,
.ticket-modal-toolbar,
.ticket-modal-status-wrap,
.ticket-modal-actions-top,
.tickets-sidebar-header-top{
  display:flex;
  justify-content:space-between;
  gap:10px;
}

.text-soft,
.activity-date,
.activity-date-line,
.ticket-modal-date,
.ticket-thread-date,
.note-mini-date,
.item-client,
.ticket-thread-company,
.ticket-dashboard-meta,
.ticket-modal-meta,
.ticket-mini-bottom{
  color:var(--text-soft);
}

.section-head{
  display:flex;
  gap:10px;
}

.section-head--between{
  justify-content:space-between;
}

.section-head--center{
  align-items:center;
}

.section-head--start{
  align-items:flex-start;
}

.section-head--wrap{
  flex-wrap:wrap;
}

.meta{
  font-size:12px;
  color:var(--text-soft);
}

.meta--xs{
  font-size:11px;
}

/* ============================= */
/* MENU / NAVEGAÇÃO */
/* ============================= */

.menu-backdrop{
  position:fixed;
  inset:0;
  background:var(--menu-overlay);
  z-index:1030;
}

.menu{
  position:fixed;
  inset:0 auto 0 0;
  width:var(--sidebar-width);
  height:100vh;
  padding:var(--space-8);
  overflow-y:auto;
  background:var(--menu-bg);
  color:var(--menu-text-strong);
  border-right:1px solid var(--menu-border);
  box-shadow:var(--shadow-md);
  z-index:1040;
}

.menu-inner{
  min-height:100%;
  display:flex;
  flex-direction:column;
  gap:var(--space-7);
}

.menu-brand-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:var(--space-5);
}

.brand-kicker{
  display:inline-flex;
  padding:var(--space-2) var(--space-4);
  margin-bottom:var(--space-4);
  border-radius:var(--radius-pill);
  font-size:10px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--menu-text-strong);
  background:var(--menu-soft-bg);
  border:1px solid var(--menu-card-border);
}

.menu h3{
  margin-bottom:0;
  font-size:22px;
  font-weight:700;
  color:var(--menu-text-strong);
}

.menu-close{
  display:none;
  width:38px;
  height:38px;
  border-radius:var(--radius-md);
  background:var(--menu-soft-bg);
  color:var(--menu-text-strong);
  font-size:22px;
}

.menu .user,
.user-card,
.menu-client-summary{
  padding:var(--space-5) 13px;
  border-radius:var(--radius-md);
  background:var(--menu-card-bg);
  color:var(--menu-text-strong);
  font-size:14px;
  border:1px solid var(--menu-card-border);
}

.user-card{
  display:grid;
  gap:var(--space-3);
}

.user-card strong{ color:var(--menu-text-strong); }

.badge{
  width:fit-content;
  min-height:24px;
  padding:2px 9px;
  font-size:10px;
  text-transform:uppercase;
  background:var(--pill-bg);
  color:var(--pill-text);
  border:1px solid var(--pill-border);
}

.menu-nav{
  display:grid;
  gap:var(--space-2);
}

.menu-nav a{
  display:block;
  margin:0;
  padding:var(--space-4) var(--space-5);
  border-radius:var(--radius-md);
  color:var(--menu-text);
  font-size:14px;
  font-weight:600;
  transition:color .2s ease, background .2s ease;
}

.menu-nav a:hover,
.menu-nav a.active,
.menu-nav a.is-active{
  color:var(--menu-text-strong);
  background:var(--menu-soft-bg);
}

.menu-link-soft{ opacity:.95; }
.menu-client-summary,
.menu-footer{ margin-top:auto; }

/* ============================= */
/* BOTÕES */
/* ============================= */

.theme-toggle,
.icon-btn,
.btn,
a.btn,
button.btn{
  appearance:none;
  -webkit-appearance:none;
  border:none;
  cursor:pointer;
}

.btn,
a.btn,
button.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:38px;
  padding:8px 14px;
  border-radius:var(--radius-md);
  background:var(--primary);
  color:var(--primary-contrast);
  font-size:13px;
  font-weight:600;
  line-height:1;
  text-decoration:none;
  box-shadow:var(--shadow-xs);
  transition:transform .2s ease, box-shadow .2s ease, opacity .2s ease, background .2s ease;
}

.btn:hover,
a.btn:hover,
button.btn:hover{
  transform:translateY(-1px);
  box-shadow:var(--shadow-hover);
}

.btn:active,
a.btn:active,
button.btn:active{ transform:translateY(0); }

.btn-disable{
  pointer-events:none;
  cursor:not-allowed;
  opacity:.55;
}

.btn.btn--danger{
  background:var(--danger);
  color:var(--white);
}

.btn.btn--icon{
  min-width:34px;
  width:34px;
  height:34px;
  padding:0;
  font-size:18px;
}

.btn.btn-sm{
  min-height:30px;
  padding:6px 10px;
  font-size:12px;
}

.theme-toggle{
  display:inline-flex;
  align-items:center;
  gap:var(--space-4);
  min-height:40px;
  padding:var(--space-4) var(--space-5);
  border-radius:var(--radius-md);
  background:var(--menu-soft-bg);
  color:var(--menu-text-strong);
  border:1px solid var(--menu-card-border);
  transition:background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.theme-toggle:hover{ background:var(--menu-soft-bg-hover); }

.theme-toggle.compact{
  background:var(--surface);
  color:var(--text-strong);
  border-color:var(--line);
  box-shadow:var(--shadow-md);
}

.theme-toggle-icon{
  font-size:14px;
  line-height:1;
}

.theme-toggle-text{
  font-size:13px;
  font-weight:600;
}

.icon-btn{
  display:none;
  width:42px;
  height:42px;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:var(--space-1);
  border-radius:var(--radius-md);
  background:var(--surface);
  border:1px solid var(--line);
  box-shadow:var(--shadow-md);
}

.icon-btn span{
  display:block;
  width:18px;
  height:2px;
  border-radius:var(--radius-pill);
  background:var(--text-strong);
}

/* ============================= */
/* LAYOUT */
/* ============================= */

.content{
  margin-left:calc(var(--sidebar-width) + 20px);
  padding:var(--content-padding-y) var(--content-padding-x);
  min-height:100vh;
}

/* ============================= */
/* FORMULÁRIOS */
/* ============================= */

form{ margin:0; }

label{
  display:block;
  margin:0 0 var(--space-3);
  color:var(--text-soft);
  font-size:13px;
  font-weight:600;
}

form input,
form textarea,
form select,
.search,
.login-form input{
  width:100%;
  margin-bottom:var(--space-5);
  padding:var(--space-4) var(--space-5);
  font-size:14px;
  color:var(--text);
  background:var(--surface-strong);
  border:1px solid var(--line);
  border-radius:var(--radius-md);
  transition:border-color .2s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
}

form input:focus,
form textarea:focus,
form select:focus,
.search:focus,
.login-form input:focus{
  outline:none;
  border-color:var(--focus);
  box-shadow:0 0 0 4px var(--primary-ring);
}

form textarea{
  resize:vertical;
  min-height:90px;
}

.search{
  max-width:320px;
  margin-top:var(--space-9);
}

.client-actions form,
.ticket-reply form,
.side-header form,
.inline-form{
  display:inline;
  margin:0;
}

.client-actions form button,
.client-actions .btn{ margin:0; }

.client-checkboxes{
  display:flex;
  flex-wrap:wrap;
  gap:var(--space-3);
  margin:6px 0 12px;
}

.tag-checkbox{
  display:flex;
  align-items:center;
  cursor:pointer;
}

.tag-checkbox input{ display:none; }

.tag-checkbox span,
.tabs a{
  padding:7px 12px;
  border-radius:var(--radius-pill);
  background:var(--pill-bg);
  color:var(--pill-text);
  font-size:13px;
  border:1px solid transparent;
  transition:background .2s ease, color .2s ease;
}

.tag-checkbox input:checked + span{
  background:var(--primary);
  color:var(--white);
}

.tabs{
  margin:10px 0 18px;
  display:flex;
  flex-wrap:wrap;
  gap:var(--space-3);
}

.tabs a:hover{ filter:brightness(.98); }

/* ============================= */
/* CARDS / LISTAS */
/* ============================= */

.card{
  padding:20px;
  margin-top:var(--space-9);
}

/* Elementos que usam .card mas não precisam de margin-top */
.tickets-sidebar.card,
.tickets-view.card,
.login-card.card{
  margin-top:0;
}

.dashboard-col,
.side-block,
.task-column,
.tickets-sidebar,
.tickets-view{
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow:hidden;
}

.dashboard-col{ padding:18px; }
.side-block,
.task-column{ padding:14px; }

.side-block-body,
.list,
.task-column-body{
  flex:1;
  padding-right:4px;
}

.dashboard-col-header,
.tasks-header,
.side-header{ 
  align-items:center;
  flex-wrap:wrap;
  margin-bottom:12px;
}

.dashboard-col-header{
  margin-bottom:14px;
  flex-shrink:0;
}

.ticket-dashboard-top,
.ticket-thread-top{
  align-items:flex-start;
}

.ticket-mini-top,
.ticket-mini-bottom,
.ticket-modal-toolbar,
.ticket-modal-status-wrap,
.ticket-modal-actions-top,
.tickets-sidebar-header-top,
.ticket-dashboard-meta,
.ticket-thread-bottom{
  align-items:center;
}

.side-header h3,
.dashboard-col h3{ margin-bottom:0; }

.list{
  display:flex;
  flex-direction:column;
}

.list-item{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  padding:10px 4px;
  border-bottom:1px solid var(--line-soft);
  font-size:13px;
}

.list-item:last-child{ border-bottom:none; }

.link-item{
  display:block;
  padding:0 6px;
  border-radius:var(--radius-md);
  transition:background .2s ease;
}

.link-item:hover{
  background:color-mix(in srgb, var(--surface) 90%, var(--bg-soft));
}

/* ============================= */
/* CLIENTES / USUÁRIOS */
/* ============================= */

.clients{
  margin-top:var(--space-9);
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:12px;
}
.client-card{
  padding:18px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  flex-wrap:wrap;
  transition:transform .2s ease;
}

.client-card:hover{
  transform:translateY(-2px);
  border-color:var(--line-strong);
}

.client-info{
  flex:1;
  min-width:240px;
  font-size:14px;
  line-height:1.65;
}

.client-info b{
  font-size:16px;
  color:var(--text-strong);
}

.client-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}

/* ============================= */
/* STATUS / TEXTO AUXILIAR */
/* ============================= */

.bold{ font-weight:700; }

.status-active,
.status-inactive{ font-weight:600; }

.status-active{ color:var(--success); }
.status-inactive{ color:var(--overdue); }

.activity-date,
.activity-date-line,
.ticket-modal-date,
.ticket-thread-date,
.note-mini-date{
  font-size:11px;
}

.item-client,
.ticket-thread-company{
  font-size:12px;
}

.empty{
  padding:12px 4px;
  font-size:13px;
  color:var(--text-faint);
}

/* ============================= */
/* MODAL */
/* ============================= */

.modal{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  padding:20px;
  overflow:auto;
  background:rgba(20,20,20,.70);
  backdrop-filter:blur(10px);
  z-index:1000;
}

.modal-content{
  position:relative;
  width: 40vw;
  min-width:460px;
  max-width:100%;
  max-height:calc(100vh - 40px);
  overflow-y:auto;
  padding:26px;
  animation:modalFade .2s ease;
}

.modal-content h3:first-child{
  padding-right:28px;
}

@keyframes modalFade{
  from{
    opacity:0;
    transform:translateY(-8px);
  }
  to{
    opacity:1;
    transform:translateY(0);
  }
}

.close{
  position:absolute;
  top:12px;
  right:12px;
  width:32px;
  height:32px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:var(--radius-pill);
  color:var(--text-soft);
  font-size:22px;
  cursor:pointer;
  transition:background .2s ease, color .2s ease;
}

.close:hover{
  background:var(--surface);
  color:var(--text-strong);
}

/* ============================= */
/* DASHBOARD */
/* ============================= */

.dashboard-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:var(--panel-gap);
  margin-bottom:24px;
}

.kpi{
  padding:18px 20px;
}

.kpi-number{
  margin-top:8px;
  font-size:30px;
  font-weight:800;
  color:var(--text-strong);
}

.dashboard-main{
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:var(--panel-gap);
  align-items:stretch;
  height:calc(100vh - 250px);
  min-height:0;
}

/* pill--count: base para badges de contagem (dashboard, threads) */
.pill--count,
.dashboard-badge,
.ticket-thread-count{
  min-width:28px;
  height:28px;
  padding:0 10px;
  font-size:12px;
  background:var(--pill-bg);
  color:var(--pill-text);
  border:1px solid var(--pill-border);
}

/* .ticket-count: variante compacta do pill--count */
.ticket-count{
  min-width:20px;
  height:20px;
  padding:0 6px;
  margin-right:5px;
  font-size:10px;
  background:var(--pill-bg);
  color:var(--pill-text);
  border:1px solid var(--pill-border);
}

.ticket-list-dashboard{ gap:10px; }

.ticket-dashboard-item{
  display:block;
  padding:12px;
  border:1px solid var(--line);
  background:var(--surface-soft);
}

.item-card:hover,
.ticket-dashboard-item:hover,
.ticket-thread-item:hover,
.ticket-mini-card:hover,
.note-mini-card:hover,
.mini-card:hover{
  transform:translateY(-1px);
  border-color:var(--line-strong);
  box-shadow:var(--shadow-xl);
}

.ticket-dashboard-item:hover{
  background:var(--surface);
}

.ticket-dashboard-top{ margin-bottom:8px; }

.ticket-dashboard-title{
  font-size:14px;
  font-weight:700;
  color:var(--text-strong);
  line-height:1.35;
}

.ticket-dashboard-meta{
  font-size:12px;
}

/* Shared: shrink + uppercase para todos os badges de status */
.status-badge,
.ticket-status-badge,
.ticket-mini-badge,
.pill--tiny{
  flex-shrink:0;
  border:1px solid transparent;
  text-transform:uppercase;
}

/* status-badge / ticket-status-badge: tamanho normal
   (ticket-status-badge mantido por compatibilidade com HTML existente) */
.status-badge,
.ticket-status-badge{
  min-height:24px;
  padding:0 10px;
  font-size:11px;
  background:var(--warning-badge-bg);
  color:var(--warning-badge-text);
  border-color:var(--warning-badge-border);
}

/* pill--tiny / ticket-mini-badge: variante compacta
   (ticket-mini-badge mantido por compatibilidade com HTML existente) */
.pill--tiny,
.ticket-mini-badge{
  min-height:22px;
  padding:0 8px;
  font-size:10px;
  background:var(--warning-badge-bg);
  color:var(--warning-badge-text);
  border-color:var(--warning-badge-border);
}

.status-retorno-cliente{
  background:var(--info-badge-bg);
  color:var(--info-badge-text);
  border-color:var(--info-badge-border);
}

.status-concluido{
  background:var(--success-badge-bg);
  color:var(--success-badge-text);
  border-color:var(--success-badge-border);
}

/* ============================= */
/* CLIENTE / KANBAN */
/* ============================= */

.client-layout{
  display:flex;
  gap:var(--panel-gap);
  margin-top:var(--space-9);
  align-items:stretch;
  height:calc(100vh - 170px);
  min-height:0;
}

.tasks-area{
  flex:1;
  min-width:0;
  min-height:0;
  display:flex;
  flex-direction:column;
}

.side-area{
  width:360px;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:16px;
}

.side-area .side-block:first-child{ flex:1.4; }
.side-area .side-block:last-child{ flex:.9; }

.kanban{
  display:flex;
  gap:16px;
  overflow-x:auto;
  padding-bottom:8px;
  flex:1;
  min-height:0;
}

.task-column{
  flex:1;
  min-width:260px;
}

.task-column h4{
  margin-bottom:12px;
  flex-shrink:0;
  font-size:15px;
  color:var(--pill-text);
}

.task-card{
  margin-bottom:10px;
  padding:12px;
  font-size:14px;
  color:var(--text);
  background:var(--surface);
  border-radius:var(--radius-md);
  border:1px solid color-mix(in srgb, var(--line) 85%, transparent);
  box-shadow:var(--shadow-md);
  cursor:pointer;
  transition:transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.task-card:hover{
  transform:translateY(-2px);
  box-shadow:0 12px 18px rgba(15,23,42,.08);
  border-left:4px solid var(--line-strong);
}

.task-overdue{ border-left:4px solid var(--overdue); }
.task-today{ border-left:4px solid var(--today); }
.task-future{ border-left:4px solid var(--future); }

/* ============================= */
/* TICKETS / NOTAS */
/* ============================= */

.mini-card{
  margin-bottom:8px;
  padding:10px 12px;
  font-size:14px;
  background:var(--surface);
  border:1px solid transparent;
  cursor:pointer;
}

.ticket-mini-card{
  background:var(--ticket-mini-bg);
  border:1px solid var(--line);
}

.ticket-mini-top{
  gap:8px;
  margin-bottom:6px;
}

.ticket-mini-title,
.ticket-thread-title{
  color:var(--text-strong);
  font-weight:700;
  line-height:1.3;
}

.ticket-mini-title{
  overflow:hidden;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  font-size:13px;
  line-height:1.25;
}

.ticket-mini-bottom{ font-size:11px; }

.ticket-mini-count{ font-weight:600; }
.ticket-mini-date{ white-space:nowrap; }

.note-mini-card{
  min-height:72px;
  padding:12px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  background:var(--surface-muted);
  border:1px solid var(--line);
}

.note-mini-title{
  margin-bottom:6px;
  font-size:14px;
  font-weight:700;
  line-height:1.35;
  color:var(--text-strong);
}

/* ============================= */
/* TIMELINE / ATIVIDADE */
/* ============================= */

.activity-timeline{
  position:relative;
  gap:0;
  padding-left:6px;
}

.activity-item{
  position:relative;
  display:flex;
  gap:12px;
  padding:0 0 14px;
}

.activity-item:last-child{ padding-bottom:0; }

.activity-item::before{
  content:"";
  position:absolute;
  left:5px;
  top:18px;
  bottom:-6px;
  width:2px;
  background:var(--timeline);
}

.activity-item:last-child::before{ display:none; }

.activity-dot{
  position:relative;
  z-index:1;
  flex-shrink:0;
  width:12px;
  height:12px;
  margin-top:4px;
  border-radius:var(--radius-pill);
  background:var(--dot-neutral);
}

.activity-task .activity-dot{ background:var(--focus); }
.activity-ticket .activity-dot{ background:var(--today); }
.activity-note .activity-dot{ background:var(--future); }

.activity-content{
  flex:1;
  min-width:0;
  padding-bottom:2px;
}

.activity-text{
  font-size:13px;
  color:var(--text);
  line-height:1.4;
}

/* ============================= */
/* TICKETS PAGE / THREAD */
/* ============================= */

.tickets-page{
  display:grid;
  grid-template-columns:380px minmax(0,1fr);
  gap:var(--panel-gap);
  margin-top:var(--space-9);
  height:calc(100vh - 100px);
  min-height:0;
}

.tickets-sidebar,
.tickets-view{
  padding:0;
  height:100%;
}

.tickets-sidebar-header{
  flex:0 0 auto;
  display:flex;
  flex-direction:column;
  gap:12px;
  padding:18px 18px 12px;
  border-bottom:1px solid var(--line);
}

.tickets-sidebar-search input{ width:100%; }

.tickets-list{
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:10px;
}

.ticket-thread-item{
  flex:0 0 auto;
  display:block;
  padding:12px;
  border:1px solid var(--line);
  background:var(--surface);
}

.ticket-thread-item.active{
  border-color:var(--focus);
  background:color-mix(in srgb, var(--focus) 8%, var(--surface));
  box-shadow:0 0 0 1px rgba(59,130,246,.12);
}

.ticket-thread-item.hidden{ display:none; }

.ticket-thread-top{ margin-bottom:6px; }

.ticket-thread-title{
  font-size:14px;
}

.ticket-thread-preview{
  overflow:hidden;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  margin-bottom:8px;
  font-size:13px;
  line-height:1.4;
  color:var(--text-soft);
}

.tickets-view{
  padding:20px;
}

.tickets-view #ticket-view-root{
  display:flex;
  flex-direction:column;
  min-height:0;
  height:100%;
}

.tickets-view .ticket-modal-header,
.tickets-view .ticket-modal-toolbar,
.tickets-view .ticket-modal-footer{
  flex:0 0 auto;
}

.tickets-view .ticket-mensagens{
  flex:1 1 auto;
  min-height:0;
  margin:16px 0;
}

.tickets-view .ticket-reply{
  gap:12px;           /* sobrescreve gap:10px do base */
  align-items:flex-end; /* sobrescreve flex-start do base */
}

.tickets-view .ticket-reply textarea{
  min-height:90px;
  max-height:180px;
  resize:vertical;
}

.tickets-view .empty{ padding:24px; }

/* ============================= */
/* TICKET MODAL / CHAT */
/* ============================= */

.ticket-modal-header{
  margin-bottom:12px;
  padding-right:28px;
}

.ticket-modal-title{
  margin:0 0 6px;
  font-size:18px;
  line-height:1.3;
  color:var(--text-strong);
}

.ticket-modal-meta{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  font-size:12px;
  font-weight:500;
}

.ticket-modal-toolbar{
  margin-bottom:14px;
  padding:10px 12px;
  border-radius:var(--radius-md);
  background:var(--surface-soft);
  border:1px solid var(--line);
}

.ticket-modal-status-wrap{
  flex-wrap:wrap;
  min-width:0;
}

.ticket-modal-actions-top{
  gap:8px;
  flex-shrink:0;
}

.ticket-modal-footer{
  margin-top:12px;
  padding-top:12px;
  border-top:1px solid var(--line);
}

.ticket-mensagens{
  margin-bottom:12px;
  padding:10px;
  max-height:360px;
  border-radius:var(--radius-md);
  background:var(--surface-soft);
  border:1px solid color-mix(in srgb, var(--line) 96%, transparent);
}

.msg{
  display:flex;
  flex-direction:column;
  max-width:78%;
  margin-bottom:12px;
}

.msg-left{ align-items:flex-start; }
.msg-right{
  align-items:flex-end;
  margin-left:auto;
}

.msg-info{
  margin-bottom:4px;
  font-size:11px;
  color:var(--text-soft);
}

.msg-user{ font-weight:700; }
.msg-date{
  margin-left:6px;
  font-size:10px;
}

.msg-bubble{
  padding:10px 12px;
  border-radius:var(--radius-md);
  font-size:14px;
  line-height:1.45;
  word-break:break-word;
  overflow-wrap:break-word;
  box-shadow:var(--shadow-sm);
}

.msg-left .msg-bubble{
  background:var(--secondary);
  color:var(--white);
}

.msg-right .msg-bubble{
  background:var(--surface);
  color:var(--text-strong);
  border:1px solid var(--line);
}

.ticket-reply{
  display:flex;
  align-items:flex-start;
  gap:10px;
}

.ticket-reply textarea{ 
  min-height:48px;
  margin:0;
}

.ticket-reply .btn{ min-width:110px; }

/* ============================= */
/* LOGIN */
/* ============================= */

.login-page{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
}

.login-card{
  width:100%;
  max-width:380px;
  padding:28px 22px;
  background:var(--surface-strong);
  border:1px solid var(--line);
  border-radius:var(--radius-md);
  box-shadow:0 8px 24px rgba(15,23,42,.08);
}

.login-title{
  text-align:center;
  margin:0 0 10px;
  font-size:26px;
  line-height:1.2;
  color:var(--text-strong);
}

.login-subtitle{
  text-align:center;
  color:var(--text-muted);
  font-size:13px;
  margin:0 0 22px;
}

.login-error{
  background:var(--danger-soft);
  color:var(--danger);
  border:1px solid var(--danger-border);
  padding:10px;
  border-radius:var(--radius-xs);
  margin-bottom:15px;
  font-size:13px;
  text-align:center;
}

.login-form{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.login-form input{
  margin-bottom:0;
  padding:14px 12px;
  font-size:16px;
}

.login-form .btn{
  width:100%;
  min-height:48px;
  padding:14px 12px;
  font-size:16px;
}

/* ============================= */
/* RESPONSIVO */
/* ============================= */

@media (max-width:1366px){
  .content{
    --content-padding-y:20px;
    --content-padding-x:22px;
  }

  .dashboard-main{
    gap:16px;
    height:calc(100vh - 235px);
  }

  .tickets-page{
    grid-template-columns:340px minmax(0,1fr);
    gap:16px;
  }

  .client-layout{ gap:16px; }
  .side-area{ width:330px; }
}

@media (max-width:1024px){
  .icon-btn,
  .menu-close{
    display:flex;
  }

  .menu{
    width:min(320px,86vw);
    transform:translateX(-108%);
    transition:transform .2s ease;
  }

  .menu.is-open{ transform:translateX(0); }

  .content{
    margin-left:0;
    --content-padding-y:20px;
    --content-padding-x:20px;
  }
  
  .clients{ grid-template-columns:repeat(2,1fr); }

  .tickets-page{
    grid-template-columns:1fr;
    height:auto;
  }

  .tickets-sidebar{ max-height:320px; }
  .tickets-view{ min-height:500px; }

  .dashboard-grid{ grid-template-columns:repeat(2,1fr); }

  .dashboard-main{
    grid-template-columns:1fr;
    height:auto;
  }

  .client-layout{
    flex-direction:column;
    height:auto;
  }

  .side-area{
    width:100%;
    max-height:none;
    flex-direction:row;
  }

  .side-block,
  .dashboard-col{
    flex:1;
    min-height:280px;
    height:auto;
  }

  .list{ max-height:320px; }
  .tasks-area{ height:auto; }
  .kanban{ min-height:420px; }
}

@media (max-width:768px){
  .content{
    --content-padding-y:18px;
    --content-padding-x:18px;
  }
  
  .clients{ grid-template-columns:1fr; }

  .side-area{ flex-direction:column; }
  .dashboard-grid{ grid-template-columns:1fr; }
  .task-column{ min-width:240px; }
  .kanban{ min-height:auto; }

  .dashboard-col{
    height:auto;
    min-height:260px;
  }

  .ticket-mini-top,
  .ticket-mini-bottom,
  .ticket-modal-toolbar,
  .ticket-modal-actions-top,
  .ticket-modal-status-wrap,
  .tickets-sidebar-header-top{
    flex-direction:column;
    align-items:flex-start;
  }
}

@media (max-width:480px){
  .content{
    --content-padding-y:16px;
    --content-padding-x:16px;
  }

  .card,
  .client-card,
  .kpi,
  .dashboard-col,
  .side-block,
  .tickets-view,
  .tickets-sidebar{
    padding:14px;
  }

  .login-card{
    max-width:100%;
    padding:22px 16px;
    border-radius:var(--radius-sm);
  }

  .btn,
  a.btn,
  button.btn{
    min-height:34px;
    padding:7px 10px;
    font-size:12px;
  }

  .client-info b{ font-size:15px; }

  .modal{ padding:12px; }

  .modal-content{
    min-width:80vw;
    padding:22px 16px;
  }

  .ticket-reply,
  .tickets-view .ticket-reply{
    flex-direction:column;
    align-items:stretch;
  }

  .msg{ max-width:88%; }

  .theme-toggle{
    width:100%;
    justify-content:center;
  }

  .login-page{ padding:16px; }

  .login-title{ font-size:22px; }

  .login-subtitle{
    font-size:13px;
    margin-bottom:18px;
  }

  .login-form input,
  .login-form .btn{
    font-size:16px;
    padding:13px 12px;
  }
}