:root {
  --ink: #0a203b;
  --navy: #071a31;
  --navy-2: #0c294a;
  --blue: #079fdf;
  --blue-soft: #e9f7fd;
  --paper: #f4f7fa;
  --surface: #fff;
  --line: #e3eaf0;
  --muted: #718498;
  --shadow: 0 16px 40px rgba(13, 39, 68, .07);
  --display: "Manrope", "Segoe UI", sans-serif;
  --sans: "DM Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

/* Login */
.login-page {
  align-items: center;
  background:
    radial-gradient(circle at 72% 18%, rgba(7, 159, 223, .2), transparent 30%),
    linear-gradient(145deg, #06162a, #0b2848);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: rgba(255, 255, 255, .98);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 22px;
  box-shadow: 0 32px 90px rgba(0, 0, 0, .3);
  max-width: 460px;
  padding: 44px;
  width: 100%;
}
.login-card h1 {
  font: 800 40px/1 var(--display);
  letter-spacing: -.055em;
  margin: 0;
}
.login-card form { display: grid; gap: 18px; margin: 32px 0; }
.login-card form button { display: flex; justify-content: space-between; margin-top: 4px; }
.back { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.6; }

/* Shell */
.admin-page { min-height: 100vh; }
.app-sidebar {
  background:
    radial-gradient(circle at 20% 5%, rgba(7, 159, 223, .14), transparent 25%),
    var(--navy);
  border-right: 1px solid rgba(255, 255, 255, .06);
  color: #fff;
  display: flex;
  flex-direction: column;
  inset: 0 auto 0 0;
  padding: 28px 20px 22px;
  position: fixed;
  width: 272px;
  z-index: 20;
}
.sidebar-head { align-items: center; display: flex; justify-content: space-between; }
.admin-brand { align-items: center; display: flex; gap: 12px; }
.admin-brand img {
  background: #fff;
  border-radius: 11px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
  height: 44px;
  object-fit: cover;
  object-position: left;
  width: 44px;
}
.admin-brand strong {
  display: block;
  font: 800 21px/1 var(--display);
  letter-spacing: -.05em;
}
.admin-brand small {
  color: #6f8ba4;
  display: block;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: .19em;
  margin-top: 5px;
}
.sidebar-toggle {
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 9px;
  color: #fff;
  cursor: pointer;
  display: none;
  height: 40px;
  width: 40px;
}
.app-sidebar nav { display: grid; gap: 5px; margin-top: 54px; }
.app-sidebar nav > p {
  color: #506b85;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .18em;
  margin: 0 12px 10px;
}
.app-sidebar nav > p.nav-group { margin-top: 24px; }
.nav-item {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #8099b0;
  display: grid;
  font-size: 12px;
  font-weight: 600;
  gap: 11px;
  grid-template-columns: 32px 1fr auto;
  min-height: 48px;
  padding: 7px 10px;
  transition: background .2s, border-color .2s, color .2s, transform .2s;
}
.nav-item:hover {
  background: rgba(255, 255, 255, .045);
  color: #d7e7f3;
  transform: translateX(2px);
}
.nav-item.active {
  background: linear-gradient(90deg, rgba(7, 159, 223, .2), rgba(7, 159, 223, .08));
  border-color: rgba(69, 191, 240, .18);
  color: #fff;
}
.nav-item.active::before {
  background: var(--blue);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 18px rgba(7, 159, 223, .65);
  content: "";
  height: 24px;
  left: -20px;
  position: absolute;
  width: 3px;
}
.nav-item { position: relative; }
.nav-icon {
  align-items: center;
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 8px;
  display: flex;
  font-size: 14px;
  height: 32px;
  justify-content: center;
}
.nav-item.active .nav-icon { background: var(--blue); border-color: var(--blue); }
.nav-item b {
  background: rgba(255, 255, 255, .07);
  border-radius: 99px;
  color: #7e99b0;
  font-size: 9px;
  padding: 4px 7px;
}
.nav-item.active b { background: rgba(255, 255, 255, .12); color: #bfeaff; }
.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, .08);
  margin-top: auto;
  padding-top: 18px;
}
.admin-user { align-items: center; display: flex; gap: 11px; }
.admin-user > span {
  align-items: center;
  background: linear-gradient(135deg, var(--blue), #4fc6f6);
  border: 3px solid rgba(255, 255, 255, .08);
  border-radius: 50%;
  display: flex;
  font-size: 12px;
  font-weight: 800;
  height: 39px;
  justify-content: center;
  width: 39px;
}
.admin-user strong, .admin-user small {
  display: block;
  max-width: 155px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-user strong { font-size: 12px; }
.admin-user small { color: #68839c; font-size: 9px; margin-top: 4px; }
.logout {
  color: #5f7a92;
  display: block;
  font-size: 10px;
  margin: 14px 0 0 50px;
  transition: color .2s;
}
.logout:hover { color: #c6dbe9; }

/* Dashboard */
.dashboard {
  background:
    radial-gradient(circle at 90% 0, rgba(7, 159, 223, .055), transparent 26%),
    var(--paper);
  margin-left: 272px;
  min-height: 100vh;
  padding: 48px clamp(28px, 4vw, 68px) 70px;
}
.dashboard > header {
  align-items: flex-end;
  display: flex;
  justify-content: space-between;
  scroll-margin-top: 30px;
}
.overline, .panel-eyebrow {
  color: var(--blue);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .18em;
}
.dashboard > header .overline { margin: 0 0 10px; }
.dashboard h1 {
  font: 800 clamp(31px, 3.2vw, 44px)/1 var(--display);
  letter-spacing: -.055em;
  margin: 0;
}
.header-copy { color: var(--muted); font-size: 12px; margin: 12px 0 0; }
.primary, button[type="submit"] {
  background: linear-gradient(135deg, #079fdf, #058dca);
  border: 0;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(7, 159, 223, .2);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 14px 18px;
  transition: box-shadow .2s, transform .2s;
}
.primary:hover, button[type="submit"]:hover {
  box-shadow: 0 14px 30px rgba(7, 159, 223, .3);
  transform: translateY(-1px);
}
.primary span { font-size: 17px; margin-right: 7px; }

.alert {
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12px;
  margin: 22px 0;
  padding: 13px 16px;
}
.alert.error { background: #fff0f0; border-color: #f7d3d3; color: #a83434; }
.alert.success { background: #e9f8f2; border-color: #ccecdf; color: #137051; }
.alert.warning { background: #fff7df; border-color: #f0e1b7; color: #8a6510; }

.metrics {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, 1fr);
  margin: 35px 0 22px;
}
.metrics article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(9, 36, 66, .02);
  min-width: 0;
  overflow: hidden;
  padding: 19px;
  position: relative;
}
.metrics article::after {
  background: var(--metric-color, var(--blue));
  border-radius: 0 0 0 5px;
  content: "";
  height: 3px;
  position: absolute;
  right: 0;
  top: 0;
  width: 42%;
}
.metrics article > div { align-items: center; display: flex; justify-content: space-between; }
.metrics span { color: #536a7f; font-size: 10px; font-weight: 700; }
.metrics i {
  background: color-mix(in srgb, var(--metric-color, var(--blue)) 10%, white);
  border-radius: 99px;
  color: var(--metric-color, var(--blue));
  font-size: 7px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: .1em;
  padding: 5px 7px;
}
.metrics strong {
  display: block;
  font: 800 31px/1 var(--display);
  letter-spacing: -.05em;
  margin: 20px 0 7px;
}
.metrics small { color: #93a2af; font-size: 9px; }
.metric-total { --metric-color: #079fdf; }
.metric-open { --metric-color: #3478d4; }
.metric-progress { --metric-color: #e3a514; }
.metric-closed { --metric-color: #2ca577; }
.metric-inquiry { --metric-color: #7b61d9; }

/* Panels and tables */
.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
  scroll-margin-top: 28px;
}
.workspace.with-detail { grid-template-columns: minmax(500px, 1.25fr) minmax(350px, .75fr); }
.ticket-list, .detail, .message-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.message-list { margin-top: 22px; scroll-margin-top: 28px; }
.panel-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 23px 24px 20px;
}
.panel-eyebrow { display: block; margin-bottom: 7px; }
.panel-title h2, .detail h2 {
  font: 750 19px/1.2 var(--display);
  letter-spacing: -.025em;
  margin: 0;
}
.panel-title p { color: var(--muted); font-size: 10px; margin: 7px 0 0; }
.panel-count {
  align-items: center;
  background: #f1f6f9;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #547087;
  display: flex;
  font-size: 11px;
  font-weight: 800;
  height: 36px;
  justify-content: center;
  min-width: 36px;
}
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; }
th {
  background: #f9fbfc;
  color: #8698a8;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .14em;
  text-align: left;
  text-transform: uppercase;
}
th, td { border-top: 1px solid #eaf0f4; padding: 15px 20px; }
tbody tr { transition: background .15s; }
tbody tr[data-href] { cursor: pointer; outline: none; }
tbody tr[data-href]:hover, tbody tr[data-href]:focus, tbody tr.selected {
  background: #f2f9fc;
}
tbody tr.selected { box-shadow: inset 3px 0 var(--blue); }
td { color: #344f66; font-size: 11px; }
td strong, td small { display: block; }
td strong { color: var(--ink); font-size: 11px; }
td small { color: #8b9ba8; font-size: 9px; margin-top: 5px; }
.message-list tbody tr { cursor: default; }
.message-list td { vertical-align: top; }
.message-list td a { color: #0989c1; font-weight: 600; }
.message-copy { line-height: 1.55; max-width: 520px; min-width: 260px; white-space: normal; }
.message-copy small { margin-top: 9px; }
.mail-ok { color: #2b9a70; }
.mail-pending { color: #b9850a; }
.empty { color: var(--muted); padding: 58px; text-align: center; }
.status {
  background: #e8f3f9;
  border: 1px solid transparent;
  border-radius: 99px;
  color: #32617e;
  display: inline-block;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: .09em;
  padding: 6px 8px;
}
.status.open { background: #eaf5ff; border-color: #d6eafb; color: #1870a7; }
.status.on-progress { background: #fff5d8; border-color: #f3e5b9; color: #8e6a07; }
.status.closed { background: #e7f7f0; border-color: #d0ebdf; color: #247452; }

/* Case detail */
.detail {
  align-self: start;
  padding: 26px;
  position: sticky;
  top: 28px;
}
.detail > .overline { margin: 0 0 9px; }
.detail h2 { max-width: calc(100% - 32px); }
.close-detail {
  align-items: center;
  background: #f2f6f8;
  border-radius: 8px;
  color: #7c90a1;
  display: flex;
  font-size: 19px;
  height: 32px;
  justify-content: center;
  position: absolute;
  right: 20px;
  top: 20px;
  width: 32px;
}
.customer {
  background: linear-gradient(135deg, #f4f9fc, #f8fbfd);
  border: 1px solid #e5eef3;
  border-radius: 11px;
  display: grid;
  gap: 5px;
  margin: 21px 0;
  padding: 15px;
}
.customer strong { font-size: 11px; }
.customer span { color: var(--muted); font-size: 9px; }
.update-form { border-bottom: 1px solid var(--line); display: grid; gap: 14px; padding-bottom: 24px; }
.update-form textarea { min-height: 94px; resize: vertical; }
.timeline h3 { font-size: 11px; margin: 24px 0; text-transform: uppercase; letter-spacing: .12em; }
.timeline article {
  display: grid;
  gap: 12px;
  grid-template-columns: 10px 1fr;
  padding-bottom: 21px;
  position: relative;
}
.timeline article::before {
  background: var(--line);
  bottom: 0;
  content: "";
  left: 4px;
  position: absolute;
  top: 9px;
  width: 1px;
}
.timeline article:last-child::before { display: none; }
.timeline i {
  background: var(--blue);
  border: 2px solid #d3f2ff;
  border-radius: 50%;
  height: 10px;
  margin-top: 4px;
  width: 10px;
  z-index: 1;
}
.timeline p { color: #405a70; font-size: 10px; line-height: 1.6; margin: 9px 0; }
.timeline small { color: #8a9aa8; font-size: 8px; }

/* Forms */
.login-card label, .update-form label, dialog label {
  color: #526b80;
  display: grid;
  font-size: 10px;
  font-weight: 700;
  gap: 8px;
}
.login-card input, .update-form select, .update-form textarea, dialog input, dialog textarea {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  outline: none;
  padding: 13px;
}
.login-card input:focus, .update-form select:focus, .update-form textarea:focus,
dialog input:focus, dialog textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(7, 159, 223, .11);
}
dialog {
  border: 0;
  border-radius: 17px;
  box-shadow: 0 35px 100px rgba(0, 0, 0, .3);
  max-width: 650px;
  padding: 0;
  width: calc(100% - 32px);
}
dialog::backdrop { backdrop-filter: blur(5px); background: rgba(5, 20, 37, .72); }
dialog form { display: grid; gap: 17px; padding: 31px; }
.modal-head { align-items: flex-start; display: flex; justify-content: space-between; }
.modal-head .overline { margin: 0 0 8px; }
.modal-head h2 { font: 800 27px/1 var(--display); letter-spacing: -.04em; margin: 0; }
.modal-head button {
  background: #f2f6f8;
  border: 0;
  border-radius: 8px;
  color: #7d91a2;
  cursor: pointer;
  font-size: 20px;
  height: 34px;
  width: 34px;
}
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
dialog textarea { min-height: 105px; resize: vertical; }

@media (max-width: 1200px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .workspace.with-detail { grid-template-columns: 1fr; }
  .detail { position: relative; top: 0; }
}

@media (max-width: 780px) {
  .app-sidebar {
    bottom: auto;
    height: 72px;
    padding: 14px 18px;
    right: 0;
    width: 100%;
  }
  .sidebar-toggle { display: block; }
  .app-sidebar nav {
    background: #0a203b;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 13px;
    box-shadow: 0 22px 55px rgba(0, 0, 0, .32);
    display: none;
    left: 14px;
    margin: 0;
    padding: 17px;
    position: absolute;
    right: 14px;
    top: 65px;
  }
  .app-sidebar.open { height: auto; }
  .app-sidebar.open nav { display: grid; }
  .sidebar-foot { display: none; }
  .admin-brand small { display: none; }
  .dashboard { margin-left: 0; padding: 105px 16px 42px; }
  .dashboard > header { align-items: flex-start; gap: 20px; }
  .dashboard h1 { font-size: 29px; }
  .header-copy { max-width: 280px; }
  .primary { font-size: 0; padding: 10px; }
  .primary span { font-size: 22px; margin: 0; }
  .metrics { gap: 9px; grid-template-columns: 1fr 1fr; }
  .metrics article { padding: 15px; }
  .metrics strong { font-size: 27px; margin-top: 17px; }
  .metrics i { display: none; }
  .ticket-list { overflow: hidden; }
  .ticket-list th:nth-child(2), .ticket-list td:nth-child(2),
  .ticket-list th:nth-child(4), .ticket-list td:nth-child(4),
  .message-list th:nth-child(2), .message-list td:nth-child(2),
  .message-list th:nth-child(4), .message-list td:nth-child(4) { display: none; }
  .message-copy { min-width: 210px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics article:last-child { grid-column: 1 / -1; }
  .panel-title { padding: 20px; }
  th, td { padding: 14px 16px; }
}

/* Configuration */
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow);
  margin-top: 22px;
  scroll-margin-top: 28px;
}
.settings-grid {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr 1fr;
  padding: 22px;
}
.settings-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 22px;
}
.settings-head {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 42px 1fr auto;
  margin-bottom: 24px;
}
.settings-icon {
  align-items: center;
  background: #f0eafe;
  border: 1px solid #ded2f8;
  border-radius: 10px;
  color: #6546b3;
  display: flex;
  font-size: 10px;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  letter-spacing: -.04em;
}
.settings-icon.mail { background: var(--blue-soft); border-color: #d2ebf7; color: #087dae; font-size: 8px; }
.settings-icon.admin-icon { background: #e9f7f2; border-color: #cce9dc; color: #247452; }
.settings-head h3 { font: 750 15px/1.2 var(--display); margin: 0; }
.settings-head p { color: var(--muted); font-size: 9px; margin: 5px 0 0; }
.config-state {
  background: #fff5d8;
  border: 1px solid #f0dfab;
  border-radius: 99px;
  color: #8e6a07;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 6px 8px;
  text-transform: uppercase;
}
.config-state.ready { background: #e7f7f0; border-color: #cce9dc; color: #247452; }
.settings-form { display: grid; gap: 14px; }
.settings-form label {
  color: #526b80;
  display: grid;
  font-size: 9px;
  font-weight: 700;
  gap: 7px;
}
.settings-form label small { color: #91a0ad; font-size: 8px; font-weight: 400; }
.settings-form input, .settings-form select {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  min-width: 0;
  outline: none;
  padding: 12px;
  width: 100%;
}
.settings-form input:focus, .settings-form select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(7, 159, 223, .11);
}
.settings-form button { justify-self: start; margin-top: 4px; }
.settings-row { display: grid; gap: 12px; grid-template-columns: 1fr .45fr; }
.settings-row.equal { grid-template-columns: 1fr 1fr; }
.email-test-form { border-top: 1px solid var(--line); grid-template-columns: 1fr auto; margin-top: 20px; padding-top: 18px; }
.email-test-form button { align-self: end; white-space: nowrap; }
.admin-management-grid { grid-template-columns: .75fr 1.25fr; }
.admin-accounts { display: grid; gap: 14px; }
.admin-account { background: #f8fafc; border: 1px solid var(--line); border-radius: 11px; padding: 15px; }
.admin-account-head { align-items: center; display: grid; gap: 10px; grid-template-columns: 35px 1fr auto; }
.admin-account-head > span {
  align-items: center; background: var(--navy); border-radius: 9px; color: #fff; display: flex;
  font: 800 12px/1 var(--display); height: 35px; justify-content: center;
}
.admin-account-head strong, .admin-account-head small { display: block; }
.admin-account-head strong { font: 700 11px/1.3 var(--display); }
.admin-account-head small { color: var(--muted); font-size: 8px; margin-top: 3px; }
.admin-account-head i { color: #8b98a4; font-size: 7px; font-style: normal; font-weight: 800; text-transform: uppercase; }
.admin-account-head i.active { color: #247452; }
.admin-password-form { border-top: 1px solid var(--line); grid-template-columns: 1fr 1fr 1fr auto; margin-top: 14px; padding-top: 14px; }
.admin-password-form button { align-self: end; white-space: nowrap; }
.admin-delete-form { border-top: 1px solid var(--line); grid-template-columns: 1fr auto; margin-top: 14px; padding-top: 14px; }
.admin-delete-form button { align-self: end; white-space: nowrap; }
.admin-delete-form .danger-button { background: #a83232; box-shadow: none; }
.admin-delete-form .danger-button:hover { background: #8e2727; }

@media (max-width: 1120px) {
  .settings-grid, .admin-management-grid { grid-template-columns: 1fr; }
  .admin-password-form { grid-template-columns: 1fr 1fr; }
  .admin-password-form button { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .settings-grid { padding: 14px; }
  .settings-card { padding: 17px; }
  .settings-head { grid-template-columns: 38px 1fr; }
  .config-state { grid-column: 2; justify-self: start; }
  .settings-row { grid-template-columns: 1fr; }
  .email-test-form { grid-template-columns: 1fr; }
  .admin-password-form { grid-template-columns: 1fr; }
  .admin-password-form button { grid-column: auto; }
  .admin-delete-form { grid-template-columns: 1fr; }
}
