.apo-layout {
  display: grid;
  grid-template-columns: minmax(0, 36fr) minmax(0, 64fr);
  gap: 10px;
  padding: 12px 10px;
  font-size: 16px;
  color: #222;
}
.apo-left,
.apo-right {
  min-width: 0;
}
.apo-search {
  background: #cfe8f5;
  border: 1px solid #38aeec;
  border-radius: 12px;
  padding: 12px;
}
.apo-search-fields {
  display: grid;
  grid-template-columns: minmax(65px, 1fr) minmax(80px, 1fr) minmax(
      90px,
      1.3fr
    ) auto;
  gap: 8px;
  align-items: end;
}
.apo-layout label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.apo-search label {
  font-size: 12px;
  font-weight: 600;
}
.apo-layout input,
.apo-layout select,
.apo-layout textarea {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  font: inherit;
  border: 1px solid #aaa;
  border-radius: 7px;
  background: white;
  padding: 6px;
}
.apo-layout button {
  cursor: pointer;
  font: inherit;
}
.apo-layout button:disabled {
  opacity: 0.4;
  cursor: default;
}
.apo-blue {
  background: #0876bc;
  color: white;
  border: 0;
  border-radius: 7px;
  padding: 6px 18px;
}
.apo-lists {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}
.apo-lists button,
.apo-image-button {
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 8px;
}
.apo-lists button {
  width: calc((100% - 28px) / 5);
  min-width: 58px;
}
.apo-lists button[aria-pressed="true"] {
  outline: 3px solid white;
  outline-offset: 2px;
}
.apo-layout img {
  object-fit: contain;
  height: auto;
  max-width: 100%;
}
.apo-lists img,
.apo-image-button img {
  display: block;
  width: 100%;
  height: auto;
}
.apo-paging {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 12px 4px;
}
.apo-count {
  font-size: 22px;
  min-width: 90px;
}
.apo-paging button {
  border: 1px solid #38aeec;
  background: #cfe8f5;
  color: #0876bc;
  width: 33px;
  height: 33px;
  border-radius: 50%;
  padding: 0;
}
.apo-card {
  width: 100%;
  display: block;
  text-align: left;
  background: #fff;
  border: 1px solid #92c928;
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}
.apo-card.is-selected {
  background: #fbfef3;
}
.apo-card.is-highlighted {
  background: #fff5c7;
}
.apo-card-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}
.apo-card .apo-name {
  font-size: 17px;
}
.apo-card small {
  flex-basis: 100%;
  font-size: 12px;
  margin-left: 0;
  text-align: left;
}
.apo-grade {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  vertical-align: middle;
}
.apo-layout .apo-gender {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  object-fit: contain;
}
.apo-detail {
  border: 1px solid #92c928;
  border-radius: 12px;
  background: #fff;
  padding: 16px;
  min-height: 750px;
  overflow-wrap: anywhere;
}
.apo-detail p {
  margin: 10px 0;
}
.apo-student-heading {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.apo-student-heading h2 {
  font-size: clamp(18px, 1.5vw, 26px);
  font-weight: 500;
  margin: 0;
}
.apo-student-heading h2 span {
  font-size: 0.85em;
}
.apo-student-heading .apo-image-button {
  width: 30px;
  margin-left: auto;
}
.apo-phones {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 18px;
}
.apo-phones > div {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.apo-phones img {
  width: 34px;
  height: 34px;
}
.apo-phones a {
  color: inherit;
  text-decoration: none;
  font-size: clamp(16px, 1.45vw, 24px);
}
.apo-phones a.apo-invalid-phone {
  color: #d52332;
}
.apo-information {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 18px;
}
.apo-info-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  min-width: 0;
  border: 1px solid #dde7d1;
  border-radius: 8px;
  overflow: hidden;
}
.apo-info-row dt {
  margin: 0;
  padding: 10px 6px;
  background: #f4f8ed;
  border-right: 1px solid #dde7d1;
  color: #45513c;
  font-size: 12px;
  line-height: 1.5;
}
.apo-info-row dd {
  margin: 0;
  padding: 9px 12px;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
  background: #fff;
}
.apo-info-row dd:empty::before {
  content: "\2014";
  color: #9aa190;
}
.apo-wide {
  grid-column: 1/-1;
}
.apo-call-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}
.apo-call-groups > div {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  flex: 1 1 0;
  max-width: 360px;
  min-width: 0;
}
.apo-call-groups button {
  width: 100%;
}
.apo-history {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}
.apo-history-card {
  padding: 12px;
  border: 1px solid;
  border-radius: 12px;
}
.apo-history-card.absent {
  border-color: #8ec31f;
}
.apo-history-card.wrong {
  border-color: #f19ec2;
}
.apo-history-card.connected {
  border-color: #7dcef4;
}
.apo-history-card header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.apo-outcome-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.apo-badge {
  padding: 3px 9px;
  color: #fff;
  border-radius: 6px;
}
.outcome-0 {
  background: #da64a0;
}
.outcome-1 {
  background: #16b4e5;
}
.outcome-2 {
  background: #900894;
}
.outcome-3 {
  background: #0876bc;
}
.apo-outcomes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
}
.apo-outcomes button {
  width: 120px;
  max-width: calc(50% - 5px);
}
.apo-schedule {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}
.apo-schedule label:first-child {
  flex: 0 1 180px;
}
.apo-schedule label {
  flex: 0 1 65px;
}
.apo-schedule textarea {
  flex-basis: 100%;
  min-height: 90px;
}
.apo-comment {
  white-space: pre-wrap;
}
.apo-saved-date.strong {
  font-weight: bold;
}
.apo-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.apo-edit textarea {
  min-height: 80px;
}
.apo-message:not(:empty) {
  padding: 10px;
  background: #fff6da;
  border-radius: 8px;
  margin-bottom: 8px;
}
.apo-message button {
  margin-left: 10px;
}
.apo-toast {
  position: fixed;
  right: 16px;
  top: 90px;
  z-index: 10000;
  max-width: calc(100vw - 32px);
  width: 350px;
  background: #fff8d7;
  border: 1px solid #e5be4e;
  box-shadow: 0 3px 15px #0002;
  border-radius: 12px;
  padding: 12px;
}
.apo-toast + .apo-toast {
  top: 230px;
}
.apo-toast button {
  border: 0;
  background: none;
  cursor: pointer;
}
.apo-toast-open {
  display: grid;
  text-align: left;
  gap: 8px;
  padding: 10px;
  font-size: 16px;
}
.apo-toast-close {
  float: right;
  font-size: 23px;
}
.apo-filter-notice {
  font-size: 13px;
}
.apo-notification-detail {
  max-width: 650px;
  margin: 20px auto;
  padding: 16px;
  font-size: 18px;
}
.apo-notification-detail a {
  display: block;
  padding: 12px;
  color: #0876bc;
}
.apo-notification-detail p {
  white-space: pre-wrap;
}
@media (max-width: 1150px) {
  .apo-search-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .apo-phones {
    grid-template-columns: 1fr;
  }
  .apo-detail {
    padding: 12px;
  }
  .apo-card small {
    margin-left: 0;
  }
  .apo-lists {
    gap: 8px;
  }
  .apo-lists button {
    width: calc((100% - 16px) / 3);
  }
}
@media (max-width: 700px) {
  .apo-layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px 5px;
  }
  .apo-detail {
    min-height: 300px;
  }
  .apo-search-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .apo-edit-grid {
    grid-template-columns: 1fr;
  }
  .apo-call-groups > div {
    flex-basis: 100%;
    max-width: 360px;
  }
  .apo-student-heading h2 {
    font-size: 21px;
  }
  .apo-phones a {
    font-size: 21px;
  }
  .apo-information {
    grid-template-columns: 1fr;
  }
  .apo-layout button {
    min-height: 34px;
  }
  .apo-lists button {
    min-height: 0;
  }
  .apo-search-fields button {
    min-height: 38px;
  }
}

.apo-layout .apo-card,
.apo-layout .apo-card:hover:not(:disabled) {
  color: #222;
  border-color: #92c928;
}
.apo-layout .apo-card.is-selected {
  background: #fbfef3;
}
.apo-layout .apo-card.is-highlighted {
  background: #fff5c7;
}

.apo-toast-stack {position:fixed;right:16px;top:90px;z-index:10000;width:350px;max-width:calc(100vw - 32px);max-height:calc(100vh - 110px);overflow-y:auto;display:grid;gap:10px}
.apo-toast-stack .apo-toast {position:static;box-sizing:border-box;max-width:100%;width:100%;}

@media (max-width: 1150px) {
  .apo-information { grid-template-columns: minmax(0, 1fr); }
  .apo-info-row { grid-template-columns: 88px minmax(0, 1fr); }
}

.apo-call-groups .apo-unavailable {
  padding: 0 2px;
  border: 1px solid currentColor;
  border-radius: 7px;
  background: #fff;
  opacity: .5;
  cursor: not-allowed;
  font-size: clamp(9px, 1vw, 16px);
  white-space: nowrap;
}
.apo-call-groups .apo-unavailable-rusu:disabled { color: #8ec31f; }
.apo-call-groups .apo-unavailable-chakukyo:disabled { color: #e94b96; }
.apo-call-groups .apo-unavailable-telgo:disabled { color: #e485ad; }
.apo-call-groups .apo-unavailable-tuuden:disabled { color: #40b5e8; }

.apo-schedule-compact {
  gap: 10px 8px;
  align-items: center;
}
.apo-schedule-compact label,
.apo-schedule-compact label:first-child {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: #666;
}
.apo-schedule-compact input[type="date"] {
  width: 112px;
  min-height: 34px;
  padding: 4px;
}
.apo-schedule-compact select {
  width: 48px;
  min-height: 34px;
  padding: 3px;
}
.apo-schedule-compact input,
.apo-schedule-compact select,
.apo-schedule-compact textarea {
  border-color: #d5dfb3;
}
.apo-schedule-compact textarea {
  min-height: 90px;
  padding: 12px;
  border-radius: 12px;
}
.apo-schedule-compact textarea::placeholder { color: #aaa; }
.apo-schedule-compact button[type="submit"] {
  margin-left: auto;
  padding: 7px 16px;
  color: #3685a5;
  background: #fff;
  border: 1px solid #3685a5;
  border-radius: 6px;
  font-size: 14px;
}

.apo-layout .apo-call-groups button {
  min-height: 0;
  min-width: 0;
  box-sizing: border-box;
  aspect-ratio: 185 / 70;
  align-self: center;
  position: relative;
}
.apo-call-groups .apo-unavailable {
  box-sizing: border-box;
  aspect-ratio: 185 / 70;
  line-height: 1;
  border-radius: 6px;
}

.apo-card .sales-card-datetime {
  font-weight: 700;
}

.sales-calendar { background: #fff; border: 1px solid #add4e9; border-radius: 10px; padding: 8px; }
.sales-calendar-heading { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sales-calendar-heading label { flex: 1; flex-direction: row; align-items: center; font-size: 12px; }
.sales-calendar-heading select { width: auto; }
.sales-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.sales-weekday { text-align: center; font-size: 12px; padding: 4px 0; }
.apo-layout .sales-calendar-day { display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-width: 0; min-height: 64px; background: #fff; border: 1px solid #d7e2e8; border-radius: 4px; padding: 3px 2px; text-align: left; font-size: 11px; }
.sales-calendar-day[aria-pressed="true"] { background: #e5f4ff; outline: 2px solid #0876bc; outline-offset: -2px; }
.sales-calendar-day:focus-visible { outline: 2px solid #0876bc; }
.sales-day-number { font-weight: 700; }
.sales-calendar-entry { display: flex; flex-direction: column; border-left: 3px solid hsl(var(--prefecture-hue) 62% 38%); background: hsl(var(--prefecture-hue) 65% 92%); color: hsl(var(--prefecture-hue) 65% 22%); border-radius: 3px; padding: 2px; line-height: 1.35; overflow-wrap: anywhere; }

.apo-schedule .apo-sales-information {
  flex: 0 0 100%;
  box-sizing: border-box;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.apo-sales-information legend { color: #666; font-size: 14px; margin-bottom: 12px; }
.apo-sales-field { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px; align-items: center; margin: 10px 0; }
.apo-sales-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-width: 0; }
.apo-sales-information .apo-sales-options label { display: inline-flex; color: #222; font-size: 16px; gap: 7px; }
.apo-sales-information input[type="checkbox"] { appearance: auto; width: 20px; height: 20px; min-height: 20px; flex: 0 0 20px; margin: 0; accent-color: #0876bc; }
.apo-sales-information input[type="text"] { min-height: 38px; }
.apo-sales-options input[type="text"] { flex: 1 1 160px; width: auto; }
.apo-sales-saved p { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; }
@media (max-width: 700px) { .apo-sales-field { grid-template-columns: minmax(0, 1fr); } }

@media (max-width: 700px) {
  .apo-cards > .apo-right { margin: 8px 0 14px; }
}

.apo-history-card { position: relative; }
.apo-history-card:has(.apo-history-actions) > header { padding-right: 80px; min-height: 36px; }
.apo-history-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; }
.apo-layout .apo-history-actions .apo-image-button { width: 32px; height: 32px; min-height: 0; padding: 0; background: transparent; border: 0; }
.apo-history-actions img { width: 100%; height: 100%; object-fit: contain; }
.apo-history-date { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.apo-history-sales { flex: 0 0 100%; min-width: 0; }
.apo-history-edit [hidden] { display: none; }

.apo-history-edit select[name="outcome"] { width: auto; min-width: 106px; }

.apo-card small { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.apo-card small > span { white-space: nowrap; }

.apo-call-groups .apo-image-button img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.apo-form-line { display: flex; flex: 0 0 100%; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.apo-outcome-form [hidden] { display: none; }
.apo-outcome-form .apo-confirmation-toggle { margin-left: 8px; }
.apo-confirmation-toggle input[type="checkbox"] { appearance: auto; width: 18px; height: 18px; min-height: 18px; margin: 0; }
.apo-refusal-options .apo-image-button { width: 90px; max-width: calc((100% - 16px) / 3); }
.apo-refusal-options button[aria-pressed="true"] { outline: 3px solid #f39a00; outline-offset: 2px; }
.apo-outcomes { gap: 8px; }
.apo-outcomes button { width: 110px; max-width: calc((100% - 16px) / 3); }
.outcome-refused { background: #f39a00; }
.outcome-delete-request { background: #a80061; }
.apo-saved-confirmation.strong { font-weight: 700; }

.apo-save-indicator {
  position: fixed; right: 16px; bottom: 16px; z-index: 100;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: 6px; background: #fff; color: #666;
  box-shadow: 0 1px 5px #0002; font-size: 12px; pointer-events: none;
}
.apo-save-indicator::before { content: ""; width: 10px; height: 10px; border: 2px solid #d7e9f1; border-top-color: #0876bc; border-radius: 50%; animation: apo-saving-spin .8s linear infinite; }
@keyframes apo-saving-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .apo-save-indicator::before { animation: none; } }

.apo-edit-wide { grid-column: 1 / -1; }
.apo-edit-actions { display: flex; align-items: center; gap: 6px; }
.apo-edit-actions .apo-online-toggle { margin-left: auto; display: flex; flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
.apo-online-toggle input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; margin: 0; }
.apo-online-badge { display: inline-block; background: #e8f6fc; color: #0875a6; border: 1px solid #80c8e4; border-radius: 5px; padding: 3px 8px; font-size: 13px; white-space: nowrap; }

.apo-inquiry { margin-bottom: 8px; }
.apo-inquiry dd { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 18px; }
.apo-inquiry-date { white-space: nowrap; }
.apo-inquiry-media { min-width: 0; }
