/* Platform additions on top of base.css: sign-in, forms, your side, modals. */
html, body { margin: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }
:root { color-scheme: light; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.toast.err { background: var(--c-red); color: #FFFFFF; }

/* Sign-in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); background: var(--subtle); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 6px 0 0; font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.02em; }
.login-card p { margin: 0; color: var(--text-2); font-size: 14px; }
.login-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--text); color: var(--bg); display: grid; place-items: center; font-weight: 600; font-size: 15px; }
.login-msg { font-size: 13px; padding: 10px 12px; border-radius: 8px; background: var(--blue-bg); color: var(--blue-fg); }
.login-msg.err { background: var(--red-bg); color: var(--red-fg); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > .lab { font-size: 13px; font-weight: 500; }
.field .opt { font-weight: 400; color: var(--text-3); }
.help { margin: 0; font-size: 12px; line-height: 17px; color: var(--text-3); }
.input, .select, .textarea { width: 100%; min-height: 36px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 14px; }
.textarea { min-height: 96px; resize: vertical; line-height: 20px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus); }
.input.money { padding-left: 22px; }
.money-wrap { position: relative; }
.money-wrap::before { content: "$"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 14px; pointer-events: none; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.form-err { margin: 0; font-size: 13px; color: var(--red-fg); background: var(--red-bg); border-radius: 8px; padding: 8px 10px; }
.form-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }
.check small { display: block; font-size: 12px; color: var(--text-3); }
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--plan-line); transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px; background: #FFFFFF; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform 0.15s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--focus); }

/* Sections on management pages */
.narrow { max-width: 860px; }
.sect { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.sect-head { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.sect-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.sect-head p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.sect-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.tpls { display: flex; flex-wrap: wrap; gap: 8px; }
.tpls button { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 500; }
.tpls button:hover { background: var(--hover); }
.mods { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 10px; }
.mod { border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.mod.on { border-color: color-mix(in srgb, var(--blue) 45%, var(--border)); background: color-mix(in srgb, var(--blue) 4%, var(--surface)); }
.mod-top { display: flex; align-items: flex-start; gap: 10px; }
.mod-top .txt { flex: 1; min-width: 0; }
.mod-top b { display: block; font-weight: 600; font-size: 14px; }
.mod-top small { display: block; font-size: 12px; line-height: 17px; color: var(--text-2); }
.mod-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-top: 10px; border-top: 1px solid var(--border-soft); font-size: 13px; }
.mod-opts label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.mod-opts input[type="checkbox"] { accent-color: var(--blue); width: 15px; height: 15px; margin: 0; }
.mod-opts .num { width: 58px; min-height: 30px; padding: 4px 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 28px; height: 28px; border-radius: 8px; border: 2px solid transparent; padding: 0; }
.swatches button[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg) inset; }
.tile { width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; color: #FFFFFF; font-size: 10px; font-weight: 600; flex: none; letter-spacing: 0; }
.tile.lg { width: 32px; height: 32px; border-radius: 9px; font-size: 13px; }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; border-radius: 10px; background: var(--violet-bg); color: var(--violet-fg); font-size: 13px; }
.banner b { font-weight: 600; }
.linkbox { display: flex; gap: 8px; align-items: center; }
.linkbox input { flex: 1; min-width: 0; font-family: var(--f-mono); font-size: 12px; }
.note-ok { padding: 12px; border-radius: 10px; background: var(--green-bg); color: var(--green-fg); font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.note-ok b { font-weight: 600; }
.btn.danger { color: var(--red-fg); }
.btn.danger.solid { background: var(--c-red); color: #FFFFFF; border-color: transparent; }
.btn.sm { min-height: 28px; padding: 0 10px; font-size: 12px; }
.code { font-family: var(--f-mono); font-size: 12px; line-height: 18px; background: var(--subtle); border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-all; margin: 0; }
.side-user { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--border-soft); display: flex; align-items: center; gap: 8px; }
.side-user .who { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user small { display: block; font-size: 11px; font-weight: 400; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.back-link { display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 8px; margin-bottom: 4px; font-size: 12px; font-weight: 500; color: var(--text-2); text-decoration: none; border-radius: 8px; }
.back-link:hover { background: var(--hover); text-decoration: none; }
.nav .sub-label { margin: 12px 0 2px; padding: 0 8px; font-size: 12px; font-weight: 500; color: var(--text-3); }

/* Clients table */
.ctable td { vertical-align: middle; }
.ctable tr.rowlink { cursor: pointer; }
.ctable tr.rowlink:hover td { background: var(--hover); }
.cname { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.chipset { display: flex; flex-wrap: wrap; gap: 4px; }
.num-cell { font-variant-numeric: tabular-nums; }

/* Modal */
.overlay.center { align-items: center; padding: 16px; overflow-y: auto; }
.dialog { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dialog-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.dialog-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border-soft); position: sticky; bottom: 0; background: var(--surface); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 76px; height: 76px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--subtle); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 999px; border: 0; background: rgba(0,0,0,0.6); color: #FFFFFF; display: grid; place-items: center; padding: 0; }

/* Portal extras */
.pv-media { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 10px; }
.pv-media img { height: 150px; width: auto; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); object-fit: cover; }
.preview .pb { white-space: pre-line; overflow-wrap: anywhere; }
.preview .clip { max-height: 220px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.staff-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px 0; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; }
.metric { padding: 12px 14px; border-top: 1px solid var(--border-soft); }
.metric + .metric { border-left: 1px solid var(--border-soft); }
.metric .label { margin: 0; font-size: 12px; font-weight: 500; color: var(--text-2); text-transform: capitalize; }
.metric .num { font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -0.02em; }
.metric svg { width: 100%; height: 34px; display: block; margin-top: 4px; }
.skeleton { padding: 40px 20px; color: var(--text-3); font-size: 13px; }
.sel-inline { min-height: 28px; padding: 2px 6px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); font-size: 12px; font-weight: 500; }
.work-add { display: grid; grid-template-columns: 150px 150px minmax(0, 1fr); gap: 10px; padding: 14px; border-bottom: 1px solid var(--border-soft); background: var(--subtle); }
.work-add .wide { grid-column: 1 / -1; }
.del-x { width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); display: inline-grid; place-items: center; }
.del-x:hover { background: var(--red-bg); color: var(--red-fg); }

@media (max-width: 899px) {
  .work-add { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dialog { max-height: calc(100vh - 16px); }
  .overlay.center { padding: 8px; align-items: flex-end; }
  .hide-phone { display: none; }
}

/* The close button in the sidebar header only matters when the sidebar is a phone drawer. */
.ws > .icon-btn { display: none; }
@media (max-width: 899px) { .ws > .icon-btn { display: inline-grid; } }
