/* COMANFY® Atendimento — identidade: preto, branco e laranja #FF7400 */
:root {
  --orange: #FF7400;
  --orange-600: #e26600;
  --orange-50: #fff3e9;
  --black: #0d0d0d;
  --ink: #1a1a1a;
  --ink-2: #444;
  --muted: #777;
  --line: #e7e7e7;
  --bg: #f5f5f4;
  --white: #fff;
  --green: #1f9d55;
  --red: #d93025;
  --yellow: #c98a00;
  --blue: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --sidebar-w: 248px;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--orange-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
[hidden] { display: none !important; }

/* ---------- Estrutura ---------- */
.shell { display: flex; min-height: 100vh; background: linear-gradient(to right, var(--black) var(--sidebar-w), transparent var(--sidebar-w)); }
.sidebar { width: var(--sidebar-w); background: var(--black); color: #d6d6d6; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: block; padding: 20px 20px 14px; color: #fff; border-bottom: 1px solid #222; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 150px; display: block; }
.brand-sub { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--orange); margin-top: 6px; }
.nav { padding: 10px 8px 24px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #cfcfcf; font-size: 13.5px; position: relative; }
.nav-item svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; flex-shrink: 0; }
.nav-item:hover { background: #1c1c1c; color: #fff; text-decoration: none; }
.nav-item.active { background: var(--orange); color: #fff; }
.nav-item.active svg { opacity: 1; }
.nav-badge { margin-left: auto; background: var(--orange); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 7px; font-weight: 700; }
.nav-item.active .nav-badge { background: #fff; color: var(--orange); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--white); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.page-title { font-size: 1.1rem; margin: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-toggle { display: none; }
.content { padding: 22px; flex: 1; }
.availability select, .company-switch select { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; background: #fff; font-size: 13px; }
.avail-online { color: var(--green); } .avail-away { color: var(--yellow); } .avail-offline { color: var(--muted); }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--black); color: var(--orange); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.dropdown { position: absolute; right: 0; top: 42px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 220px; padding: 6px; z-index: 30; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; color: var(--ink); border-radius: 6px; font: inherit; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--bg); text-decoration: none; }

/* ---------- Componentes ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.7rem; font-weight: 800; margin-top: 4px; }
.stat-hint { font-size: 12px; color: var(--muted); }
.stat.accent { border-top: 3px solid var(--orange); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; background: var(--black); color: #fff; text-decoration: none; line-height: 1.2; }
.btn:hover { text-decoration: none; filter: brightness(1.15); }
.btn-primary { background: var(--orange); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn:hover { background: var(--bg); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafafa; }
.table tr:hover td { background: #fcfcfc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #eee; color: var(--ink-2); white-space: nowrap; }
.badge-orange { background: var(--orange-50); color: var(--orange-600); }
.badge-green { background: #e7f6ee; color: var(--green); }
.badge-red { background: #fde8e7; color: var(--red); }
.badge-yellow { background: #fdf3d9; color: var(--yellow); }
.badge-blue { background: #e7efff; color: var(--blue); }
.badge-black { background: var(--black); color: #fff; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-ok { background: #e9f7ef; border-color: #bfe5cf; color: #14653a; }
.alert-warn { background: #fff6e5; border-color: #ffd9a3; color: #8a5300; }
.alert-err { background: #fdecea; border-color: #f5c2bd; color: #a3221a; }

/* Formulários */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .label { font-weight: 600; font-size: 13px; }
.field small, .help { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], input[type=time], input[type=search], input[type=tel], select, textarea {
  width: 100%; border: 1px solid #d9d9d9; border-radius: 8px; padding: 9px 11px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,116,0,.15); }
textarea { resize: vertical; min-height: 90px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.inline-form { display: inline; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 160px; }

/* Chave liga/desliga */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 22px; background: #cfcfcf; border-radius: 999px; position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; width: 18px; height: 18px; top: 2px; left: 2px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--orange); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(255,116,0,.3); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a.active { color: var(--orange-600); border-color: var(--orange); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.pagination { display: flex; gap: 4px; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
.pagination .active span, .pagination span[aria-current] { background: var(--orange); color: #fff; border-color: var(--orange); }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.bar { height: 8px; background: #eee; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--orange); }

/* Login */
.auth-body { background: var(--black); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: #fff; border-radius: 14px; padding: 32px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.4); border-top: 4px solid var(--orange); }
.auth-card .brand-logo { width: 180px; margin-bottom: 6px; }
.auth-card h1 { font-size: 1.2rem; margin: 18px 0 16px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { background: none; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  .menu-toggle { display: inline-flex; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .user-name { display: none; }
  .kv { grid-template-columns: 1fr; }
}
