:root {
  --nav: #172b3e;
  --nav-hover: #22405c;
  --nav-active: #2c5cc5;
  --primary: #2c5cc5;
  --primary-dark: #1d4aa8;
  --text: #12344d;
  --muted: #6f7c87;
  --border: #dbe2e8;
  --bg: #f3f5f7;
  --card: #fff;
  --danger: #d72d30;
  --warn: #e8a10a;
  --ok: #00a886;
  --p1: #e43538;
  --p2: #f59f00;
  --p3: #4da1ff;
  --p4: #7dc36a;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(18, 52, 77, .08), 0 2px 8px rgba(18, 52, 77, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 18px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 64px 1fr; height: 100vh; }
.side { background: var(--nav); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px; }
.side .logo { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 12px; }
.side .logo:hover { background: none; }
.side .logo img { width: 38px; height: auto; display: block; }
.side a { width: 46px; height: 46px; border-radius: 8px; display: grid; place-items: center; color: #b9c7d4; position: relative; }
.side a:hover { background: var(--nav-hover); color: #fff; text-decoration: none; }
.side a.active { background: var(--nav-active); color: #fff; }
.side a svg { width: 21px; height: 21px; }
.side a .tip { position: absolute; left: 54px; background: #0e1c29; color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; opacity: 0; pointer-events: none; transition: .1s; z-index: 50; }
.side a:hover .tip { opacity: 1; }
.side .spacer { flex: 1; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.top { height: 56px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 18px; gap: 14px; flex-shrink: 0; }
.top h1 { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .search { width: 300px; position: relative; }
.top .search input { width: 100%; padding: 7px 10px 7px 32px; border: 1px solid var(--border); border-radius: 18px; background: var(--bg); }
.top .search svg { position: absolute; left: 10px; top: 9px; width: 15px; color: var(--muted); }
.content { flex: 1; overflow: auto; padding: 18px; }
.content.flush { padding: 0; display: flex; min-height: 0; overflow: hidden; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 4px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #f5f7f9; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 15px; height: 15px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=search], input:not([type]), select, textarea {
  border: 1px solid var(--border); border-radius: 4px; padding: 7px 9px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(44, 92, 197, .15); }
textarea { min-height: 110px; resize: vertical; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
label.check { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; cursor: pointer; }
label.check input { width: auto; }
.row { display: flex; gap: 12px; align-items: center; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card > .hd h2, .card > .hd h3 { flex: 1; }
.card > .hd > svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--primary); }
.pill svg { width: 12px; height: 12px; }
.chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card > .bd { padding: 16px; }
.stack > * + * { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 12px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--primary); }
.tile .n { font-size: 26px; font-weight: 600; }
.tile .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tile.bad .n { color: var(--danger); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: #eef2f5; color: #33475b; white-space: nowrap; }
.pill.st-Open { background: #e5efff; color: #1d4aa8; }
.pill.st-In-Progress { background: #ede7ff; color: #5a3fc0; }
.pill.st-Pending { background: #fff4d6; color: #8a5a00; }
.pill.st-Resolved { background: #e0f6ef; color: #00775f; }
.pill.st-Closed { background: #eceff1; color: #546e7a; }
.pill.red { background: #fde8e8; color: var(--danger); }
.pill.green { background: #e0f6ef; color: #00775f; }
.pill.amber { background: #fff4d6; color: #8a5a00; }
.pill.blue { background: #e5efff; color: #1d4aa8; }
.pdot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.pdot.p1 { background: var(--p1); } .pdot.p2 { background: var(--p2); } .pdot.p3 { background: var(--p3); } .pdot.p4 { background: var(--p4); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--ok); } .dot.off { background: #b0bec5; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; color: #fff; flex-shrink: 0; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }

/* tickets list */
.list-wrap { display: flex; flex: 1; min-width: 0; }
.list-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.list-bar { background: #fff; border-bottom: 1px solid var(--border); padding: 10px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.list-bar select { width: auto; }
.list-bar .count { color: var(--muted); }
.list-scroll { flex: 1; overflow: auto; padding: 12px 16px; }
.tkt { display: grid; grid-template-columns: 22px 36px 1fr 150px 170px 130px; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.tkt:hover { border-color: #9fb3c8; }
.tkt.sel { border-color: var(--primary); background: #f6f9ff; }
.tkt .subj { font-weight: 600; color: var(--text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tkt .meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tkt select { padding: 4px 6px; font-size: 13px; border-color: transparent; background: transparent; }
.tkt select:hover { border-color: var(--border); background: #fff; }
.tkt .tags { display: flex; gap: 6px; margin-bottom: 2px; flex-wrap: wrap; }
.filters { width: 270px; background: #fff; border-left: 1px solid var(--border); overflow: auto; padding: 14px; flex-shrink: 0; }
.filters h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 12px; }
.bulkbar { background: #12344d; color: #fff; padding: 8px 16px; display: flex; gap: 10px; align-items: center; }
.bulkbar select { width: auto; padding: 4px 6px; }

/* ticket detail */
.tdetail { display: grid; grid-template-columns: 1fr 340px; gap: 0; flex: 1; min-height: 0; }
.tconv { overflow: auto; padding: 18px; }
.tprops { background: #fff; border-left: 1px solid var(--border); overflow: auto; }
.tprops .sec { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.tprops .sec h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; margin-bottom: 10px; }
.thead { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.thead h2 { font-size: 19px; margin: 4px 0 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.msg { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); }
.msg .mh { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid #eef1f4; }
.msg .mh .who { flex: 1; }
.msg .mb { padding: 12px 14px 14px 56px; white-space: pre-wrap; word-wrap: break-word; }
.msg.note { background: #fffbea; border-color: #f2df9b; }
.msg.note .mh { border-bottom-color: #f2e6b8; }
.msg.requester { border-left: 3px solid var(--p3); }
.composer { background: #fff; border: 1px solid var(--primary); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; box-shadow: var(--shadow); }
.composer.note { border-color: #e0c45c; background: #fffdf3; }
.composer .ctl { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.composer .ctl select { width: auto; }
.timeline { font-size: 12px; color: var(--muted); }
.timeline div { padding: 4px 0; border-bottom: 1px dashed #e6ebef; }
.atts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; padding-left: 0; }
.att { display: inline-flex; gap: 5px; align-items: center; border: 1px solid var(--border); border-radius: 4px; padding: 3px 8px; font-size: 12px; background: #fff; cursor: pointer; }
.sla { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.sla .line { display: flex; justify-content: space-between; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* tables */
table.t { width: 100%; border-collapse: collapse; background: #fff; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--border); background: #f8fafb; position: sticky; top: 0; }
table.t td { padding: 9px 12px; border-bottom: 1px solid #edf1f4; vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f6f9fc; }
table.t input, table.t select { padding: 4px 6px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* dashboard */
.dgrid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.bars .b { display: grid; grid-template-columns: 140px 1fr 36px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.bars .track { background: #eef2f5; border-radius: 3px; height: 10px; overflow: hidden; }
.bars .fill { background: var(--primary); height: 100%; }
.trend svg { width: 100%; height: 180px; }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(18, 52, 77, .45); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 8px; width: 560px; max-width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { width: 820px; }
.modal .hd { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal .hd h2 { flex: 1; }
.modal .bd { padding: 18px; }
.modal .ft { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #12344d; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: var(--shadow); max-width: 380px; }
.toast.err { background: var(--danger); }
.menu { position: absolute; right: 18px; top: 52px; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); min-width: 220px; z-index: 60; }
.menu div, .menu a { display: block; padding: 9px 14px; color: var(--text); cursor: pointer; }
.menu a:hover, .menu div.i:hover { background: var(--bg); text-decoration: none; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* portal */
.portal { min-height: 100vh; }
.phead { background: var(--nav); color: #fff; }
.phead .in { max-width: 1060px; margin: 0 auto; display: flex; align-items: center; gap: 22px; padding: 0 20px; height: 60px; }
.phead .brand { font-weight: 700; font-size: 17px; flex: 1; color: #fff; display: flex; align-items: center; gap: 10px; }
.phead .brand img { height: 26px; width: auto; }
.phead .brand:hover { text-decoration: none; }
.phead a { color: #c9d6e2; }
.phead a.active, .phead a:hover { color: #fff; text-decoration: none; }
.hero { background: linear-gradient(135deg, #1d3c5a, #2c5cc5); color: #fff; padding: 44px 20px; text-align: center; }
.hero h1 { font-size: 26px; margin-bottom: 8px; }
.pbody { max-width: 1060px; margin: 0 auto; padding: 24px 20px; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: -30px auto 24px; max-width: 1060px; padding: 0 20px; }
.choice { background: #fff; border-radius: 8px; padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--border); cursor: pointer; }
.choice:hover { border-color: var(--primary); }
.choice h3 { margin-bottom: 6px; color: var(--primary); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #172b3e, #2c5cc5); }
.login .box { background: #fff; border-radius: 10px; padding: 34px; width: 380px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.login .box h1 { font-size: 22px; margin: 10px 0 6px; }

@media (max-width: 1200px) {
  .tkt { grid-template-columns: 22px 36px 1fr 140px 150px; }
  .tkt .c-status { display: none; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .filters { display: none; }
  .tdetail { grid-template-columns: 1fr; }
  .dgrid, .grid2, .grid3, .choices { grid-template-columns: 1fr; }
  .top .search { display: none; }
}
