:root {
  --brand: #3c9e42;
  --brand-dark: #24712b;
  --brand-soft: #e8f6ea;
  --ink: #111827;
  --sidebar: #101820;
  --surface: #f4f7fb;
  --card: #ffffff;
  --line: #dde4ee;
  --line-strong: #cbd5e1;
  --muted: #64748b;
  --muted-strong: #334155;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --warning: #d97706;
  --blue: #2563eb;
  --shadow-sm: 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-md: 0 18px 46px rgba(15, 23, 42, .10);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--surface); }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(60, 158, 66, .16);
}
textarea { min-height: 142px; resize: vertical; line-height: 1.6; }
label { display: grid; gap: 7px; color: var(--muted-strong); font-size: 13px; font-weight: 800; }
strong { color: var(--ink); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #0f172a;
}

.login-shell {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 1fr 430px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 28px 80px rgba(0,0,0,.32);
}

.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 560px;
  padding: 58px;
  color: #fff;
  background: var(--sidebar);
}

.login-logo {
  width: 228px;
  max-width: 100%;
  margin-bottom: 34px;
  border-radius: var(--radius);
  box-shadow: 0 18px 42px rgba(0,0,0,.22);
}

.login-brand h1 { margin: 0 0 12px; font-size: 36px; line-height: 1.12; }
.login-brand p { max-width: 520px; margin: 0; color: #cbd5e1; line-height: 1.7; }
.login-panel { display: grid; align-items: center; padding: 46px; }
.form-card { display: grid; gap: 18px; }
.form-card h2 { margin: 0; font-size: 27px; line-height: 1.2; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.install-card {
  width: min(660px, 100%);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-md);
}
.install-logo { width: 184px; padding: 18px; border-radius: var(--radius); background: var(--sidebar); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #fff;
  border-right: 1px solid rgba(255,255,255,.08);
}

.brand {
  min-height: 104px;
  display: flex;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand img { max-width: 166px; max-height: 76px; object-fit: contain; }
.sidebar nav { flex: 1; display: grid; align-content: start; gap: 7px; padding: 16px 14px; }
.sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 11px 13px;
  border-radius: var(--radius);
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 800;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.sidebar nav a:hover { background: rgba(255,255,255,.09); color: #fff; transform: translateX(2px); }
.sidebar nav a.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 26px rgba(60, 158, 66, .24);
}
.sidebar-user {
  display: grid;
  gap: 7px;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  color: #e2e8f0;
  font-size: 14px;
}
.sidebar-user strong { color: #fff; }
.sidebar-user span {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 800;
}
.sidebar-user a { color: #d7f5da; font-weight: 800; }

.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(14px);
}
.topbar span:not(.role-pill) {
  display: block;
  margin-bottom: 3px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.topbar h1 { margin: 0; font-size: 23px; line-height: 1.2; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.role-pill {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 900;
}
.search { width: min(340px, 42vw); }
.search input { min-height: 40px; background: #f8fafc; }
.content {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px;
  display: grid;
  gap: 24px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin: 0 0 16px; font-size: 18px; line-height: 1.3; }
.muted, .section-title p { color: var(--muted); }
.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.section-title h2 { margin: 0 0 6px; font-size: 25px; line-height: 1.15; }
.section-title p { margin: 0; line-height: 1.55; }

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 15px;
}
.metric {
  position: relative;
  overflow: hidden;
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--brand);
}
.metric span { color: var(--muted); font-size: 13px; font-weight: 900; }
.metric strong { display: block; margin-top: 10px; font-size: 31px; line-height: 1; }
.metric.danger::before { background: var(--danger); }
.metric.danger strong { color: var(--danger); }

.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.full { grid-column: 1 / -1; }
.form-grid { display: grid; gap: 22px; }
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(220px, 1.4fr) auto;
  gap: 12px;
  align-items: end;
}

.btn {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(15, 23, 42, .10); }
.btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(60, 158, 66, .18); }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 12px 24px rgba(60, 158, 66, .22); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.secondary { border-color: var(--line); background: #fff; color: var(--muted-strong); }
.btn.secondary:hover { border-color: var(--line-strong); background: #f8fafc; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: var(--danger-dark); }
.btn:disabled, .btn.disabled { cursor: not-allowed; opacity: .52; pointer-events: none; transform: none; box-shadow: none; }
.btn.small { min-height: 34px; padding: 7px 10px; font-size: 13px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-actions, .user-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.password-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.password-inline input { width: 168px; min-width: 148px; min-height: 34px; padding: 7px 10px; }

.alert {
  border-radius: var(--radius);
  padding: 13px 15px;
  border: 1px solid transparent;
  font-weight: 800;
  line-height: 1.45;
}
.alert.error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.alert.success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
table { width: 100%; min-width: 860px; border-collapse: separate; border-spacing: 0; }
th {
  padding: 13px 14px;
  background: #f8fafc;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
td {
  padding: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted-strong);
  vertical-align: middle;
}
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: #fbfdff; }
td span { color: var(--muted); }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}
.status-open { background: #dbeafe; color: #1d4ed8; }
.status-analyzing { background: #ede9fe; color: #6d28d9; }
.status-waiting_customer { background: #fef3c7; color: #92400e; }
.status-in_progress { background: var(--brand-soft); color: var(--brand-dark); }
.status-resolved { background: #d1fae5; color: #047857; }
.status-closed { background: #e2e8f0; color: #334155; }
.status-canceled { background: #fee2e2; color: #991b1b; }
.priority-urgent { background: #dc2626; color: #fff; }
.priority-high { background: #f97316; color: #fff; }
.priority-medium { background: #0284c7; color: #fff; }
.priority-normal { background: #475569; color: #fff; }
.priority-low { background: #e2e8f0; color: #334155; }
.badge-line { display: flex; flex-wrap: wrap; gap: 8px; }

.bar-row {
  display: grid;
  grid-template-columns: 136px 1fr 38px;
  align-items: center;
  gap: 12px;
  margin: 13px 0;
  color: var(--muted-strong);
  font-size: 14px;
}
.bar-row div { height: 10px; overflow: hidden; border-radius: 999px; background: #eef2f7; }
.bar-row b { display: block; height: 100%; border-radius: 999px; background: var(--brand); }

.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
.ticket-main, .ticket-side { display: grid; gap: 18px; }
.description { color: var(--muted-strong); line-height: 1.75; }
.remote-box {
  margin-top: 16px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}
.comments { display: grid; gap: 12px; margin-bottom: 16px; }
.comment {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}
.comment.internal { border-color: #fde68a; background: #fffbeb; }
.comment div { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.comment div span { padding: 4px 8px; border-radius: 999px; background: #fff; color: var(--muted); font-size: 12px; font-weight: 900; }
.comment time { margin-left: auto; color: var(--muted); font-size: 12px; }
.comment p { margin-bottom: 0; line-height: 1.65; }
.reply-form { display: grid; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; width: fit-content; }
.check input { width: auto; }
.side-form { display: grid; gap: 12px; }
.side-actions { display: grid; gap: 10px; }
.attachment-list, .history { padding-left: 18px; display: grid; gap: 8px; color: var(--muted-strong); }
.history span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.client-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.client-grid .card { display: grid; gap: 10px; align-content: start; }
.client-grid .card p { margin: 0; line-height: 1.5; color: var(--muted-strong); }
.report-card { max-width: 660px; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .brand { min-height: 88px; }
  .sidebar nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding-top: 0;
  }
  .sidebar nav a { justify-content: center; text-align: center; }
  .sidebar-user {
    grid-template-columns: 1fr auto auto;
    align-items: center;
  }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ticket-layout { grid-template-columns: 1fr; }
  .client-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .topbar { align-items: stretch; flex-direction: column; padding: 16px 20px; }
  .topbar-actions { align-items: stretch; flex-direction: column; }
  .role-pill { width: fit-content; }
  .search { width: 100%; }
  .content { padding: 20px; }
  .grid-two, .grid-three, .filters, .client-grid { grid-template-columns: 1fr; }
  .section-title { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  body { font-size: 14px; }
  .login-body { padding: 14px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: auto; padding: 30px; }
  .login-panel { padding: 30px; }
  .login-brand h1 { font-size: 29px; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-user { grid-template-columns: 1fr; }
  .content { padding: 16px; gap: 18px; }
  .card { padding: 18px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 12px; }
  .metric { min-height: 106px; }
  .metric strong { font-size: 27px; }
  .bar-row { grid-template-columns: 1fr; gap: 6px; }
  .actions, .inline-actions, .user-actions, .password-inline { align-items: stretch; flex-direction: column; }
  .btn, .password-inline input { width: 100%; }
  .pagination {
    align-items: stretch;
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 440px) {
  .metrics { grid-template-columns: 1fr; }
  .sidebar nav { grid-template-columns: 1fr; }
  .login-panel, .login-brand { padding: 24px; }
  .topbar h1, .section-title h2 { font-size: 21px; }
}

@media (max-width: 720px) {
  html, body { overflow-x: hidden; }
  input, select, textarea, .btn { min-height: 44px; }

  .app-shell { display: block; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    border-right: 0;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .18);
  }
  .brand {
    min-height: 68px;
    justify-content: center;
    padding: 10px 14px;
  }
  .brand img { max-width: 132px; max-height: 52px; }
  .sidebar nav {
    display: flex;
    grid-template-columns: none;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 10px 12px 12px;
    scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav a {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 9px 12px;
    white-space: nowrap;
    transform: none;
  }
  .sidebar nav a:hover { transform: none; }
  .sidebar-user {
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    padding: 10px 12px;
    font-size: 12px;
  }
  .sidebar-user strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sidebar-user span { font-size: 11px; }

  .topbar {
    position: static;
    min-height: 0;
    padding: 14px;
  }
  .topbar-actions { gap: 10px; }
  .content {
    width: 100%;
    padding: 14px;
  }
  .section-title { gap: 12px; }
  .section-title .btn { width: 100%; }
  .card {
    padding: 16px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .06);
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }
  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tbody tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
  tbody tr:hover { background: #fff; }
  td {
    display: grid;
    grid-template-columns: minmax(112px, 38%) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 46px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    word-break: break-word;
  }
  td:first-child { border-top: 0; }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
  }
  td:empty::before { content: ""; }
  td:not([data-label]) {
    grid-template-columns: 1fr;
  }
  td:not([data-label])::before {
    display: none;
  }
  td[data-label="Acoes"] {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  td[data-label="Acoes"]::before { display: none; }
  td[data-label="Acoes"] .btn,
  td[data-label="Acoes"] form,
  td[data-label="Acoes"] .user-actions {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .login-body {
    display: block;
    padding: 0;
    background: #fff;
  }
  .login-shell {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .login-brand {
    padding: 24px 20px;
    text-align: center;
  }
  .login-logo {
    width: 168px;
    margin: 0 auto 18px;
  }
  .login-brand h1 { font-size: 25px; }
  .login-brand p { font-size: 14px; }
  .login-panel { padding: 24px 18px; }

  .sidebar-user {
    grid-template-columns: 1fr auto;
  }
  .sidebar-user span { display: none; }
  .topbar span:not(.role-pill) { font-size: 11px; }
  .role-pill { height: 30px; }
  .metrics { grid-template-columns: 1fr; }
  .metric {
    min-height: 90px;
    padding: 16px;
  }
  .metric strong { font-size: 28px; }
  .grid-two,
  .grid-three,
  .filters,
  .client-grid {
    gap: 14px;
  }
  .comment div {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .comment time { margin-left: 0; }
  .badge-line { width: 100%; }
  .badge-line > span { justify-content: center; width: 100%; }
  .report-card { max-width: none; }
  td {
    grid-template-columns: 1fr;
    gap: 5px;
  }
  td::before { letter-spacing: .02em; }
}
