/* v32 — core workflow + mobile-first completion layer */
:root{
  --hm-app-radius:22px;
  --hm-sheet-radius:26px;
  --hm-touch:44px;
}

/* Allocation is a workflow, not a tiny table-cell form. */
.allocation-panel-row[hidden]{display:none!important}
.allocation-panel-row>td{padding:14px 16px!important;background:rgba(15,23,42,.035)}
.allocation-panel-shell{border:1px solid rgba(15,23,42,.10);border-radius:20px;background:#fff;box-shadow:0 18px 44px rgba(15,23,42,.10);overflow:visible}
.allocation-panel-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;padding:18px 20px 14px;border-bottom:1px solid rgba(15,23,42,.08)}
.allocation-panel-head h3{margin:3px 0 4px;font-size:1.08rem}
.allocation-panel-head p{margin:0;color:var(--muted,#64748b);font-size:.88rem}
.allocation-panel-close{width:40px;height:40px;border:0;border-radius:13px;background:rgba(15,23,42,.06);font-size:1.6rem;line-height:1;cursor:pointer;flex:0 0 auto}
.allocation-panel-form{display:grid;grid-template-columns:minmax(260px,1.35fr) minmax(300px,1.65fr);gap:16px 20px;padding:18px 20px 20px;align-items:start}
.allocation-panel-form label>span:first-child,.allocation-owner-field>span,.allocation-reason-field>span{display:block;font-weight:800;margin-bottom:7px}
.allocation-owner-field select,.allocation-reason-field input{width:100%;min-height:46px}
.allocation-owner-field small{display:block;margin-top:6px;color:var(--muted,#64748b);font-size:.78rem}
.allocation-option-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:9px;grid-column:1/-1}
.allocation-check{display:flex!important;align-items:flex-start;gap:9px;padding:12px;border:1px solid rgba(15,23,42,.10);border-radius:15px;background:rgba(248,250,252,.9);cursor:pointer}
.allocation-check input{margin-top:3px;flex:0 0 auto}
.allocation-check span{display:block;margin:0!important}
.allocation-check b,.allocation-check small{display:block}
.allocation-check small{margin-top:3px;color:var(--muted,#64748b);font-weight:500;line-height:1.6}
.allocation-reason-field{grid-column:1/-1}
.allocation-panel-actions{grid-column:1/-1;display:flex;justify-content:flex-end;gap:10px;padding-top:2px}
.allocation-target-ready{outline:2px solid rgba(37,99,235,.20);outline-offset:-2px}

/* Annual lottery: show the whole-year plan before committing it. */
.annual-lottery-status{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:16px 0}
.annual-lottery-status>div,.annual-season-grid article{border:1px solid rgba(15,23,42,.09);border-radius:18px;background:rgba(248,250,252,.82);padding:14px 16px}
.annual-lottery-status span,.annual-lottery-status small,.annual-season-grid small{display:block;color:var(--muted,#64748b);font-size:.78rem}
.annual-lottery-status b{display:block;font-size:1.35rem;margin:4px 0}
.annual-lottery-status.has-shortage>div:nth-child(2){border-color:rgba(217,119,6,.28);background:rgba(255,251,235,.85)}
.annual-season-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:14px 0}
.annual-season-grid article header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding-bottom:9px;margin-bottom:9px;border-bottom:1px solid rgba(15,23,42,.08)}
.annual-season-grid article header span{font-size:.76rem;color:var(--muted,#64748b)}
.annual-season-grid article>div{display:flex;justify-content:space-between;gap:8px;align-items:center;margin-top:6px}
.annual-season-grid strong{font-size:1rem}
.annual-plan-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding-top:12px}
.annual-plan-list>div{display:flex;align-items:center;justify-content:space-between;gap:12px;border:1px solid rgba(15,23,42,.08);border-radius:13px;padding:10px 12px;background:#fff}
.annual-plan-list span{color:var(--muted,#64748b);font-size:.8rem;text-align:left}
.annual-shortage-box{margin-top:14px;border:1px solid rgba(217,119,6,.25);background:rgba(255,251,235,.9);border-radius:18px;padding:14px 16px}
.annual-shortage-box h3{margin:0 0 4px;font-size:1rem}.annual-shortage-box p{margin:0 0 10px;color:#92400e;font-size:.84rem}
.annual-shortage-list{display:grid;gap:7px}.annual-shortage-list>div{display:grid;grid-template-columns:minmax(140px,1fr) minmax(130px,1fr) 2fr;gap:10px;align-items:center;padding:9px 10px;border-radius:12px;background:rgba(255,255,255,.78)}
.annual-shortage-list small{color:#92400e}
.special-quota-policy-note{margin:0 0 14px;padding:11px 13px;border-radius:13px;background:rgba(37,99,235,.06);border:1px solid rgba(37,99,235,.12);font-size:.84rem}

/* App-like interaction defaults shared by owner and management mobile views. */
@media (max-width:900px){
  html{scroll-padding-bottom:92px}
  body{overscroll-behavior-y:contain}
  body.allocation-sheet-open{overflow:hidden}
  .page-content{padding-bottom:calc(96px + env(safe-area-inset-bottom,0px))!important}
  .page-heading{gap:12px!important;margin-bottom:14px!important}
  .page-heading h1{font-size:1.35rem!important;line-height:1.45!important}
  .page-heading p{font-size:.84rem!important;line-height:1.8!important}
  .heading-actions{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;gap:8px!important}
  .heading-actions>.button,.heading-actions>button{width:100%;min-height:var(--hm-touch);justify-content:center}
  .panel{border-radius:var(--hm-app-radius)!important}
  .panel-head{gap:10px!important;align-items:flex-start!important}
  .panel-head h2{font-size:1.05rem!important}
  .button,button.button,a.button{min-height:var(--hm-touch)}
  input:not([type=checkbox]):not([type=radio]),select,textarea{min-height:var(--hm-touch)}
  .form-grid{grid-template-columns:1fr!important;gap:12px!important}
  .form-grid>.wide,.form-grid>.full{grid-column:auto!important}
  .form-grid .actions{display:grid!important;grid-template-columns:1fr!important}
  .form-grid .actions>.button{width:100%}
  details>summary{min-height:var(--hm-touch);display:flex;align-items:center}
  .table-wrap.mobile-cards table tbody tr{border-radius:18px!important}
  .table-wrap.mobile-cards td.actions{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px!important}
  .table-wrap.mobile-cards td.actions::before{grid-column:1/-1}
  .table-wrap.mobile-cards td.actions>.button,.table-wrap.mobile-cards td.actions>form,.table-wrap.mobile-cards td.actions>details{width:100%!important;max-width:none!important}
  .table-wrap.mobile-cards td.actions form>.button,.table-wrap.mobile-cards td.actions details>summary{width:100%!important;justify-content:center!important}

  /* Full-screen backdrop + bottom sheet for period allocation. */
  .allocation-panel-row.is-open{position:fixed!important;inset:0!important;z-index:2600!important;display:flex!important;align-items:flex-end!important;justify-content:stretch!important;margin:0!important;padding:0!important;background:rgba(15,23,42,.48)!important;backdrop-filter:blur(3px)}
  .allocation-panel-row.is-open>td{display:block!important;width:100%!important;max-width:none!important;padding:0!important;border:0!important;background:transparent!important}
  .allocation-panel-row.is-open>td::before{display:none!important}
  .allocation-panel-shell{width:100%;max-height:min(90svh,760px);overflow:auto;border:0;border-radius:var(--hm-sheet-radius) var(--hm-sheet-radius) 0 0;box-shadow:0 -24px 70px rgba(15,23,42,.25);padding-bottom:env(safe-area-inset-bottom,0px)}
  .allocation-panel-head{position:sticky;top:0;z-index:2;background:rgba(255,255,255,.97);backdrop-filter:blur(12px);padding:15px 16px 12px}
  .allocation-panel-head::before{content:"";position:absolute;top:6px;left:50%;width:42px;height:4px;border-radius:99px;background:rgba(100,116,139,.28);transform:translateX(-50%)}
  .allocation-panel-head h3{font-size:1.05rem}.allocation-panel-head p{font-size:.8rem}
  .allocation-panel-form{display:block;padding:14px 16px 18px}
  .allocation-owner-field,.allocation-reason-field{display:block;margin-bottom:14px}
  .allocation-option-grid{display:grid;grid-template-columns:1fr;gap:8px;margin-bottom:14px}
  .allocation-check{min-height:58px;align-items:center}
  .allocation-panel-actions{position:sticky;bottom:0;display:grid;grid-template-columns:.8fr 1.2fr;gap:8px;margin:0 -16px -18px;padding:12px 16px calc(12px + env(safe-area-inset-bottom,0px));background:rgba(255,255,255,.96);backdrop-filter:blur(12px);border-top:1px solid rgba(15,23,42,.08)}
  .allocation-panel-actions>.button{width:100%}

  .annual-lottery-status{grid-template-columns:1fr 1fr}.annual-lottery-status>div:first-child{grid-column:1/-1}
  .annual-season-grid{grid-template-columns:1fr 1fr}
  .annual-plan-list{grid-template-columns:1fr}.annual-plan-list>div{display:block}.annual-plan-list span{display:block;text-align:right;margin-top:3px}
  .annual-shortage-list>div{grid-template-columns:1fr}.annual-shortage-list span,.annual-shortage-list small{display:block}
  .lottery-quarter-mode{display:grid!important;grid-template-columns:1fr!important}
  .lottery-run-form .button{width:100%}
  .special-group-selector{display:grid!important;grid-template-columns:1fr!important}
  .special-group-selector .button{width:100%}
}

@media (max-width:520px){
  .heading-actions{grid-template-columns:1fr!important}
  .table-wrap.mobile-cards td.actions{grid-template-columns:1fr!important}
  .annual-season-grid,.annual-lottery-status{grid-template-columns:1fr}
  .annual-lottery-status>div:first-child{grid-column:auto}
}
