:root {
  --accent: #bed335;
  --ink: #000;
  --text: #1a1a1a;
  --page: #f5f6f3;
  --surface: #fff;
  --line: #dfe2da;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: "Satoshi", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1 { margin: 0 0 16px; font-size: 1.75rem; font-weight: 700; }
p { margin: 0 0 12px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 28px;
  background: #000;
  border-bottom: 1px solid var(--line);
}

.brand { display: block; padding: 0; background: none; }
.brand img { display: block; width: 150px; height: 48px; object-fit: contain; object-position: left center; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.header-logo { display: block; width: 160px; height: 48px; object-fit: contain; }
.header-icon {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
}
.header-icon:hover { text-decoration: none; box-shadow: 0 0 0 3px #fff3; }
.header-icon svg { width: 25px; height: 25px; fill: currentColor; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.hierarchy ul { list-style: none; margin: 0; padding: 0 0 0 28px; border-left: 1px dashed var(--line); }
.hierarchy li { padding: 4px 0; }
.hierarchy summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.hierarchy .leaf { display: inline-block; padding: 4px 0; font-weight: 500; }
.section-heading .buttons { margin-top: 0; }
.reportees-card { width: min(640px, 94vw); margin-top: 24px; }
.reportees-card h2 { margin: 0; font-size: 1.25rem; }
.reportee-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.reportee-heading .assign-bar { margin: 0; }
.card.addissue-card { width: 70%; margin: 0 auto; }
.label-row { display: flex; align-items: center; gap: 8px; }
.helper-icon {
  position: relative;
  display: inline-grid;
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1;
}
.helper-icon:disabled { cursor: wait; }
.helper-icon.is-loading { color: transparent; }
.helper-icon.is-loading::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid var(--ink);
  border-right-color: transparent;
  border-radius: 50%;
  animation: helper-spin 0.8s linear infinite;
}
@keyframes helper-spin {
  to { transform: rotate(360deg); }
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-weight: 500; }
.field textarea {
  min-height: 90px;
  padding: 9px 11px;
  border: 1px solid #b9bdb5;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.field .actions-row { text-align: center; }
@media (max-width: 720px) {
  .field-grid { grid-template-columns: 1fr; }
}

.account-menu { position: static; }
.account-menu summary { list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  cursor: pointer;
}
.account-menu summary:hover,
.account-menu summary:focus-visible { background: var(--accent); box-shadow: 0 0 0 3px #fff3; outline: none; }
.account-menu summary svg { width: 25px; height: 25px; fill: currentColor; }

.account-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 28px;
  width: min(300px, 88vw);
  padding: 16px;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
}
.account-dropdown p { margin-bottom: 8px; overflow-wrap: anywhere; }
.account-dropdown a { display: block; margin-top: 8px; }
.account-dropdown a:hover { text-decoration: none; }

/* Layout */
.content-page { width: min(1120px, 92vw); margin: 36px auto; }
.content-page.wide-page { width: min(1600px, 96vw); }
.content-page.full-page { width: min(1920px, 98vw); }
.centered-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  width: min(100%, 92vw);
  margin: 0 auto;
  padding: 24px 0;
}
.centered-page .messages { width: min(480px, 94vw); }
.card { width: 100%; padding: 28px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-heading h1 { margin: 0; }
.section-heading .button-link { flex: 0 0 auto; }
.welcome-card { padding: 14px 28px; }
.welcome-card h1 { margin: 0 0 2px; font-size: 1.25rem; }
.welcome-card p { margin-bottom: 0; }

/* Links and buttons: bold text on #bed335 */
a,
button,
input[type="submit"] {
  font: inherit;
  font-weight: 700;
}

a {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--ink);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

.button-link,
button,
input[type="submit"] {
  display: inline-block;
  min-height: 42px;
  padding: 9px 18px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.button-link:hover,
button:hover,
input[type="submit"]:hover { text-decoration: none; filter: brightness(0.92); }

/* Forms */
label, th { color: var(--text); }
input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #b9bdb5;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus { outline: none; }
input[name*="password"]:focus { border-color: var(--accent); box-shadow: 0 0 0 2px #bed33588; }
input[readonly] { color: #5a5f55; background: var(--page); }

.form-table { width: auto; min-width: min(460px, 92vw); margin: 0 auto; border-collapse: separate; border-spacing: 0 12px; }
.form-table th,
.form-table td { padding: 0; border: 0; text-align: left; }
.form-table th { padding-bottom: 4px; background: none; font-weight: 700; }
.form-table th.label,
.form-table td.label { width: 120px; padding-right: 16px; text-align: right; font-weight: 500; vertical-align: middle; }
.form-table td.actions-row { text-align: center; }
.form-table td.nowrap { white-space: nowrap; }
.form-table .buttons { display: flex; justify-content: center; gap: 12px; }
.form-table p { margin: 0; }
.form-table .muted { color: #5a5f55; font-size: 0.9rem; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); }
th { background: #f0f1ec; }
.issues-table { font-size: 0.85rem; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 16px; font-size: 0.85rem; }
.clear-filters { font-size: 0.85rem; }
.heading-tools { display: flex; align-items: center; gap: 16px; flex: 0 0 auto; }
.per-page-form { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.per-page-form label { font-weight: 700; white-space: nowrap; }
.per-page-form select { width: auto; min-height: 34px; padding: 6px 8px; font-size: 0.85rem; }
.case-link { padding: 0; background: none; color: var(--text); font-weight: 700; }
.issues-table th,
.issues-table td.date { white-space: nowrap; }
.issues-table .filter-row th { padding: 6px 8px; background: var(--surface); font-weight: 400; }
.issues-table .filter-row input,
.issues-table .filter-row select { min-height: 34px; padding: 6px 8px; font-size: 0.85rem; }
.issues-table .filter-row select { min-width: 5.5rem; }
.issues-table select[name="date_month"],
.issues-table select[name="case_owner"] { min-width: 8.5rem; }
.issues-table .remarks-col { min-width: 10rem; }
.status-filter { position: relative; }
.status-filter summary { min-height: 34px; padding: 6px 8px; border: 1px solid #b9bdb5; border-radius: 6px; background: var(--surface); font-size: 0.85rem; list-style: none; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9rem; }
.status-filter summary::-webkit-details-marker { display: none; }
.status-options { position: absolute; right: 0; z-index: 10; display: grid; gap: 6px; margin-top: 4px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; white-space: nowrap; }
.status-options label { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.status-options input[type="checkbox"] { width: auto; min-height: 0; margin: 0; padding: 0; border: 0; }
.status-options button { justify-self: end; }
.issues-table select { width: 100%; border: 1px solid #b9bdb5; border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
td { color: var(--text); }

.actions { white-space: nowrap; }
.icon-link {
  display: inline-grid;
  width: 36px;
  height: 36px;
  margin-right: 5px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--ink);
  background: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.activity-values { white-space: pre-line; min-width: 120px; max-width: 260px; overflow-wrap: anywhere; }
.activities-table th:nth-child(2),
.activities-table td:nth-child(2) { min-width: 220px; }

/* Issue dialog */
.issue-dialog {
  width: min(960px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
}
.issue-dialog::backdrop { background: rgb(0 0 0 / 55%); }
.issue-dialog .messages { margin-bottom: 24px; }
.dialog-head {
  position: sticky;
  top: -24px;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: -24px -24px 16px;
  padding: 24px 24px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.dialog-head h2 { margin: 0; font-size: 1.15rem; }
.issue-dialog h3 { margin: 0 0 8px; font-size: 1rem; }
.detail-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.detail-table td { vertical-align: top; padding: 8px 12px 8px 0; border: 0; }
.detail-grid { display: grid; grid-template-columns: 55% 45%; gap: 0 12px; align-items: stretch; width: 100%; }
.detail-col { display: flex; flex-direction: column; min-width: 0; }
.detail-col > .detail-section, .detail-col > fieldset { flex: 1; display: flex; flex-direction: column; margin-top: 0; }
.detail-col > fieldset > .detail-section:first-child { margin-top: 0; }
.detail-col > fieldset > .product-details { flex: 1; }
.editable { display: flex; flex-direction: column; }
.editable .edit-field { display: none; }
.editable.editing .edit-field { display: block; }
.editable.editing .view-value { display: none; }
.editable .edit-save, .editable .edit-cancel { display: none; }
.editable.editing .edit-toggle { display: none; }
.editable.editing .edit-save, .editable.editing .edit-cancel { display: inline-block; }
.block-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; padding-top: 12px; }
.block-actions button { min-height: 30px; padding: 4px 14px; font-size: 0.85rem; }
.issue-details .kv { grid-template-columns: 150px 1fr; }
.issue-details .kv + fieldset .kv { margin-top: 6px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: #5a5f55; font-weight: 500; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.issue-dialog .kv dt { color: #6b6b6b; font-weight: 700; }
.issue-dialog .kv dd { color: var(--text); font-weight: 400; }
.issue-dialog .kv input,
.issue-dialog .kv select,
.issue-dialog .kv textarea { min-height: 34px; padding: 6px 8px; font-size: 0.85rem; }
.issue-dialog .kv select,
.issue-dialog .kv textarea { width: 100%; border: 1px solid #b9bdb5; border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
.issue-dialog .kv textarea { min-height: 70px; resize: vertical; }
.detail-section { margin-top: 16px; }
.detail-section.bordered { padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; }
.location-form { width: 100%; margin-top: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; }
.location-form h2 { margin: 0 0 12px; font-size: 1.25rem; }
.location-form .buttons { justify-content: center; }
.locations-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; width: min(1100px, 96vw); align-items: start; }
.locations-layout > div { min-width: 0; }
.location-search { display: flex; gap: 12px; align-items: center; }
.location-search input { flex: 1; }
.location-search button { flex: 0 0 auto; }
.location-results { margin-top: 12px; }
.location-results th, .location-results td { padding: 6px 10px; text-align: left; }
@media (max-width: 900px) {
  .locations-layout { grid-template-columns: 1fr; }
}
.pattern-layout { display: grid; grid-template-columns: 60% 40%; gap: 24px; align-items: stretch; width: 100%; }
.pattern-left, .pattern-right { min-width: 0; }
.pattern-right { display: flex; flex-direction: column; contain: size; min-height: 0; }
.pattern-table-wrap { flex: 1; min-height: 0; overflow: auto; }
.pattern-right th:first-child, .pattern-right td:first-child { width: 70px; max-width: 70px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pattern-right pre { margin: 0; white-space: pre-wrap; word-break: break-all; font-size: 0.85rem; }
@media (max-width: 900px) {
  .pattern-layout { grid-template-columns: 1fr; }
}
fieldset.edit-scope { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.edit-scope[disabled] { opacity: 0.7; }
.notice { margin: 8px 0 0; color: #ff4d4d; font-weight: 700; }
.assign-bar { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; }
.assign-bar label { font-weight: 700; }
.assign-bar select { width: auto; min-width: 260px; }
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #b9bdb5;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.detail-section > summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.upload-form { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.upload-form input[type="file"] { width: auto; min-height: 0; padding: 6px 0; border: 0; }
.files-table th, .files-table td { padding: 8px 10px; }
.editor-toolbar { display: flex; gap: 6px; margin-bottom: 6px; }
.editor-toolbar button { min-height: 30px; padding: 4px 10px; font-size: 0.85rem; }
.editor {
  min-height: 120px;
  max-height: 260px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid #b9bdb5;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.editor:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px #bed33588; }
.comment { padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment-meta { margin: 0 0 4px; color: #5a5f55; font-size: 0.85rem; }
.comment-body p { margin: 0 0 6px; }
.buttons { display: flex; gap: 12px; margin-top: 10px; }

/* Flash messages */
.messages { width: 100%; margin-bottom: 18px; }
.message { margin: 0 0 10px; font-weight: 500; }
.message.error { color: #ff4d4d; font-weight: 700; }
.message.success { color: var(--text); }
.message.imported { color: #1f8f3a; font-weight: 700; }

@media (max-width: 560px) {
  .site-header { padding: 12px 16px; }
  .account-dropdown { right: 16px; }
  .brand img { width: 120px; }
  .header-logo { width: 110px; }
  .card { padding: 22px 18px; }
  .section-heading { align-items: center; }
  .form-table th.label,
  .form-table td.label { width: auto; padding-right: 10px; }
}
