* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.4 system-ui, sans-serif; color: #1d1d1f; background: #f4f5f7; }
header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; background: #1f3a5f; color: #fff; position: sticky; top: 0; z-index: 1; }
header h1 { margin: 0; font-size: 1.15rem; }
nav { display: flex; align-items: center; gap: 4px; }
nav[hidden] { display: none; }
nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
nav a.on { background: rgba(255,255,255,.18); }
main { padding: 16px; max-width: 1200px; margin: 0 auto; }
a { color: #1f5fa8; }
button { font: inherit; padding: 6px 12px; border: 1px solid #9aa3ad; border-radius: 6px; background: #fff; cursor: pointer; }
button.primary, #add { background: #2a7a3b; border-color: #2a7a3b; color: #fff; }
button.danger { color: #b3261e; margin-right: auto; }
button.small { font-size: .8rem; padding: 2px 8px; }
input, select, textarea { font: inherit; padding: 7px; border: 1px solid #c4c9cf; border-radius: 6px; background: #fff; }
.search { width: 100%; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; }
.filters .search { flex: 1; margin: 0; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 8px; text-align: left; border-bottom: 1px solid #e3e5e8; vertical-align: top; }
th { background: #e9ecef; font-size: .85rem; }
td.nowrap, td.btns { white-space: nowrap; }
a.name { color: inherit; text-decoration: none; }
.sub { color: #555; font-size: .9rem; }
.pre { white-space: pre-wrap; }
tr.red td:first-child { border-left: 6px solid #d93025; }
tr.yellow td:first-child { border-left: 6px solid #f2b705; }
tr.green td:first-child { border-left: 6px solid #2a9d45; }
tr.red { background: #fdecea; }
tr.yellow { background: #fff8e1; }
tr.click { cursor: pointer; }
tr.click:hover { background: #f0f4fa; }
.tag { display: inline-block; font-size: .8rem; padding: 0 6px; border-radius: 4px; color: #fff; }
.red .tag { background: #d93025; }
.yellow .tag { background: #b58900; }
.green .tag { background: #2a9d45; }
.card { background: #fff; border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head h2 { margin: 0; }
.head .big { font-size: 1.1rem; margin-top: 4px; }
.head .btns { display: flex; gap: 8px; align-items: flex-start; }
.status { background: #e8eef7; color: #1f3a5f; padding: 6px 10px; border-radius: 6px; font-weight: 600; }
.status.dnc, .status-badge.dnc { background: #fdecea; color: #b3261e; }
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-weight: 600; font-size: .85rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 0 12px; }
.card h3 { margin: 0 0 8px; font-size: 1rem; color: #1f3a5f; }
dl { display: grid; grid-template-columns: 9.5em 1fr; gap: 3px 10px; margin: 0; font-size: .92rem; }
dt { color: #666; }
dd { margin: 0; min-height: 1.2em; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 6px; margin: 8px 0; }
.tabs .on { background: #1f3a5f; color: #fff; border-color: #1f3a5f; }
.tabs .primary { margin-left: auto; }
td.regarding { width: 60%; }
dialog { width: min(560px, 96vw); max-height: 92vh; border: none; border-radius: 10px; padding: 16px; }
dialog h2 { margin-top: 0; }
label { display: block; margin-bottom: 10px; font-size: .9rem; }
label input, label textarea, label select { display: block; width: 100%; }
label.check input { display: inline; width: auto; }
.actions { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: -16px; background: #fff; padding: 8px 0; }
.error { color: #b3261e; min-height: 1em; }
#login { max-width: 360px; margin: 60px auto; background: #fff; padding: 20px; border-radius: 10px; }
#login[hidden] { display: none; }

#calendar-btn { background: transparent; border: none; color: #fff; padding: 6px 10px; border-radius: 6px; }
#calendar-btn:hover { background: rgba(255,255,255,.18); }
#calendar { width: min(1100px, 96vw); max-width: 96vw; max-height: calc(100vh - 24px); border: none; border-radius: 10px; padding: 0; background: transparent; }
#calendar::backdrop { background: rgba(0,0,0,.45); }
.cal-box { background: #fff; border-radius: 10px; padding: 14px 16px 16px; max-height: calc(100vh - 24px); overflow: auto; }
.cal-toolbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-nav { grid-column: 2; display: flex; align-items: center; gap: 8px; }
.cal-toolbar h2 { margin: 0; font-size: 1.15rem; color: #1f3a5f; }
.cal-toolbar #cal-prev, .cal-toolbar #cal-next { min-width: 2.2em; font-size: 1.3rem; line-height: 1; }
.cal-actions { grid-column: 3; justify-self: end; display: flex; gap: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: .8rem; font-weight: 600; color: #555; text-align: center; padding: 4px 0; }
.cal-day { min-height: 5.6em; border: 1px solid #e3e5e8; border-radius: 6px; padding: 4px; background: #fafbfc; }
.cal-day.empty { background: #f4f5f7; border-color: transparent; }
.cal-day.today { outline: 2px solid #1f3a5f; background: #eef3f9; }
.cal-num { font-size: .8rem; font-weight: 600; color: #1f3a5f; margin-bottom: 2px; }
.cal-job { display: block; font-size: .72rem; line-height: 1.25; padding: 2px 4px; margin-bottom: 2px; border-radius: 4px; text-decoration: none; color: inherit; background: #e8f5eb; overflow-wrap: anywhere; }
.cal-job.red { background: #fdecea; }
.cal-job.yellow { background: #fff8e1; }
.cal-job.green { background: #e8f5eb; }
.cal-job .city { color: #555; }
.cal-list { display: none; }
.cal-list-day { padding: 8px 0; border-bottom: 1px solid #e3e5e8; }
.cal-list-date { font-weight: 600; margin-bottom: 4px; color: #1f3a5f; }
.cal-list .cal-job { font-size: .95rem; padding: 6px 8px; }


button.unit-note {
  display: block;
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  min-height: 2em;
  border: 1px solid transparent;
  background: #f7f9fc;
  border-radius: 6px;
  font: inherit;
  color: inherit;
}
button.unit-note:hover, button.unit-note:focus { border-color: #1f5fa8; background: #eef3f9; }
button.unit-note.empty { border-style: dashed; border-color: #c4c9cf; background: #fff; }
button.unit-note .add-note { color: #1f5fa8; font-size: .9rem; }
button.unit-note .pre { white-space: pre-wrap; }

@media (max-width: 700px) {
  .cal-toolbar { display: flex; flex-wrap: wrap; }
  .cal-nav { flex: 0 0 100%; }
  .cal-toolbar h2 { flex: 1; text-align: center; }
  .cal-actions { margin-left: auto; }
  .cal-grid { display: none; }
  .cal-list { display: block; }
}

@media print {
  @page { size: landscape; margin: 0.35in; }
  html, body { background: #fff !important; margin: 0 !important; }
  body > *:not(#calendar) { display: none !important; }
  #calendar {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    height: auto !important;
    border: none !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    box-shadow: none !important;
  }
  #calendar::backdrop { display: none !important; }
  .cal-box { padding: 0 !important; max-height: none !important; overflow: visible !important; border-radius: 0 !important; }
  .cal-actions, .cal-list, #cal-prev, #cal-next { display: none !important; }
  .cal-toolbar { display: block; margin-bottom: 6px; }
  .cal-toolbar h2 { font-size: 16pt; }
  .cal-grid { display: grid !important; gap: 2px; }
  .cal-day { min-height: 0; break-inside: avoid; page-break-inside: avoid; }
  .cal-job { font-size: 8pt; background: #f3f3f3; }
  .cal-job.red { background: #fdecea; }
  .cal-job.yellow { background: #fff8e1; }
}

@media (max-width: 700px) {
  main { padding: 10px; }
  header h1 { font-size: 1rem; }
  .filters { flex-wrap: wrap; }
  .filters .search { flex-basis: 100%; }
  .filters select { flex: 1; min-width: 0; }
  thead { display: none; }
  table, tbody, tr, td { display: block; }
  tr { margin-bottom: 8px; border-radius: 8px; overflow: hidden; background: #fff; border-left: 6px solid transparent; }
  tr.red { border-left-color: #d93025; }
  tr.yellow { border-left-color: #f2b705; }
  tr.green { border-left-color: #2a9d45; }
  tr td:first-child { border-left: none; }
  td { border: none; padding: 3px 10px; }
  td[data-label]:not(:empty)::before { content: attr(data-label) ": "; font-weight: 600; font-size: .85rem; }
  table.log tr { border-left-color: #c4c9cf; }
  table.log td { display: inline-block; }
  table.log td.regarding { display: block; width: auto; }
  .grid { grid-template-columns: 1fr; }
  dl { grid-template-columns: 8em 1fr; }
}
.notepad-log { max-height: 40vh; overflow-y: auto; border: 1px solid #e1e4e8; border-radius: 6px; padding: 8px; background: #fafbfc; white-space: pre-wrap; margin-top: 4px; }

.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; flex: 1; }
.scan-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
#scan-card {
  font-weight: 700;
  letter-spacing: .04em;
  min-height: 44px;
  min-width: 5.2em;
  padding: 8px 16px;
  background: #1f3a5f;
  border-color: #1f3a5f;
  color: #fff;
}
#scan-card:disabled, #scan-from-photos:disabled { opacity: .6; }
#scan-from-photos.scan-photos {
  font-size: .8rem;
  padding: 2px 6px;
  border: none;
  background: transparent;
  color: #1f5fa8;
  min-height: 28px;
  text-decoration: underline;
}
.scan-msg { margin: 0 0 10px; font-size: .9rem; color: #1f3a5f; }
.scan-msg.err { color: #b3261e; }
.sr-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}
#security-link { font-size: 1rem; }
.tfa { max-width: 520px; }
.tfa h2 { margin-top: 0; }
.tfa .actions { position: static; }
@media (max-width: 700px) {
  header { padding: 8px 10px; }
  nav { gap: 0; }
  nav a, #calendar-btn { padding: 6px 7px; }
  #add { white-space: nowrap; padding: 6px 8px; }
  #security-link { padding: 6px 4px; }
}
@media (max-width: 380px) {
  header { padding: 8px 6px; gap: 4px; }
  header h1 { font-size: .95rem; }
  nav a, #calendar-btn { padding: 6px 4px; }
  #add { padding: 6px 6px; }
}
.count-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.portal-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.portal-once { background: #fff8e1; border: 1px solid #f2b705; border-radius: 6px; padding: 8px 10px; margin: 8px 0; font-size: .95rem; }
.portal-once div { font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.portal-visit { border-top: 1px solid #e3e5e8; padding: 8px 0; font-size: .92rem; }
.portal-visit ul { margin: 4px 0 0; padding-left: 0; list-style: none; }
.portal-visit li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 2px 0; }
.portal-visit li a { overflow-wrap: anywhere; }
.upload-msg { min-height: 1.2em; }
