/* Supportal: Jira-like look (top bar, project sidebar, issue view with a
   details column). Plain CSS, no build step. Works down to phone width. */
:root {
  --bg: #ffffff;
  --bg-sunken: #f7f8f9;
  --bg-hover: #f1f2f4;
  --bg-selected: #e9f2ff;
  --surface: #ffffff;
  --text: #172b4d;
  --text-subtle: #44546f;
  --muted: #626f86;
  --border: #dcdfe4;
  --border-input: #8590a2;
  --accent: #0c66e4;
  --accent-hover: #0055cc;
  --accent-pressed: #09326c;
  --focus: #388bff;
  --danger: #ae2e24;
  --danger-bg: #ffeceb;
  --danger-border: #f87168;
  --dot: #e34935;
  --todo-bg: #dcdfe4;     --todo-fg: #44546f;
  --progress-bg: #cce0ff; --progress-fg: #0055cc;
  --done-bg: #baf3db;     --done-fg: #216e4e;
  --np-bg: #f8e6a0;       --np-fg: #7f5f01;
  --bug: #e2483d;
  --feature: #22a06b;
  --radius: 3px;
  --radius-lg: 8px;
  --topbar-h: 56px;
  --shadow-raised: 0 1px 1px rgba(9, 30, 66, 0.25), 0 0 1px rgba(9, 30, 66, 0.31);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/20px var(--font);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

h1 { font-size: 24px; line-height: 28px; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 16px; }
h2 { font-size: 16px; line-height: 20px; font-weight: 600; margin: 24px 0 8px; }

.muted { color: var(--muted); }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: var(--radius);
}
.brand:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.brand__mark {
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0c66e4, #5e4db2);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.topnav { display: flex; gap: 4px; }
.topnav__link {
  color: var(--text-subtle);
  font-weight: 500;
  padding: 8px 10px;
  border-radius: var(--radius);
}
.topnav__link:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.topnav__link[aria-current="page"] { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); border-radius: 0; }
.topbar__create { margin-left: 4px; }
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar__name { color: var(--text-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inline-form { display: inline; margin: 0; }

/* ---------- Shell: sidebar + page ---------- */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  flex: 0 0 240px;
  background: var(--bg-sunken);
  border-right: 1px solid var(--border);
  padding: 16px 8px;
  position: sticky;
  top: var(--topbar-h);
  align-self: flex-start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.sidebar__project { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.sidebar__icon {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 6px;
  background: #ffd5d2;
  color: #ae2e24;
  font-weight: 700;
}
.sidebar__title { margin: 0; font-weight: 600; }
.sidebar__subtitle { margin: 0; font-size: 12px; color: var(--muted); }
.sidebar__heading {
  margin: 8px 8px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.sidebar__link {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-subtle);
  font-weight: 500;
}
.sidebar__link:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.sidebar__link[aria-current="page"] {
  background: var(--bg-selected);
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}

.page {
  flex: 1;
  min-width: 0;
  max-width: 1200px;
  padding: 24px 40px 64px;
}
.no-shell .page { margin: 0 auto; }

.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--text-subtle); }
.breadcrumbs__current { display: inline-flex; align-items: center; gap: 6px; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}
.page-head h1 { margin: 0; }

/* ---------- Buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.1s ease-out;
}
.button:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.button:active { background: var(--accent-pressed); }
.button--subtle, .button--link {
  background: transparent;
  color: var(--text-subtle);
}
.button--subtle:hover, .button--link:hover { background: var(--bg-hover); color: var(--text); }
.button--subtle:active, .button--link:active { background: var(--border); }
.button--link { color: var(--accent); height: auto; padding: 2px 6px; }
.button--link:hover { color: var(--accent-hover); }

/* ---------- Lozenges, type icons, keys, avatars ---------- */
.lozenge, .badge {
  display: inline-block;
  padding: 0 4px;
  border-radius: var(--radius);
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge--todo        { background: var(--todo-bg);     color: var(--todo-fg); }
.badge--in_progress { background: var(--progress-bg); color: var(--progress-fg); }
.badge--done        { background: var(--done-bg);     color: var(--done-fg); }
.badge--not_planned { background: var(--np-bg);       color: var(--np-fg); }

.type-icon {
  display: inline-block;
  flex: none;
  width: 16px; height: 16px;
  border-radius: 3px;
  vertical-align: middle;
  position: relative;
}
.type-icon--bug { background: var(--bug); }
.type-icon--bug::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
}
.type-icon--feature { background: var(--feature); }
.type-icon--feature::after {
  content: "";
  position: absolute;
  left: 7px; top: 3px;
  width: 2px; height: 10px;
  background: #fff;
}
.type-icon--feature::before {
  content: "";
  position: absolute;
  left: 3px; top: 7px;
  width: 10px; height: 2px;
  background: #fff;
}

.request-no { color: var(--muted); white-space: nowrap; }
a.request-no { color: var(--text-subtle); }
a.request-no:hover { color: var(--accent); }
.jira-key {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}
a.jira-key { color: var(--accent); }
a.jira-key::after { content: " \2197"; font-family: var(--font); font-size: 11px; color: var(--muted); }

.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  user-select: none;
}
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--0 { background: #1d7afc; }
.avatar--1 { background: #6e5dc6; }
.avatar--2 { background: #1f845a; }
.avatar--3 { background: #c25100; }
.avatar--4 { background: #ae4787; }
.avatar--5 { background: #2898bd; }

/* ---------- Requests list ---------- */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--border); }
table.requests { width: 100%; border-collapse: collapse; }
.requests th, .requests td {
  padding: 8px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.requests th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.requests tbody tr:hover { background: var(--bg-sunken); }
.requests__type-col, .requests__type { width: 32px; }
.requests__type-label { display: none; }
.requests__key { width: 1%; white-space: nowrap; }
.requests__title a { color: var(--text); }
.requests__title a:hover { color: var(--accent); }
.request-row--updated .requests__title a { font-weight: 600; }
.requests__updated { white-space: nowrap; color: var(--text-subtle); }
.jira-keys { white-space: normal; }

.updated-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--dot);
  vertical-align: middle;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.empty {
  text-align: center;
  padding: 48px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted);
}
.empty__title { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--text); }

/* ---------- Request detail ---------- */
.request {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 32px;
  align-items: start;
}
.request__head { grid-column: 1; grid-row: 1; }
.request__main { grid-column: 1; grid-row: 2; }
.request__side { grid-column: 2; grid-row: 1 / span 2; }
.request__head .request__title { margin: 0; }
.request__main > .request__section:first-child { margin-top: 0; }
.request__title { font-size: 24px; line-height: 28px; font-weight: 500; overflow-wrap: anywhere; margin-bottom: 8px; }
.request__section { margin-top: 24px; }
.section-title { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--todo-bg);
  color: var(--text-subtle);
  font-size: 12px;
  text-align: center;
}

.request__side { position: sticky; top: calc(var(--topbar-h) + 24px); }
.request__status { margin-bottom: 16px; }
.request__status .lozenge { font-size: 12px; line-height: 20px; padding: 2px 8px; }
.details {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.details__title {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.details__list {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 16px 12px;
  margin: 0;
  padding: 16px;
}
.details__list dt { color: var(--text-subtle); font-weight: 600; padding-top: 2px; }
.details__list dd { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; overflow-wrap: anywhere; }
.links { display: flex; flex-direction: column; gap: 6px; list-style: none; margin: 0; padding: 0; }
.link { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.request__meta { margin: 12px 0 0; font-size: 12px; line-height: 18px; }

/* Comments */
.comments { display: flex; flex-direction: column; gap: 20px; margin-bottom: 20px; }
.comments__empty { margin: 0; }
.comment { display: flex; gap: 12px; }
.comment__main { flex: 1; min-width: 0; }
.comment__meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-bottom: 4px; }
.comment__author { font-weight: 600; }
.comment__time { font-size: 12px; }
.comment__time:hover { color: var(--text-subtle); }

.comment-form { display: flex; gap: 12px; }
.comment-form__main { flex: 1; min-width: 0; }

/* ---------- Attachments ---------- */
.attachments {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.attachment {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 16px;
  background: var(--surface);
}
.attachment:hover { box-shadow: var(--shadow-raised); }
.attachment__thumb-link { display: block; margin: -8px -8px 6px; }
.attachment__thumb {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}
.attachment__name { font-weight: 500; }

/* ---------- Forms ---------- */
.panel--form { max-width: 720px; }
.panel__intro { margin: -8px 0 16px; font-size: 12px; }
.required { color: var(--danger); }
.form { max-width: 100%; }
.field { margin-bottom: 16px; }
.field--narrow { max-width: 280px; }
.field label, .field__label {
  display: block;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--text-subtle);
  margin-bottom: 4px;
}
.field__label .muted { font-weight: 400; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field select, .field textarea {
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  color: inherit;
  transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}
.field input:hover, .field select:hover, .field textarea:hover { background: var(--bg-sunken); }
.field textarea { resize: vertical; min-height: 96px; }
.field input[type="text"]:focus, .field input[type="email"]:focus, .field input[type="password"]:focus, .field select:focus, .field textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--focus);
  box-shadow: inset 0 0 0 1px var(--focus);
}
.hint, .counter { margin: 4px 0 0; font-size: 12px; line-height: 16px; color: var(--muted); }
.counter { text-align: right; }
.counter--near { color: var(--danger); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-actions--end { justify-content: flex-end; }

/* Textarea as drop target */
textarea.is-dragover {
  border-color: var(--focus) !important;
  background: var(--bg-selected) !important;
  box-shadow: inset 0 0 0 1px var(--focus);
}

/* Drop zone around the file input */
.dropzone {
  position: relative;
  border: 1px dashed var(--border-input);
  border-radius: var(--radius-lg);
  background: var(--bg-sunken);
  transition: background-color 0.15s, border-color 0.15s;
}
.dropzone:hover { background: var(--bg-hover); }
.dropzone__input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  overflow: hidden;
}
.dropzone__input:focus-visible + .dropzone__label { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-lg); }
.field .dropzone__label {
  display: block;
  margin: 0;
  padding: 16px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-subtle);
  text-align: center;
  cursor: pointer;
}
.dropzone__icon { font-size: 18px; color: var(--muted); margin-right: 6px; vertical-align: -1px; }
.dropzone__browse { color: var(--accent); font-weight: 500; }
.dropzone.is-dragover {
  border: 2px dashed var(--focus);
  background: var(--bg-selected);
}
.dropzone.is-dragover .dropzone__label { padding: 15px; color: var(--accent); }

.form-errors {
  background: var(--danger-bg);
  color: var(--text);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.form-errors p, .form-errors ul { margin: 0; }
.form-errors ul { padding-left: 20px; margin-top: 4px; }

.file-error { color: var(--danger); margin: 6px 0 0; font-size: 12px; }
.file-preview {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.file-preview:empty { display: none; }
.file-preview__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
  font-size: 12px;
}
.file-preview__item > span { flex: 1; min-width: 0; }
.file-preview__thumb { width: 32px; height: 32px; object-fit: cover; border-radius: var(--radius); }
.file-preview__remove { margin-left: auto; }

/* ---------- Error page ---------- */
.error-page { text-align: center; padding: 64px 0; }
.error-page h1 { font-size: 48px; line-height: 1; font-weight: 600; color: var(--muted); }

/* ---------- Login ---------- */
.no-shell { background: var(--bg-sunken); }
.no-shell .topbar { justify-content: center; }
.login {
  max-width: 400px;
  margin: 48px auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 12px rgba(9, 30, 66, 0.15), 0 0 1px rgba(9, 30, 66, 0.31);
  padding: 32px 40px;
}
.login h1 { font-size: 16px; font-weight: 600; text-align: center; color: var(--text-subtle); }
.login .button { width: 100%; height: 40px; }
.login .form-actions { margin-top: 8px; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1100px) {
  .request { grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; }
  .page { padding: 24px 24px 64px; }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .request { grid-template-columns: 1fr; }
  .request { gap: 16px; }
  .request__head, .request__main, .request__side { grid-column: 1; grid-row: auto; }
  .request__side { position: static; order: 1; }
  .request__main { order: 2; }
}

@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .brand__name, .topbar__name { display: none; }
  .page { padding: 16px 16px 48px; }
  h1, .request__title { font-size: 20px; line-height: 24px; }

  .requests thead { display: none; }
  .requests, .requests tbody, .requests tr, .requests td { display: block; width: 100%; }
  .requests tr {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 8px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
  }
  .requests td { padding: 0; border: 0; width: auto; }
  .requests__type { display: flex; align-items: center; gap: 6px; }
  .requests__type-label { display: inline; color: var(--muted); font-size: 12px; }
  .requests__key { align-self: center; }
  .requests__title { grid-column: 1 / -1; font-size: 15px; }
  .requests__status, .jira-keys, .requests__updated { grid-column: 1 / -1; font-size: 12px; }
  .jira-keys:empty { display: none; }

  .details__list { grid-template-columns: 96px minmax(0, 1fr); }
  .comment .avatar, .comment-form > .avatar { width: 24px; height: 24px; font-size: 10px; }
  .comment, .comment-form { gap: 8px; }
  .login { margin: 16px; padding: 24px; }
}
