@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --border: #E7E4DC;
  --text: #1F2420;
  --text-soft: #6B7268;
  --brand: #2F3B2E;
  --brand-soft: #3F4E3D;
  --brand-tint: #EEF1EC;

  --urg-critica: #C1432B;
  --urg-critica-tint: #FBEBE7;
  --urg-alta: #D98A3D;
  --urg-alta-tint: #FBF1E4;
  --urg-media: #4C7A6B;
  --urg-media-tint: #EAF1EE;
  --urg-baixa: #8C9188;
  --urg-baixa-tint: #F1F1EF;

  --radius: 6px;
  --radius-lg: 10px;
  --shadow-card: 0 1px 2px rgba(31,36,32,0.04);

  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}

a { color: inherit; }
button { font-family: inherit; }

::selection { background: var(--brand-tint); }

.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Layout shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--brand);
  color: #EFEFE9;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 24px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.sidebar-brand .mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: #EFEFE9;
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}

.sidebar-brand .name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.15;
}
.sidebar-brand .sub { font-size: 11px; color: rgba(239,239,233,0.6); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: rgba(239,239,233,0.82);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: #EFEFE9; color: var(--brand); }
.nav-link .ico { width: 16px; text-align: center; flex-shrink: 0; }

.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(239,239,233,0.42);
  padding: 16px 12px 6px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.14);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-chip .who { min-width: 0; }
.user-chip .who .n { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who .r { font-size: 11px; color: rgba(239,239,233,0.55); }
.logout-btn {
  width: 100%; margin-top: 6px; padding: 8px 10px; border-radius: var(--radius);
  background: transparent; border: 1px solid rgba(255,255,255,0.14); color: rgba(239,239,233,0.75);
  font-size: 12.5px; cursor: pointer;
}
.logout-btn:hover { background: rgba(255,255,255,0.06); }

.main {
  padding: 28px 36px 48px;
  max-width: 1320px;
  width: 100%;
}

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.page-header h1 { font-size: 26px; }
.page-header .eyebrow { color: var(--text-soft); font-size: 13px; margin-bottom: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-soft); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: #cfcbc0; }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--urg-critica-tint); color: var(--urg-critica); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  font-family: var(--font-body); font-size: 13.5px; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint);
}
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { font-size: 12px; color: var(--text-soft); margin-top: 5px; }
.error-text { font-size: 12.5px; color: var(--urg-critica); margin-top: 6px; }

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 100px;
  font-size: 11.5px; font-weight: 600;
}
.badge-critica { background: var(--urg-critica-tint); color: var(--urg-critica); }
.badge-alta { background: var(--urg-alta-tint); color: var(--urg-alta); }
.badge-media { background: var(--urg-media-tint); color: var(--urg-media); }
.badge-baixa { background: var(--urg-baixa-tint); color: var(--urg-baixa); }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 100px; font-size: 11.5px; font-weight: 600;
  background: var(--brand-tint); color: var(--brand-soft);
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.kanban-col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px; margin-bottom: 10px;
}
.kanban-col-head .title { font-size: 13px; font-weight: 700; color: var(--text); }
.kanban-col-head .count {
  font-size: 11.5px; color: var(--text-soft); background: var(--surface);
  border: 1px solid var(--border); border-radius: 100px; padding: 1px 8px;
}
.kanban-col-body { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }

.ticket-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 14px 13px 16px; cursor: pointer;
  transition: border-color 0.12s, transform 0.08s;
}
.ticket-card:hover { border-color: #cfcbc0; }
.ticket-card::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px;
  background: var(--urg-media);
}
.ticket-card.u-critica::before { background: var(--urg-critica); }
.ticket-card.u-alta::before { background: var(--urg-alta); }
.ticket-card.u-media::before { background: var(--urg-media); }
.ticket-card.u-baixa::before { background: var(--urg-baixa); }

.ticket-card .code { font-size: 11px; color: var(--text-soft); margin-bottom: 4px; }
.ticket-card .title { font-size: 13.5px; font-weight: 600; margin-bottom: 8px; line-height: 1.3; }
.ticket-card .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ticket-card .foot { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--text-soft); }
.ticket-card .foot .resp { display: flex; align-items: center; gap: 6px; }
.ticket-card .sla-late { color: var(--urg-critica); font-weight: 700; }

.mini-avatar {
  width: 20px; height: 20px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-soft);
  display: flex; align-items: center; justify-content: center; font-size: 9.5px; font-weight: 700; flex-shrink: 0;
}

.empty-col { border: 1px dashed var(--border); border-radius: var(--radius); padding: 18px 12px; text-align: center; color: var(--text-soft); font-size: 12.5px; }

/* ---------- Filters bar ---------- */
.filters-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 20px; padding: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.filters-bar input, .filters-bar select { width: auto; min-width: 150px; }
.filters-bar .search { flex: 1; min-width: 200px; }

.chip-toggle { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-toggle button {
  padding: 7px 13px; border-radius: 100px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text-soft); cursor: pointer;
}
.chip-toggle button.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Stat cards ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card { padding: 16px 18px; }
.stat-card .num { font-family: var(--font-display); font-size: 30px; font-weight: 600; }
.stat-card .lbl { font-size: 12.5px; color: var(--text-soft); margin-top: 2px; }
.stat-card.alert .num { color: var(--urg-critica); }

/* ---------- Ticket detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.detail-info dl { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 0; }
.detail-info dt { font-size: 11.5px; color: var(--text-soft); margin-bottom: 3px; }
.detail-info dd { margin: 0; font-size: 13.5px; font-weight: 600; }

.timeline { display: flex; flex-direction: column; gap: 14px; }
.timeline-msg { display: flex; gap: 10px; }
.timeline-msg .bubble { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.timeline-msg.mine .bubble { background: var(--brand-tint); border-color: transparent; }
.timeline-msg .bubble .head { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-soft); margin-bottom: 4px; }
.timeline-msg .bubble .head .who { font-weight: 700; color: var(--text); }
.timeline-msg .bubble.interna { border-style: dashed; }

.attach-thumb {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: var(--radius); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-soft); text-decoration: none; margin-top: 6px; margin-right: 6px;
}
.attach-thumb:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(31,36,32,0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; z-index: 100;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  padding: 26px; box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-soft); cursor: pointer; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-14 { gap: 14px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.text-soft { color: var(--text-soft); }
.hidden { display: none !important; }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: var(--brand); color: #fff; padding: 12px 18px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toast.err { background: var(--urg-critica); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--brand);
  background-image: radial-gradient(circle at 15% 20%, rgba(255,255,255,0.05), transparent 40%),
                     radial-gradient(circle at 85% 80%, rgba(255,255,255,0.04), transparent 40%);
  padding: 20px;
}
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-lg); padding: 34px 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .mark {
  width: 48px; height: 48px; border-radius: 12px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 14px;
  font-family: var(--font-display); font-weight: 700; font-size: 20px;
}
.login-brand h1 { font-size: 21px; }
.login-brand p { color: var(--text-soft); font-size: 13px; margin-top: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kanban { grid-template-columns: 1fr 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .main { padding: 20px; }
}
@media (max-width: 600px) {
  .kanban { grid-template-columns: 1fr; }
}
