* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Roboto, Arial, sans-serif; color: #1f2430; background: #eef1f4; }
:root { --brand: #1f5fae; }

/* ---------- Portal ---------- */
.portal-hero {
  background: linear-gradient(90deg, var(--brand), #2b7fd1);
  color: #fff; padding: 42px 20px; text-align: center;
}
.portal-hero h1 { margin: 0; font-size: 28px; font-weight: 600; }
.hero-logo { height: 96px; background: #fff; padding: 12px 20px; border-radius: 12px; margin-bottom: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.15); max-width: 90%; object-fit: contain; }
.portal-foot { text-align: center; color: #8a93a0; font-size: 12px; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hub { display: flex; gap: 18px; margin-top: 18px; flex-wrap: wrap; }
.hub-option { flex: 1; min-width: 200px; text-decoration: none; color: inherit; border: 1px solid #e4e9ef; border-radius: 12px; padding: 26px 18px; text-align: center; transition: all .15s; background: #fff; }
.hub-option:hover { border-color: var(--brand); box-shadow: 0 6px 20px rgba(0,0,0,.10); transform: translateY(-2px); }
.hub-ico { font-size: 40px; margin-bottom: 10px; }
.hub-title { font-size: 18px; font-weight: 600; color: var(--brand); margin-bottom: 4px; }
.hub-sub { font-size: 13px; color: #5b6472; }
.foot-logo { height: 34px; opacity: .9; }
.portal-wrap { max-width: 680px; margin: -28px auto 40px; padding: 0 16px; }
.card {
  background: #fff; border-radius: 10px; padding: 28px 26px;
  box-shadow: 0 6px 24px rgba(0,0,0,.08);
}
.card h2 { margin: 0 0 6px; font-size: 20px; }
.muted { color: #5b6472; font-size: 14px; line-height: 1.5; margin: 0 0 12px; }
.contact { font-size: 13px; color: var(--brand); font-weight: 600; margin: 0 0 16px; }
.ticket-form label { display: block; font-size: 13px; font-weight: 600; color: #38414f; margin-bottom: 14px; }
.ticket-form input, .ticket-form textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid #cfd6df; border-radius: 6px; font-size: 14px; font-weight: 400;
}
.ticket-form input:focus, .ticket-form textarea:focus { outline: none; border-color: var(--brand); }
.req { color: #d33; }
button, .btn {
  background: var(--brand); color: #fff; border: none; border-radius: 6px;
  padding: 11px 22px; font-size: 15px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { filter: brightness(1.08); }
.alert { background: #fdecea; color: #b3261e; padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.center { text-align: center; }
.check { width: 60px; height: 60px; line-height: 60px; border-radius: 50%; background: #e6f4ea; color: #1e8e3e; font-size: 32px; margin: 0 auto 12px; }
.reference { font-size: 26px; font-weight: 700; color: var(--brand); letter-spacing: 1px; margin: 6px 0 14px; }

/* ---------- Console visual polish ---------- */
.console { background: #eef1f5; }
.topbar { background: linear-gradient(90deg,#0f2036,#1b3a5c); color: #fff; padding: 12px 22px; display: flex; align-items: center; gap: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: .2px; }
.topbar a:hover { text-decoration: underline; }
.topbar button { border-radius: 6px; cursor: pointer; }
.topbar select, .topbar input[type=search] { box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.toolbar { background: #fff; border-bottom: 1px solid #dfe4ea; padding: 10px 22px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .filters { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.toolbar select { padding: 7px 10px; border-radius: 6px; border: 1px solid #cfd6df; font-size: 13px; background: #fff; }
.layout { height: calc(100vh - 47px - 57px); }
table.tickets th { text-transform: uppercase; letter-spacing: .4px; font-size: 11px; background: #e9edf2; }
table.tickets td { padding: 11px 10px; }
table.tickets tr:hover { background: #eef4fb; }
table.tickets tr.sel { background: #dcebfb; box-shadow: inset 3px 0 0 var(--brand,#1f5fae); }
.detail { background: #eef1f5; }
.detail .desc, .detail .fields, .comment, .attachments, .assign-bar, .sla-bar { box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.detail h2 { font-size: 20px; }
.status-picker button, .prio-picker button { transition: all .12s; }

/* ---------- Dashboard ---------- */
.dash { max-width: 1150px; margin: 22px auto; padding: 0 18px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { background: #fff; border-radius: 12px; padding: 18px 20px; box-shadow: 0 4px 14px rgba(0,0,0,.06); border-left: 5px solid var(--accent, #1f5fae); }
.kpi-value { font-size: 34px; font-weight: 700; color: var(--accent, #1f5fae); line-height: 1; }
.kpi-label { font-size: 13px; color: #38414f; margin-top: 8px; font-weight: 600; }
.kpi-sub { font-size: 11px; color: #8a93a0; margin-top: 2px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-card { background: #fff; border-radius: 12px; padding: 18px 20px; box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.chart-card h3 { margin: 0 0 14px; font-size: 15px; color: #2a3442; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.bar-label { color: #38414f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #eef1f5; border-radius: 6px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; min-width: 3px; transition: width .4s; }
.bar-val { text-align: right; font-weight: 600; color: #2a3442; }
@media (max-width: 800px){ .chart-grid { grid-template-columns: 1fr; } }

.topbar { background: linear-gradient(90deg,#0f2036,#1b3a5c); color: #fff; padding: 12px 22px; display: flex; align-items: center; gap: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.brand-logo { height: 30px; background: #fff; padding: 3px 6px; border-radius: 5px; }
.admin-logo { height: 40px; background: #fff; padding: 3px 6px; border-radius: 5px; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
.topbar .filters { margin-left: auto; display: flex; gap: 8px; }
.topbar select { padding: 6px 10px; border-radius: 6px; border: none; font-size: 13px; }
.layout { display: flex; height: calc(100vh - 47px - 57px); }
.list { width: 46%; overflow-y: auto; border-right: 1px solid #dfe4ea; }
.detail { flex: 1; overflow-y: auto; padding: 20px; }
table.tickets { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tickets th { text-align: left; padding: 11px 10px; background: #e9edf2; position: sticky; top: 0; color: #4a5461; text-transform: uppercase; letter-spacing: .4px; font-size: 11px; z-index: 1; }
table.tickets td { padding: 11px 10px; border-bottom: 1px solid #eceff2; }
table.tickets tr { cursor: pointer; }
table.tickets tr:hover { background: #eef4fb; }
table.tickets tr.sel { background: #dcebfb; box-shadow: inset 3px 0 0 var(--brand,#1f5fae); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.st-New { background: #e8f0fe; color: #1a56c4; }
.st-Open { background: #fff4e5; color: #b7791f; }
.st-Pending { background: #f3e8fd; color: #7c3aed; }
.st-Resolved { background: #e6f4ea; color: #1e8e3e; }
.st-Closed { background: #eceff2; color: #5b6472; }
.detail h2 { margin: 0 0 4px; }
.detail .meta { color: #5b6472; font-size: 13px; margin-bottom: 16px; }
.detail .fields { background: #fff; border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; border: 1px solid #e4e9ef; }
.detail .fields div { font-size: 13px; padding: 4px 0; }
.detail .fields b { color: #38414f; }
.desc { background: #fff; border-radius: 8px; padding: 14px 16px; border: 1px solid #e4e9ef; white-space: pre-wrap; margin-bottom: 16px; }
.comment { background: #fff; border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; border: 1px solid #e4e9ef; }
.comment.internal { background: #fffbe6; border-color: #f0e2a8; }
.comment .who { font-weight: 600; font-size: 13px; }
.comment .when { color: #8a93a0; font-size: 11px; }
.comment .body { margin-top: 6px; white-space: pre-wrap; font-size: 14px; }
.reply { margin-top: 16px; }
.reply textarea { width: 100%; min-height: 70px; padding: 10px; border: 1px solid #cfd6df; border-radius: 6px; font-size: 14px; }
.reply .row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.status-picker { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.status-picker button { background: #fff; color: #38414f; border: 1px solid #cfd6df; padding: 6px 12px; font-size: 12px; }
.status-picker button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.wa-btn { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; background: #25d366; color: #fff; text-decoration: none; padding: 8px 16px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; }
.wa-btn:hover { filter: brightness(1.05); }
.wa-btn small { font-weight: 400; opacity: .9; font-size: 11px; }
.attachments { background: #fff; border: 1px solid #e4e9ef; border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px; }
.attachments .att { display: inline-flex; align-items: center; gap: 4px; background: #eef4fb; color: #1a56c4; border-radius: 6px; padding: 5px 10px; margin: 6px 6px 0 0; text-decoration: none; }
.attachments .att:hover { background: #dcebfb; }
.attachments .att small { color: #5b6472; }
.assign-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #f4f6f8; border: 1px solid #e4e9ef; border-radius: 8px; padding: 8px 12px; margin-bottom: 14px; font-size: 13px; }
/* SLA */
.sla-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.sla-red { background: #d93025; } .sla-yellow { background: #f9ab00; } .sla-green { background: #1e8e3e; }
.age { font-size: 11px; color: #8a93a0; margin-top: 2px; }
.sla-bar { display: flex; align-items: center; gap: 6px; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }
.sla-bar-red { background: #fdecea; color: #b3261e; } .sla-bar-yellow { background: #fef7e0; color: #8a6116; } .sla-bar-green { background: #e6f4ea; color: #1e7a34; }
.sla-bar .muted { font-weight: 400; }
.prio-picker { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.prio-picker button { background: #fff; color: #38414f; border: 1px solid #cfd6df; padding: 5px 12px; font-size: 12px; border-radius: 6px; cursor: pointer; }
.prio-picker button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.prio { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.prio-Low { background: #eceff2; color: #5b6472; }
.prio-Normal { background: #e8f0fe; color: #1a56c4; }
.prio-High { background: #fff4e5; color: #b7791f; }
.prio-Urgent { background: #fdecea; color: #d93025; }
.empty { color: #8a93a0; padding: 40px; text-align: center; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; font-size: 13px; color: #5b6472; }
.pager button { background: #fff; color: #38414f; border: 1px solid #cfd6df; padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.pager button:disabled { opacity: .5; cursor: default; }
/* Knowledge base */
.kb-item { padding: 12px 14px; border-bottom: 1px solid #eceff2; cursor: pointer; }
.kb-item:hover { background: #eef4fb; }
.kb-item.sel { background: #dcebfb; box-shadow: inset 3px 0 0 var(--brand,#1f5fae); }
.kb-item-title { font-weight: 600; font-size: 14px; color: #1f2430; }
.kb-item-meta { font-size: 11px; color: #8a93a0; margin-top: 3px; }
.kb-tags { margin-top: 6px; }
.kb-tag { display: inline-block; background: #eef1f5; color: #5b6472; border-radius: 10px; padding: 1px 8px; font-size: 11px; margin: 2px 4px 0 0; }
.kb-inline { margin: 12px 0; }
.kb-save-btn { display: inline-block; background: #fef7e0; color: #8a6116; border: 1px solid #f0e2a8; border-radius: 8px; padding: 8px 14px; text-decoration: none; font-size: 13px; font-weight: 600; }
.kb-save-btn:hover { filter: brightness(.98); }
.kb-suggest { background: #eef7ff; border: 1px solid #cfe0f5; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.kb-suggest-link { display: block; color: var(--brand,#1f5fae); text-decoration: none; margin-top: 5px; }
.kb-suggest-link:hover { text-decoration: underline; }
.kb-detail .desc { white-space: pre-wrap; }
.kb-pub { display:inline-block; background:#e6f4ea; color:#1e7a34; border-radius:10px; padding:1px 8px; font-size:11px; font-weight:600; }
/* Public FAQ */
.faq-list { margin-top: 14px; }
.faq-item { display:block; text-decoration:none; color:inherit; border:1px solid #e4e9ef; border-radius:10px; padding:14px 16px; margin-bottom:10px; transition: all .12s; background:#fff; }
.faq-item:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.faq-item-title { font-weight:600; color: var(--brand); font-size:15px; }
.faq-item-sub { font-size:13px; color:#5b6472; margin-top:4px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10,20,35,.5); display: flex; align-items: flex-start; justify-content: center; z-index: 50; overflow-y: auto; padding: 40px 16px; }
.modal { background: #fff; border-radius: 10px; padding: 22px 24px; width: 560px; max-width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 14px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: #38414f; margin-bottom: 12px; }
.modal input, .modal textarea, .modal select { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid #cfd6df; border-radius: 6px; font-size: 14px; font-family: inherit; }
.modal textarea { white-space: pre-wrap; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.btn-ghost { background: #fff; color: #38414f; border: 1px solid #cfd6df; }
.msg { font-size: 12px; margin: 4px 0; }
.msg.ok { color: #1e8e3e; } .msg.err { color: #b3261e; }
