:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #eef4fb;
  --line: #d8e1ec;
  --text: #142033;
  --muted: #607086;
  --primary: #176b87;
  --primary-strong: #0f5068;
  --accent: #d97a2b;
  --success: #1c7c54;
  --warning: #a86700;
  --danger: #b63a3a;
  --shadow: 0 18px 45px rgba(28, 46, 74, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

.is-hidden {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: none;
  place-items: center;
  padding: 24px;
  background: #102536;
}

.login-screen.active {
  display: grid;
}

.login-card {
  width: min(100%, 430px);
  background: var(--surface);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.auth-tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--primary-strong);
  box-shadow: 0 4px 12px rgba(28, 46, 74, 0.08);
}

.auth-form {
  display: none;
  gap: 14px;
}

.auth-form.active {
  display: grid;
}

.login-card .brand {
  color: var(--text);
  margin-bottom: 6px;
}

.login-card .brand p {
  color: var(--muted);
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.form-notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-notice:empty {
  display: none;
}

.demo-accounts {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

.demo-accounts strong {
  color: var(--text);
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #102536;
  color: #edf6fb;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #e7a84c;
  color: #102536;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p,
.ticket-card h4 {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p {
  color: #aac2d2;
  margin-top: 4px;
  font-size: 13px;
}

.role-tabs {
  display: grid;
  gap: 10px;
}

.role-tab {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #edf6fb;
  padding: 13px 14px;
  border-radius: 8px;
  text-align: left;
}

.role-tab.active {
  background: #edf6fb;
  color: #102536;
}

.summary-panel {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.07);
  display: grid;
  gap: 8px;
}

.summary-label,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

.summary-panel .summary-label,
.summary-panel span:last-child {
  color: #bdd0dc;
}

.summary-panel strong {
  font-size: 42px;
  line-height: 1;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.account-box {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.account-box strong,
.account-box span {
  display: block;
}

.account-box span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.topbar h2 {
  font-size: 30px;
  margin-top: 4px;
}

.ghost-button,
.primary-button,
.small-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
}

.ghost-button {
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--line);
}

.primary-button,
.small-button {
  background: var(--primary);
  color: #fff;
}

.small-button.secondary {
  background: var(--surface-soft);
  color: var(--primary-strong);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.content-grid,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
}

.admin-layout {
  display: grid;
  gap: 18px;
  max-width: 1280px;
}

.single-panel {
  max-width: 560px;
}

.single-panel.wide {
  max-width: 980px;
}

.panel,
.ticket-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.panel-header {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.panel-header h3 {
  font-size: 18px;
}

.panel-header p {
  color: var(--muted);
  font-size: 14px;
}

.form-panel {
  display: grid;
  gap: 14px;
  align-content: start;
  align-self: start;
}

label {
  display: grid;
  gap: 7px;
  color: #2b3a4e;
  font-weight: 700;
  font-size: 14px;
}

.field-note {
  color: var(--danger);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

input[readonly] {
  background: var(--surface-soft);
  color: var(--muted);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) 180px minmax(190px, auto);
  gap: 12px;
  margin-bottom: 16px;
}

.notification-control {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.notification-control.compact {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.notification-control .small-button {
  white-space: nowrap;
}

.notification-control span {
  white-space: nowrap;
}

.ticket-list,
.ticket-board,
.user-list,
.recent-list {
  display: grid;
  gap: 12px;
}

.ticket-board {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.ticket-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.ticket-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.ticket-head h4 {
  margin-top: 6px;
  font-size: 17px;
}

.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge {
  color: var(--primary-strong);
  background: #e3f3f6;
}

.status-pill {
  white-space: nowrap;
}

.status-pending {
  color: var(--warning);
  background: #fff3d8;
}

.status-active {
  color: var(--primary-strong);
  background: #dff0f5;
}

.status-resolved {
  color: var(--success);
  background: #dff4e9;
}

.ticket-desc {
  margin: 0;
  color: #425168;
  line-height: 1.6;
}

.ticket-image-link {
  display: block;
  width: min(100%, 360px);
}

.ticket-image {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.meta div {
  min-width: 0;
}

.meta dt {
  font-weight: 800;
  color: #2f3d50;
}

.meta dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.meta .queue-meta {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff3d8;
}

.meta .queue-meta dt {
  color: var(--warning);
  font-size: 15px;
}

.meta .queue-meta dd {
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
}

.reply-box {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 10px;
}

.reply-box textarea {
  min-height: 90px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty {
  min-height: 160px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px minmax(270px, auto);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.user-row strong,
.user-row span {
  display: block;
}

.user-identity {
  min-width: 0;
}

.user-identity strong,
.user-identity span {
  overflow-wrap: anywhere;
  word-break: normal;
}

.user-identity strong {
  font-size: 15px;
  line-height: 1.45;
}

.user-row span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.toggle {
  justify-self: end;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 12px;
  font-weight: 800;
}

.toggle.disabled {
  color: var(--danger);
  background: #fdeaea;
}

.toggle.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.user-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  justify-content: flex-end;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-soft);
}

.stat-card strong {
  display: block;
  font-size: 30px;
  margin-bottom: 4px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .app-shell,
  .content-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .user-actions {
    flex-wrap: wrap;
  }

  .sidebar {
    min-height: auto;
  }

  .role-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .role-tab {
    text-align: center;
  }

  .summary-panel {
    margin-top: 0;
  }
}

@media (max-width: 620px) {
  .sidebar,
  .main {
    padding: 18px;
  }

  .topbar,
  .ticket-head {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar,
  .stats,
  .user-row,
  .meta {
    grid-template-columns: 1fr;
  }

  .notification-control {
    justify-content: flex-start;
  }

  .role-tabs {
    grid-template-columns: 1fr;
  }

  .toggle {
    justify-self: stretch;
  }
}
