* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: #f4f6fb; color: #1a1f36; min-height: 100vh; }
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: linear-gradient(180deg, #1a2332 0%, #0f1728 100%); color: #b0bccd; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-brand h3 { font-size: 1.1rem; font-weight: 700; color: #fff; margin: 0; letter-spacing: -0.3px; }
.sidebar-brand small { display: block; font-size: 0.75rem; color: #6b7a99; margin-top: 4px; }
.sidebar-nav { padding: 12px 0; }
.nav-item { padding: 10px 20px; display: flex; align-items: center; gap: 12px; color: #8896b0; font-size: 0.875rem; font-weight: 500; border-left: 3px solid transparent; text-decoration: none; }
.nav-item i { font-size: 1.1rem; width: 22px; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: #d1d9e8; }
.nav-item.active { background: rgba(79,70,229,0.14); color: #a5b4fc; border-left-color: #6366f1; }
.nav-item .badge-count { margin-left: auto; background: #ef4444; color: #fff; border-radius: 10px; font-size: .68rem; padding: 1px 7px; font-weight: 700; }
.main-content { flex: 1; padding: 26px 32px; min-width: 0; }
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.4px; color: #0f172a; margin: 0; }
.panel { background: #fff; border: 1px solid #eef2f6; border-radius: 16px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 10px rgba(0,0,0,.03); }
.panel h2 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }
.btn-brand { background: #4f46e5; border: none; border-radius: 10px; padding: 8px 18px; font-weight: 600; color: #fff; font-size: .85rem; }
.btn-brand:hover { background: #4338ca; color: #fff; }
.btn-brand:disabled { opacity: .6; }
.btn-ghost { border: 1px solid #dbe2ec; background: #fff; border-radius: 10px; padding: 7px 14px; font-size: .82rem; font-weight: 600; color: #475569; }
.btn-ghost:hover { background: #f8fafc; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { border: 1px solid #dbe2ec; background: #fff; border-radius: 10px; padding: 7px 14px; font-size: .82rem; font-weight: 600; color: #475569; cursor: pointer; }
.tab.active { background: #1e1b4b; border-color: #1e1b4b; color: #fff; }
.tab .n { opacity: .65; font-weight: 500; margin-left: 4px; }
table.tk { width: 100%; font-size: .86rem; }
table.tk th { font-size: .72rem; text-transform: uppercase; color: #64748b; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid #eef2f6; white-space: nowrap; text-align: left; }
table.tk td { padding: 11px 10px; border-bottom: 1px solid #f4f6fb; vertical-align: top; }
table.tk tr.trow { cursor: pointer; }
table.tk tr.trow:hover { background: #eef2ff; }
table.tk tr.trow:hover .tlink b { color: #4338ca; }
.tlink { color: inherit; text-decoration: none; }
.tlink:hover { text-decoration: underline; }
table.tk td.go { width: 36px; text-align: right; color: #6366f1; font-size: 1.05rem; }
table.tk td.go i { opacity: 0; transform: translateX(-6px); transition: opacity .15s, transform .15s; }
table.tk tr.trow:hover td.go i { opacity: 1; transform: translateX(0); }
table.tk tr.unread td.subj b { color: #0f172a; }
.subj b { font-weight: 600; }
.preview { color: #94a3b8; font-size: .8rem; max-width: 520px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-block; font-size: .7rem; font-weight: 700; border-radius: 12px; padding: 2px 9px; text-transform: capitalize; }
.st-open { background: #dbeafe; color: #1d4ed8; } .st-pending { background: #fef3c7; color: #92400e; }
.st-resolved { background: #d1fae5; color: #047857; } .st-closed { background: #e2e8f0; color: #475569; }
.pr-low { background: #f1f5f9; color: #64748b; } .pr-normal { background: #eef2ff; color: #4338ca; }
.pr-high { background: #ffedd5; color: #c2410c; } .pr-urgent { background: #fee2e2; color: #b91c1c; }
.dot-reply { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; margin-right: 6px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { border: 1px solid #dbe2ec; border-radius: 10px; padding: 7px 12px; font-size: .85rem; background: #fff; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .ticket-layout { grid-template-columns: 1fr; } .sidebar { display: none; } .main-content { padding: 16px; } }
.msg { border: 1px solid #eef2f6; border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; background: #fff; }
.msg.inbound { border-left: 4px solid #6366f1; }
.msg.outbound { border-left: 4px solid #10b981; background: #f7fffb; }
.msg.note { border-left: 4px solid #f59e0b; background: #fffbeb; }
.msg.activity { border: none; background: none; padding: 2px 8px; margin-bottom: 8px; text-align: center; color: #94a3b8; font-size: .78rem; }
.msg .meta { display: flex; justify-content: space-between; gap: 10px; font-size: .78rem; color: #64748b; margin-bottom: 8px; flex-wrap: wrap; }
.msg .meta b { color: #1e293b; font-size: .86rem; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; font-size: .9rem; line-height: 1.5; }
.msg .quoted { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e2e8f0; color: #64748b; font-size: .82rem; }
.toggle-quote { font-size: .75rem; color: #6366f1; cursor: pointer; background: none; border: none; padding: 0; margin-top: 6px; }
.att { display: inline-flex; gap: 6px; align-items: center; font-size: .78rem; background: #f1f5f9; border-radius: 8px; padding: 4px 10px; margin: 8px 6px 0 0; color: #334155; text-decoration: none; }
.att:hover { background: #e2e8f0; }
.reply-box textarea { width: 100%; min-height: 150px; border: 1px solid #dbe2ec; border-radius: 12px; padding: 12px; font-size: .9rem; resize: vertical; }
.reply-box.note-mode textarea { background: #fffbeb; border-color: #fcd34d; }
.prop { margin-bottom: 14px; }
.prop label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .4px; color: #64748b; font-weight: 600; margin-bottom: 4px; }
.prop select, .prop input { width: 100%; border: 1px solid #dbe2ec; border-radius: 10px; padding: 7px 10px; font-size: .86rem; background: #fff; }
.mail-banner { background: #fef3c7; color: #92400e; border-radius: 12px; padding: 10px 14px; font-size: .85rem; margin-bottom: 16px; }

/* ticket page: list pane + conversation */
.main-content.split { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; padding: 16px 20px; align-items: start; }
.tdetail { min-width: 0; }
.tlist { background: #fff; border: 1px solid #eef2f6; border-radius: 16px; box-shadow: 0 2px 10px rgba(0,0,0,.03); position: sticky; top: 16px; height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.tlist-head { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid #eef2f6; }
.tlist-head input { flex: 1; min-width: 0; border: 1px solid #dbe2ec; border-radius: 10px; padding: 7px 10px; font-size: .84rem; }
.tlist-head select { border: 1px solid #dbe2ec; border-radius: 10px; padding: 6px 8px; font-size: .82rem; background: #fff; }
.tlist-items { flex: 1; overflow-y: auto; }
.titem { display: block; padding: 10px 14px; border-bottom: 1px solid #f1f5f9; text-decoration: none; color: inherit; border-left: 3px solid transparent; cursor: pointer; }
.titem:hover { background: #f5f7ff; color: inherit; }
.titem.active { background: #eef2ff; border-left-color: #6366f1; }
.titem .t1 { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: #64748b; }
.titem .t1 b { color: #1e293b; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titem .t2 { font-size: .84rem; font-weight: 600; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0; }
.titem .t3 { display: flex; justify-content: space-between; align-items: center; font-size: .74rem; color: #94a3b8; }
.tlist-foot { padding: 8px 10px; border-top: 1px solid #eef2f6; display: flex; justify-content: space-between; align-items: center; }
.ticket-layout { grid-template-columns: minmax(0, 1fr) 260px; }
@media (max-width: 1450px) {
    .ticket-layout { grid-template-columns: minmax(0, 1fr); }
    .ticket-layout > div:nth-child(2) { display: contents; }                      /* properties + customer panels become grid items */
    .ticket-layout > div:nth-child(2) > .panel:first-child { order: -1; margin-bottom: 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; align-items: end; }
    .ticket-layout > div:nth-child(2) > .panel:first-child .prop { margin: 0; }
    .ticket-layout > div:nth-child(2) > .panel:first-child .btn-ghost { width: auto !important; }
    .ticket-layout > div:nth-child(2) > .panel:last-child { order: 2; }
}
@media (max-width: 1000px) { .main-content.split { grid-template-columns: 1fr; } .tlist { display: none; } }

.br { display: inline-block; font-size: .66rem; font-weight: 700; border-radius: 6px; padding: 1px 7px; letter-spacing: .3px; text-transform: uppercase; }
.br-minibay { background: #e0e7ff; color: #3730a3; } .br-upcase { background: #ccfbf1; color: #0f766e; }
.brand-tabs { display: inline-flex; background: #eef2f6; border-radius: 12px; padding: 3px; gap: 2px; margin-bottom: 14px; }
.brand-tabs button { border: none; background: transparent; border-radius: 9px; padding: 6px 16px; font-size: .84rem; font-weight: 600; color: #475569; }
.brand-tabs button.active { background: #fff; color: #1e1b4b; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.brand-tabs .n { margin-left: 6px; background: #ef4444; color: #fff; border-radius: 9px; font-size: .66rem; padding: 0 6px; }
