.admin-shell {
  display: grid;
  gap: 18px;
}

@media (min-width: 1101px) {
  .admin-shell {
    width: min(1600px, calc(100% - 40px));
    max-width: 1600px;
  }

  .admin-panel,
  .admin-panel .table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

.admin-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 6px;
  padding: 10px 16px;
  background: #e7edf1;
  color: #24313d;
  font-weight: 900;
  text-decoration: none;
}

.admin-message {
  border: 1px solid #d9e1e7;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f8fbfc;
  color: #24313d;
  font-weight: 800;
}

.admin-message.error {
  border-color: #e0b868;
  background: #fff8e8;
  color: #8a4f20;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.admin-stats div {
  border: 1px solid #d8e2e6;
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.admin-stats span {
  display: block;
  color: #607080;
  font-size: 13px;
  font-weight: 900;
}

.admin-stats strong {
  display: block;
  margin-top: 6px;
  color: #296f77;
  font-size: 30px;
  line-height: 1;
}

.admin-panel {
  padding: 22px;
}

.valuation-watch-panel .valuation-watch-table {
  min-width: 1480px;
}

.valuation-watch-panel .status-pill.active {
  color: #0b6b53;
}

.admin-form {
  display: grid;
  grid-template-columns: 1fr 1fr 160px 120px;
  gap: 12px;
  align-items: end;
}

select {
  min-height: 46px;
  border: 1px solid #c9d2da;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfd;
  font: inherit;
}

.member-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 340px;
}

.member-tools button,
.member-tools select,
.member-tools input {
  min-height: 36px;
  font-size: 13px;
}

.member-tools input {
  width: 110px;
}

.line-plan-tools {
  display: grid;
  grid-template-columns: 105px 145px;
  gap: 6px;
  min-width: 260px;
}

.line-member-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.line-member-filters button {
  min-height: 38px;
  border: 1px solid #c9d2da;
  border-radius: 999px;
  padding: 7px 14px;
  background: #f4f7f9;
  color: #43515e;
  font-weight: 800;
}

.line-member-filters button.active {
  border-color: #296f77;
  background: #296f77;
  color: #fff;
}

.compact-date,
.compact-time {
  width: 82px;
  min-width: 82px;
  white-space: nowrap;
  font-size: 12px;
}

.line-plan-tools select,
.line-plan-tools input,
.line-plan-tools button {
  min-height: 36px;
  font-size: 13px;
}

.permanent-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.permanent-option input {
  width: auto;
  min-height: auto;
}

.mini-button {
  padding: 7px 10px;
}

.mini-button.is-saving {
  background: #607080;
  cursor: wait;
  opacity: 0.85;
}

.mini-button.is-saved {
  background: #1f7a52;
}

.danger-button {
  background: #b23a48;
}

.muted-text {
  color: #607080;
  font-size: 12px;
  font-weight: 800;
}

.line-watchlist-box {
  margin-top: 18px;
  border: 1px solid #d8e2e6;
  border-radius: 8px;
  padding: 16px;
  background: #f8fbfc;
}

.line-watchlist-box h3 {
  margin: 0 0 10px;
  color: #24313d;
}

.line-watchlist-box ul {
  margin: 0;
  padding-left: 20px;
  color: #24313d;
  font-weight: 800;
}

.line-watchlist-box li + li {
  margin-top: 6px;
}

.watermark-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  align-items: start;
}

.watermark-form textarea {
  min-height: 120px;
}

.status-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e7edf1;
  color: #24313d;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.active {
  background: #e6f5ee;
  color: #1f6b45;
}

.status-pill.online {
  background: #fff2c7;
  color: #7a4f00;
}

.line-member-mobile-details {
  display: none;
}

.admin-alert-form {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 150px 150px 210px;
  align-items: end;
  gap: 12px;
}

.admin-alert-form label {
  min-width: 0;
}

.admin-alert-form :is(input, textarea) {
  width: 100%;
}

.admin-alert-form textarea {
  min-height: 94px;
  resize: vertical;
}

.admin-alert-message-field {
  grid-row: span 2;
}

.admin-alert-form-actions {
  grid-column: 2 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.admin-alert-form-actions button {
  min-width: 120px;
}

.admin-alert-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.admin-alert-empty {
  margin: 0;
  border: 1px dashed #cbd7dc;
  border-radius: 10px;
  padding: 20px;
  color: #677986;
  text-align: center;
}

.admin-alert-card {
  border: 1px solid #d5e0e4;
  border-left: 5px solid #8a969d;
  border-radius: 10px;
  padding: 13px 14px;
  background: #fff;
}

.admin-alert-card.is-published {
  border-left-color: #27766f;
}

.admin-alert-card-head,
.admin-alert-card-meta,
.admin-alert-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.admin-alert-card-head {
  justify-content: space-between;
}

.admin-alert-card-head > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.admin-alert-card-head time,
.admin-alert-card-meta {
  color: #667783;
  font-size: 12px;
  font-weight: 800;
}

.admin-alert-card > p {
  margin: 11px 0;
  color: #253541;
  font-weight: 800;
  line-height: 1.55;
  white-space: pre-wrap;
}

.admin-alert-card-actions {
  justify-content: flex-end;
  margin-top: 11px;
}

.admin-alert-card-actions button {
  min-height: 38px;
}

@media (max-width: 780px) {
  .admin-hero,
  .admin-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-stats,
  .admin-form,
  .admin-alert-form,
  .watermark-form {
    grid-template-columns: 1fr;
  }

  .admin-alert-message-field,
  .admin-alert-form-actions {
    grid-column: auto;
    grid-row: auto;
  }

  .admin-alert-form-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-alert-form-actions button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 400px) {
  .admin-shell {
    gap: 10px;
  }

  .admin-panel,
  .line-watchlist-box {
    padding: 12px;
  }

  .admin-stats {
    gap: 7px;
  }

  .admin-stats div {
    padding: 10px;
  }

  .admin-stats strong {
    font-size: 24px;
  }

  .member-tools {
    min-width: 0;
  }
}

/* Admin-only responsive layouts. These breakpoints intentionally live in the
   admin stylesheet and do not reuse the public stock-card layout. */
@media (max-width: 600px) and (orientation: portrait) {
  .valuation-watch-panel .valuation-watch-table {
    min-width: 0;
  }

  .admin-shell {
    width: 100%;
    max-width: none;
    gap: 12px;
    margin: 0;
    padding: 16px 12px 28px;
  }

  .admin-hero {
    gap: 12px;
  }

  .admin-hero .brand-title {
    margin-bottom: 0;
    font-size: clamp(30px, 10vw, 44px);
  }

  .admin-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .admin-actions > * {
    width: 100%;
    min-height: 46px;
  }

  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .admin-stats div {
    min-width: 0;
    min-height: 92px;
    padding: 12px;
  }

  .admin-stats span {
    font-size: 13px;
    line-height: 1.25;
  }

  .admin-stats strong {
    font-size: 28px;
  }

  .admin-panel {
    min-width: 0;
    padding: 14px 12px;
  }

  .admin-panel .result-actions {
    align-items: flex-start;
  }

  .admin-panel .section-title {
    font-size: 21px;
  }

  .admin-panel .section-note {
    font-size: 13px;
    line-height: 1.45;
  }

  .admin-form,
  .watermark-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-form button,
  .watermark-form button {
    min-height: 46px;
  }

  .line-member-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .line-member-filters button {
    min-width: 0;
    min-height: 44px;
    padding: 7px 5px;
    font-size: 14px;
    white-space: nowrap;
  }

  .admin-panel .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .admin-panel table,
  .admin-panel tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .admin-panel thead {
    display: none;
  }

  .admin-panel tbody tr {
    display: grid;
    width: 100%;
    min-width: 0;
    gap: 0;
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid #d6e0e5;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(23, 49, 62, 0.06);
  }

  .admin-panel tbody td {
    display: grid;
    grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #edf1f3;
    font-size: 14px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .admin-panel tbody td:last-child {
    border-bottom: 0;
  }

  .admin-panel tbody td::before {
    content: attr(data-label);
    color: #617381;
    font-size: 12px;
    font-weight: 900;
    line-height: 1.4;
  }

  .admin-panel tbody td[colspan] {
    display: block;
    padding: 18px 12px;
    text-align: center;
  }

  .admin-panel tbody td[colspan]::before {
    content: none;
  }

  .compact-date,
  .compact-time {
    width: 100%;
    min-width: 0;
    font-size: 14px;
  }

  .member-tools,
  .line-plan-tools {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .member-tools input,
  .member-tools select,
  .member-tools button,
  .line-plan-tools input,
  .line-plan-tools select,
  .line-plan-tools button {
    width: 100%;
    min-width: 0;
    min-height: 42px;
  }

  .line-plan-tools .permanent-option {
    min-height: 42px;
  }

  .line-plan-tools .permanent-option input {
    width: 20px;
    min-height: 20px;
  }

  .watermark-form textarea {
    width: 100%;
  }
}

/* Phone landscape keeps a compact, scrollable table instead of the portrait
   card stack. Controls stay inside the viewport and retain touch-sized targets. */
@media (max-width: 932px) and (max-height: 600px) and (orientation: landscape) {
  .admin-shell {
    width: 100%;
    max-width: none;
    gap: 10px;
    margin: 0;
    padding: 10px 12px 20px;
  }

  .admin-hero {
    align-items: center;
    flex-direction: row;
    gap: 12px;
  }

  .admin-hero .brand-title {
    margin: 0;
    font-size: 30px;
  }

  .admin-actions {
    flex-direction: row;
    margin-left: auto;
  }

  .admin-actions > * {
    min-height: 42px;
  }

  .admin-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  .admin-stats div {
    min-height: 76px;
    padding: 10px;
  }

  .admin-stats strong {
    font-size: 24px;
  }

  .admin-panel {
    padding: 14px;
  }

  .admin-form {
    grid-template-columns: 1fr 1fr 130px 100px;
  }

  .admin-alert-form {
    grid-template-columns: minmax(220px, 1.4fr) 92px 122px minmax(170px, 1fr);
    gap: 8px;
  }

  .admin-panel .table-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .admin-panel table {
    width: max-content;
    min-width: 980px;
  }

  .admin-panel .line-member-filters + .table-wrap table {
    min-width: 1240px;
  }

  .admin-panel th,
  .admin-panel td {
    padding: 9px 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  .member-tools button,
  .member-tools select,
  .member-tools input,
  .line-plan-tools button,
  .line-plan-tools select,
  .line-plan-tools input {
    min-height: 40px;
  }
}

/* Tablet keeps the full administration tables, with local horizontal scrolling
   rather than clipping the page itself. */
@media (min-width: 601px) and (max-width: 1100px) and (min-height: 601px) {
  .admin-shell {
    width: 100%;
    max-width: none;
    padding-inline: 18px;
  }

  .admin-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-panel .table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-panel table {
    min-width: 1050px;
  }

  .admin-panel .line-member-filters + .table-wrap table {
    min-width: 1280px;
  }

  .admin-panel th,
  .admin-panel td {
    white-space: nowrap;
  }
}

/* Phone landscape LINE members: five directly usable columns. Secondary date
   fields move into an inline details disclosure instead of consuming width. */
@media (max-width: 932px) and (max-height: 600px) and (orientation: landscape) {
  .admin-shell > *,
  .admin-panel {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .admin-panel .table-wrap:has(.line-members-table) {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden;
  }

  .admin-panel .line-members-table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed;
  }

  .line-members-table :is(th, td):nth-child(3),
  .line-members-table :is(th, td):nth-child(4),
  .line-members-table :is(th, td):nth-child(6),
  .line-members-table :is(th, td):nth-child(8),
  .line-members-table :is(th, td):nth-child(9) {
    display: none;
  }

  .line-members-table :is(th, td):nth-child(1) {
    width: 20%;
  }

  .line-members-table :is(th, td):nth-child(2) {
    width: 14%;
  }

  .line-members-table :is(th, td):nth-child(5) {
    width: 13%;
    text-align: center;
  }

  .line-members-table :is(th, td):nth-child(7) {
    width: 40%;
  }

  .line-members-table :is(th, td):nth-child(10) {
    width: 13%;
    text-align: center;
  }

  .line-members-table :is(th, td) {
    box-sizing: border-box;
    min-width: 0;
    padding: 8px 7px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .line-members-table .line-plan-tools {
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(84px, 0.9fr) minmax(116px, 1.25fr);
    gap: 5px;
  }

  .line-members-table .line-plan-tools :is(select, input, button) {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 5px 6px;
    font-size: 12px;
  }

  .line-members-table .permanent-option {
    min-width: 0;
    min-height: 38px;
    font-size: 12px;
  }

  .line-members-table .permanent-option input {
    width: 18px;
    min-height: 18px;
  }

  .line-members-table [data-action="line-watchlist"] {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 6px 4px;
    font-size: 12px;
    white-space: normal;
  }

  .line-member-mobile-details {
    display: block;
    margin-top: 5px;
  }

  .line-member-mobile-details summary {
    color: #296f77;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
  }

  .line-member-mobile-details dl {
    position: absolute;
    z-index: 20;
    width: 210px;
    margin: 5px 0 0;
    border: 1px solid #cad7dc;
    border-radius: 8px;
    padding: 8px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(20, 45, 57, 0.2);
  }

  .line-member-mobile-details dl div {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 6px;
  }

  .line-member-mobile-details dl div + div {
    margin-top: 5px;
  }

  .line-member-mobile-details :is(dt, dd) {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
    white-space: nowrap;
  }

  .line-member-mobile-details dt {
    color: #697985;
    font-weight: 900;
  }
}
