/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Kamico Brand Colors */
  --brand: #DE002E;
  --brand-hover: #b8001f;
  --brand-light: #fff0f3;
  --brand-2: #F53461;
  --brand-muted: #ffd6de;

  /* Neutrals (from PPTX) */
  --dark: #0D0D0D;
  --dark-2: #453D3F;
  --gray-mid: #535353;
  --gray-light: #C7C7C7;
  --gray-lighter: #D9D9D9;
  --bg: #F5F4E9;
  --bg-warm: #FFFEF4;
  --surface: #FFFFFF;
  --border: #E2E0D5;
  --text: #0D0D0D;
  --text-muted: #535353;

  /* Semantic */
  --success: #1a7a4a;
  --success-light: #d6f5e3;
  --warning: #b86e00;
  --warning-light: #fff3cd;
  --danger: #DE002E;
  --danger-light: #fff0f3;
  --info: #005b8e;
  --info-light: #ddeeff;

  /* Layout */
  --sidebar-w: 256px;
  --header-h: 60px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 8px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 24px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

body { font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; min-height: 100vh; }

/* ===== LOGIN SCREEN ===== */
#login-screen {
  position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.login-box {
  background: var(--surface); border-radius: 14px; padding: 48px 40px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.login-logo { margin-bottom: 28px; }
.login-logo .logo-mark { width: 64px; height: 64px; background: var(--brand); border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; color: #fff; margin-bottom: 12px; letter-spacing: -1px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-box .form-group { text-align: left; }
.login-box .btn-primary { width: 100%; justify-content: center; padding: 10px; font-size: 15px; margin-top: 4px; }
.login-error { background: var(--danger-light); color: var(--brand); border: 1px solid var(--brand-muted); border-radius: 6px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; display: none; }
.login-footer { margin-top: 24px; font-size: 12px; color: var(--text-muted); }

/* ===== SIDEBAR ===== */
#app-shell { display: none; }
#app-shell.visible { display: flex; }

#sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
  background: var(--dark); color: #c9cdd4; display: flex; flex-direction: column;
  z-index: 100; transition: transform .3s;
}
#sidebar .logo {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08); background: #000;
}
.logo-mark-sm { width: 36px; height: 36px; background: var(--brand); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; font-size: 15px; flex-shrink: 0; letter-spacing: -1px; }
.logo-text-sm { font-size: 14px; font-weight: 700; color: #fff; line-height: 1.2; }
.logo-sub-sm { font-size: 11px; color: #8a9099; }

#sidebar nav { flex: 1; overflow-y: auto; padding: 10px 0; }
#sidebar nav::-webkit-scrollbar { width: 3px; }
#sidebar nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.nav-section { padding: 10px 16px 3px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #525b68; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 18px;
  cursor: pointer; border-radius: 6px; margin: 1px 8px;
  transition: background .15s, color .15s; color: #9aa5b1; font-size: 13px;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #e0e5ea; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item .nav-icon { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; fill: none; display: block; }

#sidebar .sidebar-footer {
  padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11.5px; color: #525b68;
  display: flex; align-items: center; justify-content: space-between;
}
.btn-logout { background: none; border: none; color: #9aa5b1; cursor: pointer; font-size: 11.5px; padding: 4px 8px; border-radius: 4px; transition: background .15s; }
.btn-logout:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ===== MAIN LAYOUT ===== */
#main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
#topbar {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px; box-shadow: var(--shadow);
}
#topbar h1 { font-size: 17px; font-weight: 600; color: var(--text); flex: 1; }
#topbar .topbar-user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
#topbar .user-avatar { width: 32px; height: 32px; background: var(--brand); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; }
#content { flex: 1; padding: 24px; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); border-left: 4px solid var(--gray-light); display: flex; flex-direction: column; gap: 6px;
}
.stat-card.red { border-color: var(--brand); }
.stat-card.green { border-color: var(--success); }
.stat-card.yellow { border-color: var(--warning); }
.stat-card.dark { border-color: var(--dark-2); }
.stat-card.info { border-color: var(--info); }
.stat-card .stat-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); }
.stat-card .stat-icon { font-size: 24px; margin-bottom: 4px; }

/* ===== CARD ===== */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.card-header h2 { font-size: 14px; font-weight: 600; flex: 1; color: var(--text); }
.card-body { padding: 20px; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: 13.5px; font-weight: 600; cursor: pointer; border: 1.5px solid transparent; transition: all .15s; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(.9); }
.btn-danger { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-danger:hover { background: var(--brand-hover); }
.btn-outline { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn-outline:hover { background: var(--brand-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }
.btn-icon { padding: 6px 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.form-group label .req { color: var(--brand); margin-left: 3px; }
.form-control {
  padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 6px;
  font-size: 13.5px; background: var(--surface); color: var(--text); width: 100%;
  transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(222,0,46,.1); }
.form-control:disabled { background: var(--bg); color: var(--text-muted); }
.form-control.error { border-color: var(--brand); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.form-error { font-size: 11.5px; color: var(--brand); }

/* ===== TABLES ===== */
.table-container { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 10px 14px; text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-muted); background: var(--bg); border-bottom: 1.5px solid var(--border); white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-warm); }
.table-empty { text-align: center; padding: 52px; color: var(--text-muted); }
.table-empty .empty-icon { font-size: 36px; margin-bottom: 10px; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; letter-spacing: .02em; }
.badge-green { background: var(--success-light); color: #0f5132; }
.badge-red { background: var(--danger-light); color: var(--brand); }
.badge-yellow { background: var(--warning-light); color: #7c4a00; }
.badge-blue { background: var(--info-light); color: var(--info); }
.badge-gray { background: #f0eeea; color: var(--gray-mid); }
.badge-dark { background: #e8e6e2; color: var(--dark-2); }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(13,13,13,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .15s;
}
.modal {
  background: var(--surface); border-radius: 12px; width: 100%; max-width: 680px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slideUp .2s;
}
.modal.modal-lg { max-width: 860px; }
.modal.modal-xl { max-width: 1040px; }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.modal-header h3 { font-size: 16px; font-weight: 700; flex: 1; color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--bg); border-radius: 0 0 12px 12px; }
.btn-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 20px; padding: 2px 6px; border-radius: 4px; transition: background .15s, color .15s; line-height: 1; }
.btn-close:hover { background: var(--bg); color: var(--text); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

/* ===== TOOLBAR ===== */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 300px; }
.search-box input { padding-left: 34px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; pointer-events: none; }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 0; }
.tab { padding: 10px 18px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-muted); border-bottom: 2.5px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab:hover:not(.active) { color: var(--text); background: var(--bg); border-radius: 6px 6px 0 0; }

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: 6px; font-size: 13px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.alert-info { background: var(--info-light); color: var(--info); border: 1px solid #aad3f5; }
.alert-warning { background: var(--warning-light); color: #7c4a00; border: 1px solid #ffc107; }
.alert-success { background: var(--success-light); color: #0f5132; border: 1px solid #a3e6c0; }
.alert-danger { background: var(--danger-light); color: var(--brand); border: 1px solid var(--brand-muted); }

/* ===== MISC ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-mono { font-family: 'Consolas', 'Courier New', monospace; font-size: 12px; }
.code-badge { background: var(--brand-light); border: 1px solid var(--brand-muted); border-radius: 4px; padding: 2px 7px; font-family: monospace; font-size: 12px; color: var(--brand); font-weight: 700; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ===== TOAST ===== */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 8px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); animation: slideToast .3s ease; max-width: 360px; display: flex; align-items: center; gap: 10px; }
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--brand); color: #fff; }
.toast-info { background: var(--dark); color: #fff; }
@keyframes slideToast { from { transform: translateX(100%); opacity: 0 } to { transform: translateX(0); opacity: 1 } }

/* ===== FILE UPLOAD ===== */
.file-upload-area { border: 2px dashed var(--border); border-radius: 8px; padding: 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; color: var(--text-muted); }
.file-upload-area:hover, .file-upload-area.dragover { border-color: var(--brand); background: var(--brand-light); }
.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg); border-radius: 6px; font-size: 12.5px; border: 1px solid var(--border); }
.file-item .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-remove-file { color: var(--brand); cursor: pointer; background: none; border: none; font-size: 14px; padding: 0 4px; }

/* ===== CHARTS ===== */
.chart-bar-container { display: flex; flex-direction: column; gap: 10px; }
.chart-bar-row { display: flex; align-items: center; gap: 12px; }
.chart-bar-label { width: 140px; font-size: 12px; color: var(--text); text-align: right; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar-track { flex: 1; background: var(--bg); border-radius: 4px; height: 22px; overflow: hidden; border: 1px solid var(--border); }
.chart-bar-fill { height: 100%; border-radius: 3px; transition: width .5s ease; display: flex; align-items: center; padding-left: 8px; font-size: 11px; font-weight: 700; color: #fff; min-width: 24px; }
.chart-bar-val { width: 70px; font-size: 12px; font-weight: 600; color: var(--text); flex-shrink: 0; }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.pagination-btns { display: flex; gap: 4px; }
.page-btn { padding: 5px 10px; border: 1.5px solid var(--border); border-radius: 5px; background: var(--surface); cursor: pointer; font-size: 12.5px; color: var(--text); transition: all .15s; font-weight: 600; }
.page-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.page-btn:hover:not(.active):not(:disabled) { background: var(--bg); border-color: var(--brand); color: var(--brand); }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ===== DETAIL VIEW ===== */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.detail-item { padding: 14px 16px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.detail-item .detail-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 4px; }
.detail-item .detail-value { font-size: 14px; font-weight: 500; color: var(--text); }


/* ===== ALERT BAR GLOBAL ===== */
#alert-bar { width: 100%; }
.alert-global { display:flex; align-items:center; gap:10px; padding:10px 24px; font-size:13px; flex-wrap:wrap; }
.alert-global-danger  { background:#fef2f2; border-bottom:2px solid #fca5a5; color:#991b1b; }
.alert-global-warning { background:#fffbeb; border-bottom:2px solid #fde68a; color:#92400e; }
.alert-global-icon { font-size:16px; flex-shrink:0; }
.alert-global-msg  { flex:1; line-height:1.5; }
.alert-global-btn  { flex-shrink:0; background:rgba(0,0,0,0.12); border:none; color:inherit; padding:4px 12px; border-radius:5px; cursor:pointer; font-size:12px; font-weight:600; }
.alert-global-btn:hover { background:rgba(0,0,0,0.22); }

/* ===== CHAMADOS / HELPDESK ===== */
.nav-badge { display:inline-flex; align-items:center; justify-content:center; min-width:18px; height:18px; padding:0 5px; background:var(--brand); color:#fff; font-size:10px; font-weight:700; border-radius:9px; margin-left:6px; }
.sla-ok       { color:#1a7a4a; font-weight:600; }
.sla-warning  { color:#b86e00; font-weight:600; }
.sla-critical { color:#c2410c; font-weight:700; }
.sla-overdue  { color:var(--brand); font-weight:700; }
.chat-container { flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:8px; padding:12px; background:var(--bg); border-radius:8px; min-height:200px; max-height:400px; border:1.5px solid var(--border); }
.msg-sistema  { text-align:center; font-size:11.5px; color:var(--text-muted); padding:4px 10px; background:var(--border); border-radius:20px; align-self:center; max-width:90%; }
.msg-public   { background:var(--surface); border:1px solid var(--border); border-radius:10px 10px 10px 2px; padding:10px 14px; max-width:80%; align-self:flex-start; }
.msg-admin    { background:var(--brand-light); border:1px solid var(--brand-muted); border-radius:10px 10px 2px 10px; padding:10px 14px; max-width:80%; align-self:flex-end; }
.msg-interna  { background:#fffbeb; border:1.5px dashed #fde68a; border-radius:8px; padding:10px 14px; max-width:90%; align-self:stretch; font-size:13px; }
.chamado-card { background:var(--surface); border:1.5px solid var(--border); border-radius:10px; padding:16px 20px; cursor:pointer; transition:border-color .15s,box-shadow .15s; margin-bottom:10px; }
.chamado-card:hover { border-color:var(--brand); box-shadow:var(--shadow-md); }
.portal-wrap  { max-width:780px; margin:0 auto; padding:28px 20px; }
.sla-matrix   { border-collapse:collapse; width:100%; }
.sla-matrix th, .sla-matrix td { border:1px solid var(--border); }
.sla-matrix th { background:var(--bg); font-size:11px; font-weight:700; padding:6px 10px; text-transform:uppercase; }
.sla-matrix-inp { border:1.5px solid var(--border); border-radius:5px; background:var(--surface); color:var(--text); font-family:inherit; }
.sla-matrix-inp:focus { outline:none; border-color:var(--brand); }

/* ===== PRINT ===== */
@media print {
  #login-screen, #sidebar, .no-print { display: none !important; }
  #main { margin-left: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
