:root {
  color-scheme: light;
  --ink: #1f302e;
  --muted: #647471;
  --line: #dce5e1;
  --surface: #fff;
  --canvas: #f3f7f5;
  --accent: #176d57;
  --accent-dark: #105441;
  --soft: #e5f2ed;
  --warning: #a65b18;
  --danger: #a13d36;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.topbar { min-height: 64px; padding: 12px max(20px, calc((100vw - 1160px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 18px; background: #153b35; color: white; }
.brand { color: white; text-decoration: none; font-weight: 750; letter-spacing: .01em; }
.account { display: flex; align-items: center; gap: 12px; font-size: .92rem; }
main { width: min(1160px, calc(100% - 32px)); min-height: calc(100vh - 128px); margin: 30px auto 50px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.7rem, 4vw, 2.5rem); }
h2 { margin-bottom: 12px; font-size: 1.3rem; }
h3 { font-size: 1.02rem; }
.welcome { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.eyebrow { margin-bottom: 6px; color: var(--accent); font-size: .7rem; font-weight: 800; letter-spacing: .13em; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 7px 12px; background: var(--soft); color: var(--accent-dark); font-size: .82rem; font-weight: 700; }
.tabs { display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab { padding: 12px 15px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); white-space: nowrap; font-weight: 650; }
.tab.active { border-color: var(--accent); color: var(--accent-dark); }
.panel, .auth-card, .task-card, .item-card, .checkout-card, .history-card, .user-card { border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 4px 18px rgb(31 48 46 / 4%); }
.panel { padding: 22px; margin-bottom: 18px; }
.auth-card { max-width: 480px; margin: 7vh auto; padding: clamp(24px, 5vw, 42px); }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: #40514e; font-size: .88rem; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid #cbd8d3; border-radius: 8px; padding: 9px 11px; background: white; color: var(--ink); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgb(23 109 87 / 15%); border-color: var(--accent); }
.button { min-height: 40px; border: 1px solid var(--accent); border-radius: 8px; padding: 9px 14px; background: var(--accent); color: white; font-weight: 700; }
.button:hover { background: var(--accent-dark); }
a.button { display: inline-block; text-decoration: none; }
.button-secondary { border-color: #cbd8d3; background: white; color: var(--accent-dark); }
.button-secondary:hover { background: var(--soft); }
.button-quiet { min-height: 34px; border-color: rgb(255 255 255 / 25%); background: transparent; padding: 6px 10px; }
.button-danger { border-color: #e4c7c4; background: #fff8f7; color: var(--danger); }
.actions, .section-heading, .search-row, .task-actions, .form-end { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-heading { margin-bottom: 15px; }
.section-heading h2 { margin-bottom: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.filters label { min-width: 130px; flex: 1; }
.filters .grow, .search-row .grow { flex: 2 1 230px; }
.filters.compact { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.span-2 { grid-column: span 2; }
.form-end { justify-content: flex-end; }
.admin-editor { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #f8fbf9; }
.upload-status { display: grid; gap: 7px; color: var(--muted); font-size: .9rem; }
.upload-status progress { width: 100%; min-height: 12px; accent-color: var(--accent); }
.card-list { display: grid; gap: 12px; }
.task-card, .item-card, .checkout-card, .history-card, .user-card { padding: 17px; }
.role-permission-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px 14px; }
.role-permission-grid label { display: flex; align-items: center; gap: 8px; }
.role-permission-grid input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; margin: 0; padding: 0; accent-color: var(--accent); }
.role-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fbfdfc; }
.task-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-top h3 { margin-bottom: 5px; }
.task-meta, .muted { color: var(--muted); font-size: .88rem; line-height: 1.5; }
.task-assignee-options { display: grid; gap: 9px; min-width: 0; }
.task-assignee-toolbar { display: flex; align-items: center; gap: 12px; }
.task-assignee-toolbar input { min-width: 180px; }
.task-assignee-toolbar .muted { flex: 0 0 auto; white-space: nowrap; }
.task-assignee-queue { justify-self: start; }
.task-assignee-queue.selected { border-color: var(--accent); background: var(--soft); }
.task-assignee-selected { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 32px; }
.task-assignee-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 3px 7px 3px 10px; border: 1px solid #b8d6ca; border-radius: 999px; background: var(--soft); color: var(--accent-dark); font-size: .82rem; }
.task-assignee-chip span { overflow-wrap: anywhere; }
.task-assignee-chip button { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 1.05rem; }
.task-assignee-list { display: grid; gap: 4px; max-height: 220px; overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: #fbfdfc; }
.task-assignee-list[hidden] { display: none; }
.task-assignee-option { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 7px 9px; border-radius: 7px; cursor: pointer; }
.task-assignee-option:hover { background: #eef6f2; }
.task-assignee-option[hidden] { display: none; }
.task-assignee-option input[type="checkbox"] { width: 19px; min-width: 19px; min-height: 19px; height: 19px; margin: 0; padding: 0; accent-color: var(--accent); }
.task-assignee-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-description { white-space: pre-wrap; line-height: 1.5; }
.task-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 13px; }
.task-actions form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-actions input[type="file"] { max-width: 260px; }
.photo-source { position: relative; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.photo-source input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.photo-selection { display: grid; gap: 6px; margin: 0; padding-left: 20px; }
.photo-selection li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.workshop-tabs { display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.work-order-files { display: grid; gap: 8px; margin-top: 12px; }
.work-order-file { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.work-order-complete { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.work-order-complete label { min-width: min(100%, 280px); }
.description-editor { display: grid; gap: 8px; margin: 10px 0; }
.description-editor textarea { width: 100%; }
.status-Unassigned { background: #edf0f1; color: #4e5c60; }
.status-Open, .status-Active { background: #e7f1ff; color: #295489; }
.status-Completed { background: #fff0d8; color: var(--warning); }
.status-Verified { background: #e4f4e9; color: #267343; }
.status-ReassignedIncomplete, .status-ReturnedForRevision { background: #fff0ed; color: #993d34; }
.history-line { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; font-size: .87rem; line-height: 1.5; }
.photo-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.photo-picker { display: grid; gap: 8px; }
.task-completion-comment { width: 100%; }
.photo-preview { max-width: min(100%, 520px); max-height: 430px; border-radius: 9px; border: 1px solid var(--line); object-fit: contain; background: #f2f4f3; }
.photo-dialog { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 20px; background: rgb(0 0 0 / 72%); }
[hidden] { display: none !important; }
.photo-dialog img { max-width: min(100%, 1000px); max-height: 85vh; }
.notice { border-radius: 9px; margin-bottom: 16px; padding: 12px 14px; background: #e8f3ee; color: #145a43; }
.notice.error { background: #fff0ed; color: #913e36; }
.employee-picker { max-width: 500px; margin: 16px 0 22px; }
.report-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 20px; }
.report-grid h3 { margin-bottom: 12px; }
.scanner { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f7faf8; }
.scanner video { display: block; width: min(100%, 520px); max-height: 330px; margin-bottom: 10px; border-radius: 8px; background: #152522; }
.empty { border: 1px dashed #c5d2cc; border-radius: 10px; padding: 18px; color: var(--muted); text-align: center; }
footer { padding: 22px 16px; color: var(--muted); text-align: center; font-size: .82rem; }
.hidden { display: none !important; }

@media (max-width: 740px) {
  main { width: min(100% - 20px, 600px); margin-top: 18px; }
  .topbar { padding: 12px 15px; }
  .panel { padding: 16px; }
  .form-grid, .report-grid { grid-template-columns: 1fr; }
  .task-actions form.admin-editor { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .welcome { align-items: flex-start; }
  .section-heading { align-items: flex-start; }
  .filters label { min-width: calc(50% - 8px); }
  .filters .grow { flex: 1 1 100%; }
  .task-actions form { align-items: stretch; }
  .actions { align-items: stretch; flex-direction: column; }
}

.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; padding: 16px 0; }
.pagination select { width: auto; }

.metal-facts { display: flex; flex-wrap: wrap; gap: 16px 32px; margin: 12px 0; }
.size-search-help { margin: 14px 0 0; }
.filters .size-mode-field { flex: 1 1 210px; min-width: min(210px, 100%); }
.size-match { color: var(--accent-dark); font-size: .88rem; font-weight: 650; margin: 8px 0; }
.size-match-Smaller { color: var(--warning); }
.user-removal-dialog { width: min(600px, calc(100vw - 24px)); max-height: 90vh; overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); }
.user-removal-dialog::backdrop { background: rgb(10 35 30 / 55%); }
.user-removal-dialog h2 { margin: 0; }
.archive-comment { margin-top: 12px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; }
.checkbox-label input[type="checkbox"] { width: 20px; min-height: 20px; flex: 0 0 auto; }
.work-order-urgent, .task-urgent { border-left: 5px solid #bd3a30; background: #fff8f5; }
.urgent-badge { background: #a92e25; color: white; letter-spacing: .04em; }
.order-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.file-selection { font-weight: 400; min-width: 0; }
.file-selection ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.file-selection li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.file-selection li span { overflow-wrap: anywhere; min-width: 0; }
.file-selection button { flex: 0 0 auto; }
#employee-details { margin-top: 24px; scroll-margin-top: 20px; }
.profile-password-panel, #employee-profile-edit-panel { margin-top: 20px; }
.metal-facts dt { font-size: .8rem; color: var(--muted, #617571); }
.metal-facts dd { margin: 3px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.metal-card, .metal-usage { overflow-wrap: anywhere; }
.urgent-bell { position: relative; flex-shrink: 0; min-width: 42px; }
.urgent-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; padding: 2px 5px; border-radius: 20px; background: #a72529; color: #fff; font-size: .75rem; }
.chat-layout { display: grid; grid-template-columns: minmax(230px, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
.chat-sidebar, .chat-room { min-width: 0; }
.chat-group-button { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.chat-group-button.selected { background: #d8ece5; border-color: #21745e; }
.chat-messages { display: flex; flex-direction: column; gap: 12px; max-height: 65vh; overflow-y: auto; overflow-x: hidden; padding: 10px 2px; margin: 10px 0; }
.chat-message { border: 1px solid var(--line); border-radius: 12px; background: #f6faf8; padding: 14px; min-width: 0; overflow-wrap: anywhere; }
.chat-message header, .chat-message summary { font-weight: 650; font-size: .9rem; }
.chat-message summary { cursor: pointer; }
.chat-own { background: #e9f4ef; }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 12px 0; }
.chat-unread { border-left: 4px solid #b83432; }
.chat-attachments { display: grid; gap: 10px; }
.chat-file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chat-file > span { width: 100%; overflow-wrap: anywhere; }
.chat-photo { width: 100%; max-width: 480px; max-height: 400px; object-fit: contain; border-radius: 8px; }
#chat-recipients { max-height: 240px; overflow: auto; }
#chat-private-compose { margin-top: 20px; }
@media (max-width: 760px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-messages { max-height: 55vh; }
  .account { gap: 6px; }
  #account-name { max-width: 140px; }
}
.metal-group-details { margin-top: 14px; }
.metal-kind-tabs { margin-bottom: 14px; }
.role-create-details > summary { cursor: pointer; color: var(--accent-dark); list-style-position: inside; }
.role-create-details > summary h2 { display: inline; margin: 0; font-size: 1.15rem; }
.role-create-details[open] > summary { margin-bottom: 14px; }
.role-list-details { margin-top: 18px; }
.role-list-details > summary { cursor: pointer; color: var(--accent-dark); list-style-position: inside; }
.role-list-details > summary h2 { display: inline; margin: 0; font-size: 1.15rem; }
.role-list-details[open] > summary { margin-bottom: 14px; }
.metal-panel-summary { cursor: pointer; color: var(--accent-dark); list-style-position: inside; }
.metal-panel-summary h2 { display: inline; margin: 0; }
.metal-stock-details > .section-heading { margin: 10px 0; }
.metal-create-details > form { margin-top: 14px; }
.metal-catalog-details { margin-top: 18px; }
.metal-catalog-details > summary { margin-bottom: 12px; }
.metal-catalog-details > summary h3 { display: inline; margin: 0; font-size: 1rem; }
.metal-group-details > summary { cursor: pointer; color: var(--accent-dark); font-weight: 650; padding: 8px 0; }
.metal-pieces { display: grid; gap: 10px; margin-top: 10px; }
.metal-piece { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #f8fbf9; }
.metal-piece h4 { margin: 0 0 8px; font-size: .9rem; }
.metal-count { white-space: nowrap; }
.metal-comment-editor { margin-top: 12px; }
.metal-comment-editor button { margin-top: 8px; }
.order-metals { margin: 12px 0; }
.metal-usage { background: #f1f7f5; border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.metal-usage p { margin: 6px 0 0; }
.metal-remainders { border: 1px solid #c9d8d4; border-radius: 10px; padding: 14px; min-width: 0; }
.metal-remainders label { display: block; margin: 10px 0; }
.metal-remainders input { margin-top: 6px; }
.metal-picker { border: 1px solid #c9d8d4; border-radius: 16px; padding: 24px; width: min(960px, calc(100vw - 32px)); max-height: 90vh; overflow: auto; color: inherit; }
.metal-picker::backdrop { background: rgb(10 35 30 / 55%); }
.metal-picker h2 { margin: 0; }
.metal-picker-filters label:first-child { min-width: 160px; }
.metal-pick-row { display: flex; align-items: start; gap: 12px; padding: 14px; border: 1px solid #d6e3df; border-radius: 10px; cursor: pointer; overflow-wrap: anywhere; }
.metal-pick-row input[type="checkbox"] { flex: 0 0 auto; width: 20px; height: 20px; margin: 3px 0; }
.metal-pick-row span { min-width: 0; }
.metal-selection { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.metal-chip { white-space: normal; text-align: left; }
.metal-picker-footer { position: sticky; bottom: -24px; background: white; padding: 14px 0; margin-top: 10px; }
@media (max-width: 740px) {
  .metal-picker { padding: 16px; width: calc(100vw - 20px); }
  .metal-picker .section-heading { align-items: start; }
  .metal-picker h2 { font-size: 1.25rem; }
  .metal-facts { gap: 12px 24px; }
}
