:root { font: 14px/1.45 var(--workspace-font); color: var(--ink); background: var(--paper); }

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.app-header :focus-visible { outline-color: var(--selected); }

.header-search { display: flex; align-items: center; gap: 8px; }
.header-search input { min-width: 0; height: 40px; }

.button, .header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--field-line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button:hover { background: var(--hover); }
.button-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button-primary:hover { background: #063558; }
.header-button { min-height: 40px; border-color: #ffffff88; background: transparent; color: #fff; }
.header-button:hover { background: #205273; }

.workspace { padding: 14px var(--workspace-padding) 26px; }
.page-heading, .filter-actions, .pagination {
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-heading, .pagination { justify-content: space-between; }
.page-heading { margin-bottom: 14px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; }
.muted { margin: 0; color: var(--muted); font-size: 13px; }

.directory {
  display: grid;
  grid-template-columns: 235px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 325px;
  height: calc(100dvh - 257px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 3px 12px #16395408;
  overflow: hidden;
}
.directory:has(> .filters:not([open])) { grid-template-columns: 48px minmax(0, 1fr); }
.filters { min-width: 0; overflow: auto; border-right: 1px solid var(--line); background: var(--wash); }
.filters summary {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.filters summary:focus-visible { outline-offset: -3px; }
.filters:not([open]) summary { writing-mode: vertical-rl; padding: 16px 13px; min-height: 100px; border-bottom: 0; }
.filter-form { padding: 12px; }
.filter-form fieldset {
  min-width: 0;
  margin: 0;
  padding: 7px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.filter-form legend { padding: 0 4px; font-weight: 650; font-size: 12px; }
.filter-option {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.filter-option:hover { background: var(--selected); }
.filter-option input { margin: 3px 0 0; accent-color: var(--brand); }
.filter-actions { flex-wrap: wrap; margin-top: 12px; gap: 6px; }

input:not([type=hidden], [type=radio]) {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--field-line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.grid-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.table-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  background: var(--wash);
  scrollbar-color: #91a8bb #eef3f8;
  scrollbar-gutter: stable;
}
.table-scroll:focus-visible { outline-offset: -2px; }
table {
  width: 100%;
  min-width: 650px;
  border-spacing: 0;
  table-layout: fixed;
  text-align: left;
  background: var(--surface);
  font-size: 13px;
}
.store-number-col { width: 100px; }
.store-phone-col { width: 145px; }
.store-status-col { width: 175px; }
th, td {
  height: 42px;
  padding: 7px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
th:last-child, td:last-child { border-right: 0; }
thead th { position: sticky; top: 0; background: var(--table-head); font-weight: 650; }
thead th a { display: block; color: inherit; text-decoration: none; }
thead th a:hover { text-decoration: underline; }
thead th[aria-sort=ascending] a::after { content: " ↑"; }
thead th[aria-sort=other] a::after { content: " ✓"; }
tbody tr:nth-child(even) { background: var(--stripe); }
tbody tr:hover, tbody tr:focus-within { background: var(--selected); }
.store-link { display: block; color: var(--brand); font-weight: 650; text-decoration: none; }
.store-link:hover { text-decoration: underline; }
.empty { height: auto; padding: 18px 12px; color: var(--muted); }
.pagination { flex-shrink: 0; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--wash); font-size: 13px; }
.pagination div { display: flex; gap: 8px; }

.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  background: #eaf0f5;
  color: #344d60;
  font-size: 12px;
  font-weight: 650;
}
.status-received { background: #e3f0fc; color: #174772; }
.status-rejected { background: #fce8e7; color: #852a2a; }
.status-accepted { background: #e2f1e9; color: #24583d; }

.back-link { display: inline-block; margin-bottom: 13px; }
.store-card, .login-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.store-card { max-width: 900px; overflow: hidden; box-shadow: 0 4px 18px #001e3310; }
.store-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  background: var(--brand);
  color: #fff;
}
.store-card-header p { margin: 0 0 3px; color: #e4eff8; font-size: 13px; }
.store-card-header h1 { margin: 0; overflow-wrap: anywhere; }
.store-card-body { padding: 18px 22px; }
.store-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.store-card-actions h2 { margin: 0; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0; }
.detail-grid dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.instructions { grid-column: 1 / -1; }
.photo-section { border-top: 1px solid var(--line); }
.upload-link-button { margin-top: 8px; }
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.photo-gallery a { display: grid; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 7px; overflow-wrap: anywhere; }
.photo-gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; background: var(--wash); }
.review-notice { margin: 0; padding: 10px 22px; background: #e2f1e9; color: #24583d; }
.review-notice.error { background: #fce8e7; color: #852a2a; }
.review-form { display: grid; gap: 8px; }
.review-form label { font-weight: 650; }
.review-form textarea { width: 100%; padding: 8px; border: 1px solid var(--field-line); border-radius: 7px; font: inherit; color: inherit; resize: vertical; }
.review-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.button-danger { color: #852a2a; border-color: #d9a8a8; }
.button-danger:hover { background: #fce8e7; }
.review-history { list-style: none; margin: 0; padding: 0; }
.review-history li + li { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.review-history .status { margin-right: 6px; }
.review-history p { margin: 6px 0 0; overflow-wrap: anywhere; }
.login-card { max-width: 400px; margin: 20px auto 0; padding: 20px; }
.login-card form { display: grid; gap: 12px; margin-top: 16px; }
.login-card label, dt { font-size: 12px; font-weight: 650; }
.login-card .button { justify-self: start; }
.form-error, .errorlist { color: #852a2a; }

@media (max-width: 800px) {
  .header-tools { grid-column: 1 / -1; }
  .header-tools:not(:has(form)) { display: none; }
  .directory, .directory:has(> .filters:not([open])) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: auto;
  }
  .filters { border-right: 0; border-bottom: 1px solid var(--line); }
  .filters:not([open]) summary { writing-mode: horizontal-tb; min-height: 0; padding: 13px 14px; }
  .table-scroll { flex-basis: auto; max-height: 60vh; }
}

@media (max-width: 480px) {
  .detail-grid { grid-template-columns: 1fr; }
  .store-card-header { flex-wrap: wrap; }
}
