/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; flex-wrap: wrap; }
.login-brand {
  position: relative; overflow: hidden; flex: 1 1 420px; background: var(--side); color: #fff; padding: 56px 48px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
/* the play-triangle from the I-MODE mark, cropped large as the one brand gesture */
.login-brand::after {
  content: ""; position: absolute; right: -90px; bottom: -70px; width: 340px; height: 400px;
  background: var(--orange); opacity: .12; clip-path: polygon(0 0, 100% 50%, 0 100%); pointer-events: none;
}
.login-brand > * { position: relative; z-index: 1; }
.login-logo { align-self: flex-start; }
.login-logo img { width: 220px; height: auto; display: block; }
.login-pitch { display: flex; flex-direction: column; gap: 14px; max-width: 460px; }
.login-pitch h1 { margin: 0; font-size: 38px; line-height: 1.3; font-weight: 700; text-wrap: balance; }
.login-pitch p { margin: 0; font-size: 17px; line-height: 1.6; color: #d5d8dd; }
.login-modules { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.login-modules li { padding: 6px 14px; border: 1px solid #6a6f78; border-radius: 999px; font-size: 14px; color: #e6e8eb; }

.login-panel { flex: 1 1 420px; background: var(--surface); padding: 56px 32px 96px; display: flex; align-items: center; justify-content: center; }
.login-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 20px; }
.login-form .btn-primary { margin-top: 4px; }
.login-form h2 { margin: 0 0 4px; font-size: 26px; font-weight: 700; }
.login-logo-mobile { display: none; width: 180px; height: auto; }
.muted { margin: 0; color: var(--ink-2); font-size: 15px; text-wrap: pretty; }
.small { font-size: 13px; line-height: 1.6; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.field input {
  font-size: 16px; transition: border-color .15s, box-shadow .15s; min-height: 48px; padding: 0 14px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: #fff;
}
.field input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(11,99,229,.18); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
/* the browser draws its own eye in password fields; ours is the one that stays */
input[type="password"]::-ms-reveal,input[type="password"]::-ms-clear{display:none}
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink-2); border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pw-toggle[aria-pressed="true"] { color: var(--blue); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.link-btn { border: 0; background: none; color: var(--blue-text); font-size: 14px; cursor: pointer; padding: 10px 0; text-decoration: underline; text-underline-offset: 3px; }
.note { margin: -8px 0 0; padding: 10px 12px; background: #f3f6fb; border-radius: 8px; font-size: 14px; color: var(--ink-2); }
.form-error { padding: 10px 12px; border-radius: 8px; background: var(--danger-bg); color: var(--danger); font-size: 14px; border: 1px solid #f6c5b4; }

@media (max-width: 860px) {
  .login-brand { display: none; }
  .login-panel { padding: 40px 16px; align-items: flex-start; }
  .login-logo-mobile { display: block; }
}

/* ---------- Launcher ---------- */
.launcher-page { min-height: 100vh; }
.topbar { padding: 12px 24px; display: flex; align-items: center; gap: 12px; }
.topbar-spacer { flex: 1; }
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 10px 4px 4px;
  border: 0; border-radius: 24px; background: transparent; color: var(--ink); cursor: pointer;
}
.user-btn:hover { background: rgba(12,34,94,.06); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #ffe8cc; color: #8a3c00; font-weight: 700;
  display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; text-align: left; }
.user-name { font-size: 14px; font-weight: 600; }
.user-role { font-size: 12px; color: var(--ink-2); }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 10;
  background: #fff; border-radius: 12px; box-shadow: 0 8px 28px rgba(12,34,94,.18); padding: 6px;
}
.pop-head { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }
.pop-item {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 8px; background: none; color: var(--danger); font-size: 15px; cursor: pointer; text-align: left;
}
.pop-item:hover { background: var(--danger-bg); }

.launcher { max-width: 1000px; margin: 0 auto; padding: 32px 24px 64px; display: flex; flex-direction: column; align-items: center; gap: 44px; }
.hero { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.hero-logo { width: 340px; max-width: 80vw; height: auto; display: block; }
.hero-sub { font-size: 15px; color: var(--ink-2); letter-spacing: 1px; }
.greeting { margin: 14px 0 0; font-size: 17px; font-weight: 500; min-height: 1.5em; }

.launcher > nav { width: 100%; }
.app-grid {
  list-style: none; margin: 0; padding: 0; width: 100%;
  display: grid; grid-template-columns: repeat(5, 118px); justify-content: center; gap: 32px 40px; justify-items: center;
}
.app {
  display: flex; flex-direction: column; align-items: center; gap: 10px; width: 118px; padding: 6px 0;
  border: 0; background: none; font: inherit; color: var(--ink); text-decoration: none; cursor: pointer; border-radius: 14px;
}
.app:hover { color: var(--ink); }
.app-icon {
  position: relative; width: 84px; height: 84px; border-radius: 20px; background: #fff;
  border: 1px solid #dfe6f2; box-shadow: 0 1px 2px rgba(12,34,94,.06); display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease-out, box-shadow .15s ease-out, border-color .15s ease-out;
}
.app:not(.is-soon):hover .app-icon, .app:not(.is-soon):focus-visible .app-icon { transform: translateY(-3px); border-color: #c7d4ea; box-shadow: 0 8px 18px -4px rgba(12,34,94,.18); }
.app:active .app-icon { transform: translateY(0) scale(.97); }
.app-name { font-size: 15px; font-weight: 500; text-align: center; line-height: 1.3; }
.app.is-soon { cursor: default; }
.app.is-soon .app-icon { background: #f6f8fc; border-style: dashed; border-color: #cfd9ea; box-shadow: none; }
.app.is-soon .app-icon svg { opacity: .5; filter: grayscale(1); }
.app.is-soon .app-name { color: #5b6b88; }
.app.is-soon:active .app-icon { transform: none; }
.grid-note { margin: -20px 0 0; font-size: 14px; color: var(--ink-2); text-align: center; }
.grid-note i { display: inline-block; width: 12px; height: 12px; margin: 0 6px -1px 0; border: 1px dashed #b5c3db; border-radius: 4px; background: #f6f8fc; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; max-width: calc(100vw - 32px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 15px; box-shadow: 0 6px 20px rgba(12,34,94,.3);
}
.is-loading .topbar, .is-loading .greeting { visibility: hidden; }

@media (max-width: 760px) {
  .app-grid { grid-template-columns: repeat(4, 118px); gap: 28px 16px; }
}
@media (max-width: 560px) {
  .topbar { padding: 8px 12px; }
  .user-text { display: none; }
  .launcher { padding: 16px 16px 48px; gap: 32px; }
  .app-grid { grid-template-columns: repeat(3, 1fr); gap: 24px 8px; }
  .app { width: 100%; }
  .app-icon { width: 72px; height: 72px; border-radius: 18px; }
  .app-icon svg { width: 40px; height: 40px; }
  .app-name { font-size: 13px; }
}

/* menu item that is not sign-out */
.pop-item.is-plain { color: var(--ink); }
.pop-item.is-plain:hover { background: var(--line-soft); }
.pop-item.is-plain svg { color: var(--ink-2); }

/* ---------- dark (shared/theme-pref.js) ---------- */
html[data-theme="dark"] .field input { background: #1f1f1f; }
html[data-theme="dark"] .note { background: #2e2e2e; }
html[data-theme="dark"] .form-error { border-color: #6b3424; }
html[data-theme="dark"] .user-btn:hover { background: rgba(255,255,255,.07); }
html[data-theme="dark"] .avatar { background: #4a2e12; color: #ffc68a; }
html[data-theme="dark"] .user-pop { background: var(--surface); border: 1px solid var(--line-soft); box-shadow: 0 10px 28px -6px rgba(0,0,0,.6); }
html[data-theme="dark"] .app-icon { background: #262626; border-color: #3a3a3a; box-shadow: none; }
html[data-theme="dark"] .app:not(.is-soon):hover .app-icon,
html[data-theme="dark"] .app:not(.is-soon):focus-visible .app-icon { border-color: #5a5a5a; box-shadow: 0 8px 18px -6px rgba(0,0,0,.6); }
html[data-theme="dark"] .app.is-soon .app-icon { background: #1f1f1f; border-color: #4a4a4a; }
html[data-theme="dark"] .app.is-soon .app-name { color: #9a9a9a; }
html[data-theme="dark"] .grid-note i { background: #1f1f1f; border-color: #6a6a6a; }
html[data-theme="dark"] .toast { background: #333; box-shadow: 0 6px 20px rgba(0,0,0,.5); }

/* ---------- reorder + change icon (edit mode) ---------- */
.app-grid.is-editing .app { touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.app-grid.is-editing .app-icon { outline: 2px dashed var(--blue, #0b63e5); outline-offset: 3px; }
.app-grid.is-editing .app.is-soon .app-icon svg { opacity: 1; filter: none; }
.app-grid.is-editing li:not(.is-drag) .app-icon { animation: tile-wiggle .28s ease-in-out infinite alternate; }
.app-grid.is-editing li:nth-child(even):not(.is-drag) .app-icon { animation-direction: alternate-reverse; }
@keyframes tile-wiggle { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } }
@media (prefers-reduced-motion: reduce) { .app-grid.is-editing li .app-icon { animation: none !important; } }
.app-grid li.is-drag { opacity: .25; }
.drag-ghost { position: fixed; z-index: 40; pointer-events: none; margin: 0; list-style: none; transform: scale(1.08); filter: drop-shadow(0 10px 18px rgba(12,34,94,.3)); }
.drag-ghost .app-icon { animation: none; }
.edit-bar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30; max-width: calc(100vw - 24px);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: var(--surface, #fff); border: 1px solid var(--line, #dfe6f2); border-radius: 16px; padding: 10px 14px;
  box-shadow: 0 8px 28px rgba(12,34,94,.2);
}
.edit-bar[hidden] { display: none; }
.edit-hint { font-size: 14px; color: var(--ink-2); }
.edit-btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line, #dfe6f2); background: transparent; color: var(--ink); font: inherit; font-size: 15px; cursor: pointer; }
.edit-btn.is-primary { background: var(--blue, #0b63e5); border-color: var(--blue, #0b63e5); color: #fff; font-weight: 600; }
.icon-dlg-back { position: fixed; inset: 0; z-index: 50; background: rgba(12,34,94,.4); display: flex; align-items: center; justify-content: center; padding: 16px; }
.icon-dlg { width: 100%; max-width: 420px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface, #fff); color: var(--ink); border-radius: 18px; padding: 20px; box-shadow: 0 16px 48px rgba(12,34,94,.35); display: flex; flex-direction: column; gap: 14px; }
.icon-dlg h2 { margin: 0; font-size: 18px; font-weight: 700; }
.icon-dlg h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.icon-prev { display: flex; align-items: center; gap: 12px; }
.icon-prev .app-icon { flex: none; }
.glyph-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.glyph-btn { aspect-ratio: 1; min-height: 44px; border: 2px solid transparent; border-radius: 12px; background: rgba(12,34,94,.06); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; color: var(--ink); }
.glyph-btn svg { width: 26px; height: 26px; }
.glyph-btn[aria-pressed="true"] { border-color: var(--blue, #0b63e5); }
.color-row { display: flex; flex-wrap: wrap; gap: 10px; }
.color-btn { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; box-shadow: inset 0 0 0 2px var(--surface, #fff); cursor: pointer; padding: 0; }
.color-btn[aria-pressed="true"] { border-color: var(--ink); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
html[data-theme="dark"] .glyph-btn { background: rgba(255,255,255,.08); }
html[data-theme="dark"] .edit-bar, html[data-theme="dark"] .icon-dlg { border-color: #3a3a3a; }
html[data-theme="dark"] .icon-dlg-back { background: rgba(0,0,0,.6); }
@media (max-width: 560px) { .edit-bar { bottom: 12px; width: calc(100vw - 24px); } .edit-hint { width: 100%; text-align: center; } }

/* 2026-10-29 — sign-in on a phone, laid out like the technician app's: logo and title centred,
   the fields in one rounded card, a pill button with the brand's play mark, and the large
   triangle from the logo behind the card. Desktop is unchanged (.login-card is only a box). */
.login-card { display: flex; flex-direction: column; gap: 20px; }
.btn-play { display: none; }
@media (max-width: 860px) {
  .login-page { background: var(--bg); }
  .login-panel { background: var(--bg); position: relative; overflow: hidden; padding: 36px 20px 40px; min-height: 100vh; }
  .login-panel::after { content: ""; position: absolute; right: -40px; bottom: 6%; width: 230px; height: 260px;
    background: var(--line-soft); clip-path: polygon(0 0, 100% 50%, 0 100%); opacity: .7; pointer-events: none; }
  .login-form { position: relative; z-index: 1; max-width: 420px; margin: 0 auto; gap: 18px; text-align: center; }
  .login-logo-mobile { width: 170px; margin: 8px auto 0; }
  .login-form h2 { font-size: 28px; }
  .login-card { text-align: left; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 24px;
    padding: 22px 18px; gap: 16px; box-shadow: 0 10px 30px rgba(12, 34, 94, .08); }
  .login-card .field input { border-radius: 16px; min-height: 52px; }
  .login-card .btn-primary { border-radius: 999px; min-height: 56px; display: flex; align-items: center; justify-content: center;
    position: relative; padding: 0 64px 0 24px; }
  .login-card .btn-play { display: block; position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
    width: 42px; height: 42px; border-radius: 50%; background: #fff; }
  .login-card .btn-play::after { content: ""; position: absolute; left: 16px; top: 13px; border-left: 13px solid #f05a28;
    border-top: 8px solid transparent; border-bottom: 8px solid transparent; }
  .login-card .muted.small { text-align: center; }
}
html[data-theme="dark"] .login-card { box-shadow: none; }

/* ลืมรหัสผ่าน popup (login.js) */
.forgot-pop { position: fixed; inset: 0; z-index: 50; background: rgba(9, 22, 52, .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.forgot-pop-card { background: var(--surface); color: var(--ink); border: 1px solid var(--line-soft); border-radius: 20px; width: 100%; max-width: 360px; padding: 24px 20px 20px; text-align: center; box-shadow: 0 24px 60px rgba(9, 22, 52, .35); }
.forgot-pop-ic { font-size: 30px; line-height: 1; margin-bottom: 8px; }
.forgot-pop-card h3 { margin: 0 0 6px; font-size: 19px; }
.forgot-pop-card p { margin: 0 0 18px; line-height: 1.6; color: var(--ink-2); }
.forgot-pop-ok { width: 100%; }
.forgot-pop { animation: fp-fade .2s ease both; }
.forgot-pop .forgot-pop-card { animation: fp-pop .38s cubic-bezier(.2, 1.4, .4, 1) both; }
.forgot-pop .forgot-pop-ic { animation: fp-ic .5s .12s cubic-bezier(.2, 1.6, .4, 1) both; }
.forgot-pop.is-out { animation: fp-fade-out .16s ease both; }
.forgot-pop.is-out .forgot-pop-card { animation: fp-pop-out .16s ease both; }
@keyframes fp-fade { from { background: rgba(9, 22, 52, 0); } to { background: rgba(9, 22, 52, .5); } }
@keyframes fp-fade-out { from { background: rgba(9, 22, 52, .5); } to { background: rgba(9, 22, 52, 0); } }
@keyframes fp-pop { from { opacity: 0; transform: translateY(24px) scale(.82); } to { opacity: 1; transform: none; } }
@keyframes fp-pop-out { to { opacity: 0; transform: translateY(12px) scale(.92); } }
@keyframes fp-ic { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .forgot-pop, .forgot-pop .forgot-pop-card, .forgot-pop .forgot-pop-ic { animation: none; } }

/* quick actions around the palette button (launcher.js wireFab) */
body.fab-open #imodeThemeFab { z-index: 61; transform: rotate(45deg); background: var(--blue, #0b63e5); color: #fff; border-color: transparent; }
#imodeThemeFab { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; transition: transform .18s ease, background .18s ease; }
.fab-menu { position: fixed; inset: 0; z-index: 60; background: rgba(9, 22, 52, 0); transition: background .18s ease; }
.fab-menu.is-in { background: rgba(9, 22, 52, .55); }
.fab-act { position: fixed; transform: translate(-50%, -50%) scale(.4); opacity: 0; transition: transform .2s cubic-bezier(.2, .9, .3, 1.3), opacity .15s ease;
  transition-delay: calc(var(--i) * 40ms); display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: #fff; }
.fab-menu.is-in .fab-act { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.fab-ic { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--surface, #fff); color: var(--ink, #0c225e);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .25); transition: transform .12s ease, background .12s ease; }
.fab-lb { font-size: 12.5px; font-weight: 700; white-space: nowrap; padding: 3px 9px; border-radius: 999px; background: rgba(0, 0, 0, .55); }
.fab-act:hover .fab-ic, .fab-act.is-hot .fab-ic, .fab-act:focus-visible .fab-ic { transform: scale(1.12); background: #f05a28; color: #fff; }
.fab-act:focus-visible { outline: none; }
@media (prefers-reduced-motion: reduce) { .fab-act, .fab-menu, #imodeThemeFab { transition: none; } }
