:root {
  color-scheme: light;
  --ink: #172f2a;
  --muted: #4b655d;
  --accent: #146451;
  --deep: #103e34;
  --line: #d6e5de;
  --field: #f4f8f6;
  --soft: #e3f1ea;
  --bg: #eaf2ee;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.55 system-ui, sans-serif; color: var(--ink); background: var(--bg); }
main { max-width: 650px; margin: auto; padding: 0 16px 28px; }
.app-header {
  margin: 0 -16px 16px;
  padding: 22px max(20px, env(safe-area-inset-right)) 18px max(20px, env(safe-area-inset-left));
  background: var(--deep);
  color: white;
}
.app-header h1 { margin: 0; font-size: clamp(1.3rem, 6vw, 1.8rem); line-height: 1.35; }
.app-header p { color: #d3ebe1; margin: 4px 0 0; font-size: .85rem; }
#session-status { color: var(--muted); margin: 0 4px 12px; font-size: .9rem; }
#status { margin: 0 4px 12px; color: #823421; overflow-wrap: anywhere; }
.screen { padding: 18px; margin: 0 0 14px; background: white; border: 1px solid var(--line); border-radius: 18px; }
h2, h3 { line-height: 1.35; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
p { overflow-wrap: anywhere; }
button, input, textarea, select { font: inherit; }
button {
  min-height: 44px;
  padding: 7px 12px;
  color: var(--accent);
  background: white;
  border: 1px solid #adc8bd;
  border-radius: 10px;
  font-weight: 650;
  cursor: pointer;
}
button:disabled, select:disabled { cursor: default; opacity: 1; color: var(--muted); background: #eff2f0; border-color: var(--line); }
:focus-visible { outline: 3px solid #287a69; outline-offset: 2px; }
input:not([type="checkbox"]):not([type="file"]), textarea, select {
  min-height: 44px;
  max-width: 100%;
  padding: 8px 11px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid #b9d2c7;
  border-radius: 10px;
}
input[type="file"] { max-width: 100%; }
[hidden] { display: none !important; }
[role="status"]:empty, #session-status:empty { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#register label, #login label, #role-password label, #customer-admin label, #backup-panel label { display: block; margin: 12px 0; }
#register input, #login input, #role-password input, #customer-admin textarea, #customer-admin select, #backup-panel input {
  display: block;
  width: 100%;
  margin: 4px 0 0;
}
#role-password button, #customer-form button, #photo-editor button, .tool-content button { margin: 8px 4px 0 0; }
.button-primary { background: var(--accent); color: white; border-color: var(--accent); }
.button-soft { background: var(--soft); border-color: var(--soft); }
.screen-heading, .management-session { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.screen-heading h2, #management-page-title { margin: 0; }
.search-field { position: relative; display: block; margin: 16px 0 12px; }
.search-field::before, .search-field::after { content: ''; position: absolute; pointer-events: none; }
.search-field::before {
  width: 13px;
  height: 13px;
  left: 15px;
  top: 14px;
  border: 2px solid var(--accent);
  border-radius: 50%;
}
.search-field::after {
  width: 8px;
  height: 2px;
  left: 27px;
  top: 29px;
  background: var(--accent);
  transform: rotate(45deg);
}
#search { display: block; width: 100%; padding-left: 43px; }
.region-control { display: flex; align-items: center; gap: 10px; color: var(--muted); }
#activity-controls { margin: 13px 0; }
#activity-controls label { color: var(--muted); font-weight: 650; }
.activity-inputs { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.activity-inputs select { flex: 1; min-width: 0; }
#activity-availability, #activity-status { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }
#customers { list-style: none; margin: 4px 0 0; padding: 0; }
#customers li { border-top: 1px solid var(--line); }
.customer-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 11px 24px 11px 0;
  border: 0;
  border-radius: 0;
  text-align: left;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.customer-button::after, .admin-tool > summary::after {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  content: '›';
  color: var(--accent);
  font-size: 1.55rem;
  line-height: 1;
}
.customer-name, .customer-area, .customer-activity-summary { display: block; }
.customer-area { color: var(--muted); font-size: .875rem; font-weight: 500; }
.customer-activity-summary { color: var(--accent); font-size: .875rem; margin-top: 3px; }
.back-button { border: 0; padding: 0; margin-bottom: 10px; }
.detail-header { display: flex; align-items: flex-end; gap: 10px; border-bottom: 1px solid var(--line); padding: 6px 0 14px; }
.detail-header h2 { flex: 1; margin: 0; font-size: 1.65rem; overflow-wrap: anywhere; }
#detail-area { flex: 0 1 auto; margin: 0; padding: 3px 10px; background: var(--soft); color: var(--accent); border-radius: 9px; font-size: .9rem; }
.collection {
  display: grid;
  grid-template-columns: minmax(85px, 1fr) minmax(0, 1.5fr);
  margin: 0;
  padding: 0 12px;
  background: var(--field);
  border-radius: 12px;
}
.collection dt, .collection dd { margin: 0; padding: 8px 4px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.collection dt { color: var(--muted); }
.collection dd { font-size: 1rem; font-weight: 700; white-space: pre-wrap; }
.collection > :nth-last-child(-n+2) { border-bottom: 0; }
.detail-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.notice { background: #fff1c9; border: 1px solid #ebd69a; border-left: 5px solid #c68e24; padding: 12px; border-radius: 12px; color: #423013; }
.notice h3, .notice p { margin: 0; }
.notice p { margin-top: 5px; }
.photo-preview { width: 100%; padding: 0; overflow: hidden; background: var(--field); }
.site-photo { display: block; max-width: 100%; max-height: 320px; margin: auto; object-fit: contain; }
#photo-dialog { width: min(92vw, 720px); max-height: 90vh; border: 1px solid var(--line); border-radius: 12px; }
#photo-dialog::backdrop { background: #0b201bd9; }
#photo-large { display: block; max-width: 100%; max-height: 74vh; object-fit: contain; margin: 10px auto 0; }
.management-session { flex-wrap: wrap; margin: 9px 0 16px; }
.management-session p { margin: 0; color: var(--muted); }
.customer-actions { display: grid; gap: 9px; }
#customer-form { margin-top: 14px; }
#customer-admin textarea { resize: vertical; }
.operations-card { padding: 14px; margin-top: 20px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; }
.operations-card h3 { margin: 0; }
.operations-card p { margin: 6px 0; color: var(--muted); }
.operations-card button { display: block; margin-left: auto; }
.tools-heading { margin: 18px 0 3px; color: var(--muted); }
.admin-tool { border-bottom: 1px solid var(--line); }
.admin-tool > summary {
  position: relative;
  min-height: 44px;
  padding: 10px 24px 10px 0;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}
.admin-tool > summary::-webkit-details-marker { display: none; }
.admin-tool[open] > summary::after { transform: translateY(-50%) rotate(90deg); }
.tool-content { padding: 0 0 14px; }
#code, #edit-conflict, #backup-status, #history-rows { overflow-wrap: anywhere; }
#edit-conflict { padding: 10px; margin-bottom: 10px; background: var(--field); }
#history-rows dd { margin: 0 0 8px; white-space: pre-wrap; }
@media (max-width: 360px) {
  main { padding-inline: 10px; }
  .app-header { margin-inline: -10px; }
  .screen { padding: 14px; }
  .detail-header { align-items: flex-start; }
}
