.admin-header { max-width: 1240px; }
.header-actions { display: flex; align-items: center; gap: 18px; }
.signed-user { color: var(--muted); font-size: 14px; }
.quiet-button { padding: 0; border: 0; background: none; color: var(--accent); font-weight: 700; cursor: pointer; }

.login-shell { width: min(100% - 32px, 460px); margin: 70px auto; }
.login-card { padding: clamp(28px, 6vw, 44px); background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0; font-size: 38px; letter-spacing: -.035em; }
.form-intro { margin: 10px 0 28px; color: var(--muted); }
.role-notice { display: grid; gap: 5px; margin: 18px 0 24px; padding: 15px 16px; color: #6f1020; background: var(--danger-bg); border-left: 4px solid var(--accent); border-radius: 8px; font-size: 14px; line-height: 1.45; }
.role-notice span { color: #5e6871; }
.role-switch-link { display: grid; gap: 3px; margin-top: 24px; padding: 15px 16px; color: var(--ink); background: var(--soft); border: 1px solid var(--line); border-radius: 9px; text-decoration: none; font-size: 14px; }
.role-switch-link span { color: var(--muted); font-size: 12px; }
.role-switch-link:hover { color: var(--accent); border-color: var(--accent); }

.admin-shell { width: min(100% - 40px, 1180px); margin: 20px auto 64px; }
.admin-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 5px; background: #e7eaec; border-radius: 11px; }
.tab-button { min-width: 130px; min-height: 44px; padding: 8px 18px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 750; cursor: pointer; }
.tab-button.active { color: var(--ink); background: var(--white); box-shadow: 0 1px 5px rgba(0,0,0,.08); }
.admin-panel { margin-top: 18px; padding: clamp(22px, 4vw, 38px); background: var(--white); border: 1px solid var(--line); border-radius: 15px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 28px; }
.panel-heading h1 { margin: 0; font-size: clamp(30px, 4vw, 42px); letter-spacing: -.035em; }
.cycle-status { margin: -8px 0 28px; padding: 14px 16px; color: #17623a; background: #eff9f3; border-left: 4px solid #238354; border-radius: 8px; font-size: 14px; font-weight: 680; line-height: 1.45; }

label { display: grid; gap: 7px; color: #3f4b55; font-size: 14px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); background: var(--white); border: 1px solid #bfc7cd; border-radius: 8px; outline: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181,18,43,.12); }
button:disabled { opacity: .55; cursor: not-allowed; }

.primary-button, .secondary-button { min-height: 44px; padding: 10px 17px; border-radius: 8px; font-weight: 780; cursor: pointer; }
.primary-button { color: var(--white); background: var(--accent); border: 1px solid var(--accent); }
.primary-button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.secondary-button { color: var(--ink); background: var(--white); border: 1px solid #bfc7cd; }
.secondary-button:hover { color: var(--accent); border-color: var(--accent); }
.close-button { width: 42px; height: 42px; flex: 0 0 auto; padding: 0; border: 0; border-radius: 8px; background: var(--soft); color: var(--muted); font-size: 26px; cursor: pointer; }

.stack-form { display: grid; gap: 20px; }
.form-grid { display: grid; gap: 18px; align-items: end; }
.three-columns { grid-template-columns: repeat(3, 1fr); }
.two-columns { grid-template-columns: repeat(2, 1fr); }
.swap-grid { grid-template-columns: 1fr 1fr 1fr auto; }
.full-column { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.form-actions.end { justify-content: flex-end; }
.form-error { min-height: 20px; margin: -7px 0; color: var(--accent); font-size: 14px; font-weight: 650; }
.section-help, .muted { color: var(--muted); font-size: 14px; }
.permission-readonly { padding: 12px 14px; background: #f3f5f6; border-left: 3px solid var(--accent); border-radius: 6px; }

.tool-card, .settings-card { margin: 0 0 28px; padding: 24px; background: #f8f9fa; border: 1px solid var(--line); border-radius: 12px; }
.compact-tool { padding-bottom: 20px; }
.tool-card-heading, .modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.tool-card-heading h2, .modal-heading h2 { margin: 0; font-size: 23px; }
.tool-card-heading p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.notice { margin: 22px 0 10px; padding: 13px 15px; color: var(--success); background: #eaf7f0; border-radius: 8px; font-size: 14px; font-weight: 700; }
.notice.warning { color: var(--warning-text); background: var(--warning-bg); }
.compact-list { max-height: 330px; overflow: auto; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.compact-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 16px; align-items: center; min-height: 48px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.compact-row select { min-height: 38px; padding: 6px 10px; }
.cycle-order-box { display: grid; gap: 12px; padding: 16px; background: var(--white); border: 1px solid var(--line); border-radius: 9px; }
.cycle-order-box p { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.cycle-order-list { display: grid; gap: 7px; }
.cycle-order-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; min-height: 42px; padding: 5px 8px; background: var(--soft); border-radius: 7px; }
.cycle-order-actions { display: flex; gap: 5px; }
.compact-row:last-child { border-bottom: 0; }
.conflict-text { color: var(--accent); font-size: 12px; font-weight: 750; }
.tile-swap-bar { display: grid; grid-template-columns: minmax(260px, 1.4fr) minmax(220px, 1fr) auto; gap: 16px; align-items: end; }
.selected-tiles-summary { min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 9px 12px; background: var(--white); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; }
.selected-tiles-summary span:nth-child(2) { color: var(--accent); font-size: 19px; }

.list-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin: 34px 0 10px; }
.list-heading h2 { margin: 0; font-size: 22px; }
.admin-list { border-top: 1px solid var(--line); }
.admin-month-list { display: grid; gap: 34px; }
.admin-month-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 16px; }
.admin-duty-tile { position: relative; outline: none; }
.admin-duty-tile:hover { border-color: #c2c9ce; }
.admin-duty-tile:focus-visible { box-shadow: 0 0 0 3px rgba(181,18,43,.18); }
.admin-duty-tile.selected { border-color: var(--accent); background: var(--danger-bg); }
.admin-duty-tile.cancelled { cursor: default; background: #fff8f8; border-color: #d9a7af; border-style: dashed; }
.selection-order { position: absolute; top: 9px; right: 9px; width: 25px; height: 25px; display: grid; place-items: center; color: var(--white); background: var(--accent); border-radius: 50%; font-size: 12px; font-weight: 850; }
.tile-footer { min-height: 30px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.tile-footer .small-button { min-height: 32px; padding: 5px 9px; }
.tile-footer .small-button.is-selected { color: var(--white); background: var(--accent); border-color: var(--accent); }
.small-button.cancel-duty-button { width: 100%; color: var(--accent); border-color: #d9a7af; background: var(--danger-bg); }
.tile-footer .cancel-duty-button { flex: 1 0 100%; }
.cancelled-original { margin: -5px 0 0; color: var(--muted); font-size: 12px; }
.duty-row { display: grid; grid-template-columns: 1.2fr 1fr auto auto; gap: 18px; align-items: center; min-height: 76px; border-bottom: 1px solid var(--line); }
.duty-date { color: var(--muted); font-size: 14px; }
.duty-name { font-weight: 780; }
.small-button { min-height: 38px; padding: 7px 12px; border: 1px solid #c8cfd4; border-radius: 7px; background: var(--white); color: var(--ink); font-size: 13px; font-weight: 720; cursor: pointer; }
.small-button:hover { border-color: var(--accent); color: var(--accent); }
.empty-admin { padding: 28px; color: var(--muted); text-align: center; border: 1px dashed #c6cdd2; border-radius: 10px; }

.inline-form { display: flex; align-items: end; gap: 12px; max-width: 620px; margin-bottom: 14px; }
.inline-form label { flex: 1; }
.employee-create-form { max-width: none; }
.employee-list { margin-top: 24px; border-top: 1px solid var(--line); }
.employee-row { display: grid; grid-template-columns: 50px minmax(160px, 1fr) 130px auto; gap: 16px; align-items: center; min-height: 72px; border-bottom: 1px solid var(--line); }
.rotation-number { width: 34px; height: 34px; display: grid; place-items: center; background: var(--soft); border-radius: 7px; font-weight: 800; }
.employee-name { font-weight: 750; }
.employee-name small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.status-active { color: var(--success); font-size: 13px; font-weight: 750; }
.status-inactive { color: var(--muted); font-size: 13px; font-weight: 750; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.arrow-button { width: 38px; min-height: 38px; padding: 0; }

.settings-card { max-width: 650px; }
.permission-box { display: grid; gap: 16px; padding: 16px; background: var(--soft); border: 1px solid var(--line); border-radius: 9px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 10px; color: #3f4b55; font-size: 14px; font-weight: 700; }
.check-row { display: flex; flex-wrap: wrap; gap: 8px; }
.check-row label { display: flex; align-items: center; gap: 7px; min-height: 40px; padding: 8px 11px; background: var(--white); border: 1px solid var(--line); border-radius: 7px; }
.check-label { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.check-label input, .check-row input { width: 18px; min-height: 18px; accent-color: var(--accent); }

.history-list { border-top: 1px solid var(--line); }
.history-row { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(280px, 1.7fr) minmax(150px, 1fr); gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.history-when, .history-meta { color: var(--muted); font-size: 13px; }
.history-change { font-size: 15px; }
.history-note { margin-top: 5px; color: var(--muted); font-size: 13px; }

.modal { width: min(100% - 28px, 560px); padding: 26px; border: 0; border-radius: 14px; box-shadow: 0 22px 70px rgba(0,0,0,.22); }
.modal::backdrop { background: rgba(23,32,42,.52); }
.modal .eyebrow { margin-bottom: 5px; }
.toast { position: fixed; z-index: 20; top: 18px; left: 50%; transform: translateX(-50%); width: min(calc(100% - 28px), 560px); padding: 13px 18px; color: var(--white); background: var(--ink); border-radius: 9px; box-shadow: var(--shadow); text-align: center; font-size: 14px; font-weight: 700; }
.toast.error { background: var(--accent-dark); }

@media (max-width: 850px) {
  .three-columns, .swap-grid { grid-template-columns: 1fr 1fr; }
  .swap-grid .form-actions { grid-column: 1 / -1; }
  .duty-row { grid-template-columns: 1fr auto; padding: 14px 0; gap: 7px 12px; }
  .duty-date { grid-column: 1 / -1; }
  .history-row { grid-template-columns: 1fr 2fr; }
  .history-meta { grid-column: 2; }
  .tile-swap-bar { grid-template-columns: 1fr 1fr; }
  .tile-swap-bar .selected-tiles-summary { grid-column: 1 / -1; }
  .admin-month-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .admin-header { height: auto; min-height: 68px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
  .header-actions { gap: 12px; }
  .signed-user { display: none; }
  .admin-shell { width: min(100% - 20px, 1180px); margin-top: 10px; }
  .admin-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 -1px; overflow: visible; }
  .tab-button { width: 100%; min-width: 0; }
  .admin-panel { padding: 22px 16px; }
  .panel-heading { align-items: end; }
  .three-columns, .two-columns, .swap-grid { grid-template-columns: 1fr; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .employee-row { grid-template-columns: 42px 1fr auto; gap: 10px; padding: 13px 0; }
  .employee-row .employee-status { grid-column: 2; }
  .row-actions { grid-column: 3; grid-row: 1 / 3; flex-wrap: wrap; width: 82px; }
  .history-row { grid-template-columns: 1fr; gap: 6px; }
  .history-meta { grid-column: 1; }
  .modal { padding: 22px 18px; }
  .tile-swap-bar { grid-template-columns: 1fr; }
  .tile-swap-bar .selected-tiles-summary { grid-column: auto; }
  .admin-month-tiles { grid-template-columns: 1fr; }
}
