:root {
  --navy: #101827;
  --navy-soft: #17253a;
  --red: #e60012;
  --blue: #1769aa;
  --green: #168b5b;
  --amber: #d98200;
  --violet: #7257b4;
  --ink: #152236;
  --muted: #6d7b8d;
  --bg: #f3f6f9;
  --paper: #ffffff;
  --line: #e1e7ed;
  --shadow: 0 14px 38px rgba(16, 24, 39, .07);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Arial Nova", Arial, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }

/* Signed-out pages */
.auth-body { background: radial-gradient(circle at 80% 0, #e8f1f8 0, transparent 32%), var(--bg); }
.auth-header {
  height: 72px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100% - 1180px) / 2));
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand img { width: 86px; height: auto; }
.brand span { display: grid; }
.brand strong { font-size: 17px; }
.brand small { color: #aebed0; font-size: 12px; }
.site-link { color: #dce6f1; border: 1px solid rgba(255,255,255,.2); padding: 8px 12px; border-radius: 8px; }
.auth-main { max-width: 1180px; margin: auto; padding: 28px 24px; }
.login-card {
  max-width: 430px;
  margin: 7vh auto;
  padding: 34px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin-top: 0; font-size: 28px; }

/* Signed-in shell */
.portal-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.portal-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 15px;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: linear-gradient(180deg, #101827 0%, #17263d 100%);
  overflow: auto;
}
.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  padding: 2px 7px 24px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.portal-brand:hover { text-decoration: none; }
.portal-brand img { width: 82px; height: auto; }
.portal-brand span { display: grid; }
.portal-brand strong { font-size: 16px; }
.portal-brand small { color: #9fb0c5; font-size: 12px; }
.portal-nav { display: grid; gap: 5px; margin-top: 20px; }
.portal-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 9px;
  color: #becbdd;
  font-weight: 700;
}
.portal-nav a:hover { background: rgba(255,255,255,.09); color: #fff; text-decoration: none; }
.portal-nav i {
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255,255,255,.08);
  color: #8fc9f1;
  font-size: 9px;
  font-style: normal;
  letter-spacing: .03em;
}
.portal-sidebar-footer { margin-top: auto; padding: 18px 7px 2px; border-top: 1px solid rgba(255,255,255,.1); }
.portal-user { display: flex; gap: 10px; align-items: center; }
.portal-user div { display: grid; min-width: 0; }
.portal-user strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-user small { color: #9fb0c5; }
.portal-avatar, .team-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #e5f1fb;
  color: #145b90;
  font-size: 12px;
  font-weight: 800;
}
.availability { display: flex; gap: 7px; align-items: center; margin-top: 11px; color: #aebed0; font-size: 12px; }
.availability i { width: 8px; height: 8px; border-radius: 50%; background: #31cf8a; box-shadow: 0 0 0 4px rgba(49,207,138,.12); }
.portal-main { min-width: 0; }
.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.portal-topbar > div { display: grid; }
.portal-topbar > div strong { font-size: 16px; }
.portal-topbar > div small { color: var(--muted); }
.portal-topbar nav { display: flex; align-items: center; gap: 18px; }
.portal-topbar nav a { color: #4d5d70; font-weight: 700; }
.portal-topbar nav .signout { color: #a91c29; }
.portal-content { max-width: 1600px; margin: 0 auto; padding: 27px 30px 42px; }

/* Shared components */
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.page-head h1 { margin: 7px 0 3px; }
.page-head p { margin: 0; color: var(--muted); }
.eyebrow { display: block; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
form { display: grid; gap: 16px; }
label { display: grid; gap: 6px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #bac6d2;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(23,105,170,.12); border-color: var(--blue); }
textarea { resize: vertical; }
button, .button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 0;
  border-radius: 8px;
  padding: 10px 15px;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
.button:hover { text-decoration: none; }
.button.primary { background: var(--navy); }
.secondary { background: #506174; }
.danger { background: #b51d2a; }
.alert, .success { padding: 12px 14px; border-radius: 8px; margin: 14px 0; }
.alert { background: #fff0f0; color: #9d1824; }
.success { background: #e9f8ef; color: #176b37; }
.muted, .empty { color: var(--muted); }
.empty { padding: 28px !important; text-align: center; }
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; font-weight: 500; }
.check input { width: auto; }

/* Dashboard */
.dashboard-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.dashboard-intro h1 { margin: 7px 0 3px; }
.dashboard-intro p { margin: 0; color: var(--muted); }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 13px; margin-bottom: 17px; }
.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 135px;
  padding: 17px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 5px 18px rgba(16,24,39,.035);
}
.metric-card:after { content: ""; position: absolute; top: -31px; right: -28px; width: 88px; height: 88px; border-radius: 50%; background: var(--tint); }
.metric-card span { display: block; color: var(--muted); font-weight: 700; }
.metric-card strong { display: block; margin: 7px 0 2px; font-size: 28px; }
.metric-card small { color: var(--accent); }
.metric-card.amber { --accent: #a55e00; --tint: #fff0d6; }
.metric-card.blue { --accent: #1769aa; --tint: #e7f2fb; }
.metric-card.red { --accent: #b51d2a; --tint: #fde7ea; }
.metric-card.green { --accent: #168b5b; --tint: #e4f6ed; }
.metric-card.violet { --accent: #7257b4; --tint: #eeeafe; }
.dashboard-layout { display: grid; grid-template-columns: minmax(0,2.1fr) minmax(280px,.75fr); gap: 17px; align-items: start; }
.queue-panel { padding: 0; overflow: hidden; }
.queue-tabs { display: flex; gap: 4px; padding: 4px; background: #eff3f6; border-radius: 9px; }
.queue-tabs a { padding: 7px 10px; border-radius: 6px; color: #667487; font-size: 12px; font-weight: 800; }
.queue-tabs a:hover { text-decoration: none; background: #fff; }
.queue-tabs a.active { color: var(--ink); background: #fff; box-shadow: 0 2px 7px rgba(25,40,59,.1); }
.filters { display: flex; flex-wrap: wrap; gap: 7px; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.filters a { padding: 6px 9px; color: #647386; background: #f6f8fa; border-radius: 6px; font-size: 12px; font-weight: 700; }
.filters a:hover { text-decoration: none; }
.filters a.active { color: #fff; background: var(--navy); }
.filters b { margin-left: 4px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 15px; text-align: left; vertical-align: middle; border-bottom: 1px solid #edf0f3; }
th { color: var(--muted); background: #fafbfc; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
tbody tr { transition: background .16s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
td small, .message small, .history small { display: block; color: var(--muted); }
.ticket-number { white-space: nowrap; font-size: 12px; font-weight: 800; }
.request-cell { min-width: 230px; }
.request-cell strong { display: block; }
.priority, .assignment, .status { display: inline-block; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.p1 { background: #fde4e7; color: #a51222; }
.p2 { background: #fff0dc; color: #985000; }
.p3 { background: #e5f1fb; color: #155c91; }
.p4, .p5 { background: #edf0f3; color: #53606d; }
.assignment.unassigned { background: #fff0dc; color: #8a4800; }
.status-new { background: #fff0dc; color: #8a4800; }
.status-in-progress { background: #e5f1fb; color: #155c91; }
.status-waiting-user { background: #eeeafe; color: #6549a8; }
.status-resolved { background: #e4f6ed; color: #167049; }
.status-closed { background: #edf0f3; color: #53606d; }
.updated-time { white-space: nowrap; }
.dashboard-side { display: grid; gap: 17px; }
.pulse-panel, .team-panel { padding: 0; overflow: hidden; }
.pulse-list { padding: 11px 20px 18px; }
.pulse-row { margin-top: 13px; }
.pulse-row > div:first-child { display: flex; justify-content: space-between; margin-bottom: 6px; }
.pulse-row span { color: #4d5b6d; }
.pulse-bar, .team-bar { height: 7px; overflow: hidden; background: #edf1f5; border-radius: 999px; }
.pulse-bar i, .team-bar i { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: #8091a4; }
.pulse-bar .pulse-new { background: var(--amber); }
.pulse-bar .pulse-in-progress { background: var(--blue); }
.pulse-bar .pulse-waiting-user { background: var(--violet); }
.pulse-bar .pulse-resolved { background: var(--green); }
.team-list { padding: 8px 20px 14px; }
.team-list article { display: grid; grid-template-columns: 36px minmax(0,1fr) 24px; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid #edf0f3; }
.team-list article:last-child { border: 0; }
.team-list article > div { min-width: 0; }
.team-list article strong, .team-list article small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-list article small { color: var(--muted); font-size: 11px; }
.team-bar { height: 5px; margin-top: 6px; }
.team-bar i { background: linear-gradient(90deg, var(--blue), #58aee5); }
.team-list article > b { text-align: right; }

/* Ticket and account pages */
.ticket-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(310px,.85fr); gap: 18px; }
.panel h2:first-child { margin-top: 0; }
.description { padding: 16px; white-space: normal; background: #f8fafc; border-left: 4px solid var(--blue); border-radius: 0 7px 7px 0; }
.message { padding: 15px 0; border-top: 1px solid var(--line); }
.message.internal { padding: 14px; background: #fff8dd; border-radius: 7px; }
.message p { margin-bottom: 0; }
.assignment-summary { margin-top: 0; padding: 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 7px; }
.assignment-summary small { display: block; margin-top: 3px; color: var(--muted); }
.assignment-form { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.compact-form { display: block; margin: 0 0 20px; }
.compact-form button { width: 100%; }
.history { padding-left: 18px; }
.history li { margin-bottom: 10px; }
.history li span { display: block; font-size: 13px; }
.account-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 20px; margin-bottom: 26px; }
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: inline; }

@media (max-width: 1240px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .dashboard-layout { grid-template-columns: 1fr; }
  .dashboard-side { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .portal-shell { grid-template-columns: 76px minmax(0,1fr); }
  .portal-sidebar { padding: 18px 10px; align-items: center; }
  .portal-brand span, .portal-nav span, .portal-sidebar-footer > .availability, .portal-user div { display: none; }
  .portal-brand { padding: 0 0 19px; }
  .portal-brand img { width: 55px; }
  .portal-nav a { padding: 10px; }
  .portal-nav i { width: 30px; height: 30px; }
  .portal-sidebar-footer { padding: 16px 0 0; }
  .ticket-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .portal-shell { display: block; }
  .portal-sidebar { position: relative; width: 100%; height: auto; padding: 10px 12px; display: flex; flex-direction: row; overflow-x: auto; }
  .portal-brand { border: 0; border-right: 1px solid rgba(255,255,255,.1); padding: 0 12px 0 0; margin-right: 8px; }
  .portal-nav { display: flex; gap: 3px; margin: 0; }
  .portal-sidebar-footer { margin: 0 0 0 auto; padding: 0 0 0 8px; border: 0; }
  .portal-topbar { height: 62px; padding: 0 14px; }
  .portal-topbar > div small, .portal-topbar nav a:not(.signout) { display: none; }
  .portal-content { padding: 20px 12px 34px; }
  .dashboard-intro { align-items: flex-start; }
  .dashboard-intro .button { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 120px; padding: 14px; }
  .metric-card:last-child { grid-column: 1 / -1; }
  .dashboard-side { grid-template-columns: 1fr; }
  .panel-heading { display: block; }
  .queue-tabs { margin-top: 12px; width: 100%; }
  .queue-tabs a { flex: 1; text-align: center; }
  .page-head { display: block; }
  .account-grid { grid-template-columns: 1fr; }
  .auth-header { padding: 0 14px; }
  .auth-main { padding: 18px 12px; }
  th, td { padding: 11px; }
}
