:root {
  --navy: #0B1D35; --navy-light: #132845;
  --teal: #047F94; --teal-dark: #035e6e; --tint-teal: #5FB3C3;
  --orange: #F97316; --orange-dark: #DD6610;
  --ink: #0B1D35; --muted: #5b6472;
  --bg: #f5f7fb; --card: #ffffff; --line: #e2e8f0;
  --red: #dc2626; --green: #16a34a; --amber: #d97706;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

.top-nav {
  background: var(--navy); color: #fff; display: flex; align-items: center;
  gap: 24px; padding: 12px 24px; position: sticky; top: 0; z-index: 10;
}
.top-nav .brand-mark { display: flex; align-items: center; }
.top-nav .brand-mark img { display: block; }
.top-nav .spacer { flex: 1; }

.nav-menu { position: relative; }
.nav-toggle {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 4px; width: 36px; height: 36px; background: none; border: none; border-radius: 8px;
  cursor: pointer;
}
.nav-toggle:hover { background: rgba(255,255,255,0.1); }
.nav-toggle span { display: block; width: 18px; height: 2px; border-radius: 2px; background: #fff; }
.nav-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  display: flex; flex-direction: column; gap: 2px; min-width: 200px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
  box-shadow: 0 10px 30px rgba(11,29,53,0.18); z-index: 40;
}
.nav-dropdown[hidden] { display: none; }
.nav-dropdown-user {
  padding: 8px 14px 10px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
.nav-dropdown a, .nav-dropdown button.linklike {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 9px 14px; border-radius: 8px; color: var(--ink);
  font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap;
  font-family: inherit; cursor: pointer;
}
.nav-dropdown a:hover, .nav-dropdown button.linklike:hover { background: rgba(4,127,148,0.08); text-decoration: none; }
.nav-dropdown-divider { height: 1px; background: var(--line); margin: 6px 4px; }

.main { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; margin-bottom: 18px; }
.card--table { padding: 0; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; margin: 0; }

.btn {
  display: inline-block; background: var(--teal); color: #fff; border: none;
  border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.btn:hover { background: var(--teal-dark); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--bg); }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(4,127,148,0.15);
}
.field-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.error-text { color: var(--red); font-size: 13px; margin-top: 8px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 2px solid var(--line); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
tbody tr:hover { background: rgba(4,127,148,0.04); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.status-open { background: rgba(4,127,148,0.12); color: var(--teal); }
.pill.status-pending { background: rgba(217,119,6,0.12); color: var(--amber); }
.pill.status-resolved { background: rgba(22,163,74,0.12); color: var(--green); }
.pill.status-closed { background: rgba(91,100,114,0.12); color: var(--muted); }
.pill.priority-low { background: rgba(91,100,114,0.12); color: var(--muted); }
.pill.priority-normal { background: rgba(4,127,148,0.12); color: var(--teal); }
.pill.priority-high { background: rgba(249,115,22,0.12); color: var(--orange-dark); }
.pill.priority-urgent { background: rgba(220,38,38,0.12); color: var(--red); }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 40px; width: 360px; max-width: calc(100vw - 32px); box-shadow: 0 10px 40px rgba(15,23,42,0.08); text-align: center; }
.login-box h1 { font-size: 20px; margin: 0 0 4px; }
.login-logo { height: 36px; margin-bottom: 10px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.ms-signin-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none;
}
.ms-signin-btn:hover { background: var(--bg); text-decoration: none; }

.meta-row { display: flex; gap: 14px; color: var(--muted); font-size: 13px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filters select, .filters input { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; }

/* Ticket thread */
.msg { border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; border: 1px solid var(--line); }
.msg.public_reply { background: rgba(4,127,148,0.05); border-color: rgba(4,127,148,0.25); }
.msg.internal_note { background: rgba(249,115,22,0.05); border-color: rgba(249,115,22,0.25); }
.msg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.msg-head .who { font-weight: 700; }
.msg-head .when { color: var(--muted); }
.msg-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; }
.msg-tag.public_reply { background: var(--teal); color: #fff; }
.msg-tag.internal_note { background: var(--orange); color: #fff; }
.msg-body { white-space: pre-wrap; font-size: 14px; line-height: 1.6; }

.reply-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.reply-tabs button {
  flex: 1; padding: 9px; border-radius: 8px 8px 0 0; border: 1px solid var(--line); border-bottom: none;
  background: var(--bg); color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; font-family: inherit;
}
.reply-tabs button.active.public_reply { background: var(--teal); color: #fff; border-color: var(--teal); }
.reply-tabs button.active.internal_note { background: var(--orange); color: #fff; border-color: var(--orange); }
.reply-box textarea { min-height: 110px; resize: vertical; }

@media (max-width: 680px) {
  .main { padding: 16px 12px; }
  .card { padding: 16px; }
  .login-box { width: 100%; padding: 28px 24px; }
  .field-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .field-row > .field { margin-bottom: 0; }
  table, thead, tbody, tr, th, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
  .card--table { padding: 12px; }
  td { border-bottom: none; padding: 3px 0; font-size: 13px; }
  td:first-child { font-size: 15px; font-weight: 600; padding-bottom: 6px; }
}
