/* ============================================================================
   AMOMS — Core / Platform module (Module 0). Admin Web.
   Layered on css/app.css (shadcn-flavoured tokens). Scoped .core-* / .auth-*.
   Covers: auth screens (login / reset / redirect), profile & settings,
   user management, RBAC permission matrix, notifications inbox, global search,
   audit log.
   ============================================================================ */

/* ---- Auth shell (pre-login, no admin chrome) ----------------------------- */
.auth-body { min-height: 100vh; background: var(--background); }
.auth-split { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
@media (max-width: 900px) { .auth-split { grid-template-columns: 1fr; } .auth-brand { display: none; } }

.auth-brand {
  position: relative; overflow: hidden; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #fff;
  background:
    radial-gradient(120% 90% at 12% 8%, oklch(0.52 0.11 145 / 0.85), transparent 55%),
    radial-gradient(120% 120% at 100% 100%, oklch(0.42 0.07 55 / 0.55), transparent 50%),
    oklch(0.34 0.06 150);
}
.auth-brand::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(125deg, oklch(1 0 0 / 0.04) 0 2px, transparent 2px 26px);
}
.auth-brand-top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.auth-brand-mark { width: 46px; height: 46px; border-radius: 13px; background: oklch(1 0 0 / 0.16); backdrop-filter: blur(4px); display: inline-flex; align-items: center; justify-content: center; }
.auth-brand-name { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.auth-brand-sub { font-size: 12.5px; opacity: 0.8; margin-top: 1px; }
.auth-brand-mid { position: relative; z-index: 1; max-width: 440px; }
.auth-brand-head { font-size: 34px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.12; }
.auth-brand-desc { font-size: 15px; opacity: 0.86; margin-top: 14px; line-height: 1.6; }
.auth-brand-stats { display: flex; gap: 32px; margin-top: 34px; }
.auth-brand-stat .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.auth-brand-stat .l { font-size: 12px; opacity: 0.72; margin-top: 2px; }
.auth-brand-foot { position: relative; z-index: 1; font-size: 12px; opacity: 0.66; }

.auth-pane { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.auth-card { width: 100%; max-width: 408px; }
.auth-card-center { text-align: center; }
.auth-mark-sm { width: 44px; height: 44px; border-radius: 12px; background: var(--avocado); color: #fff; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 20px; }
.auth-h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.auth-p { font-size: 14px; color: var(--muted-foreground); margin-top: 7px; line-height: 1.55; }
.auth-form { display: flex; flex-direction: column; gap: 15px; margin-top: 26px; }
.auth-field-row { display: flex; align-items: center; justify-content: space-between; }
.auth-input-wrap { position: relative; }
.auth-input-wrap > .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.auth-input-wrap .input { padding-left: 38px; height: 44px; }
.auth-input-wrap .eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: none; background: transparent; color: var(--muted-foreground); border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.auth-input-wrap .eye:hover { background: var(--accent); }
.auth-link { font-size: 12.5px; font-weight: 600; color: var(--avocado-fg); cursor: pointer; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-submit { height: 44px; font-size: 14.5px; }
.auth-check-row { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--foreground); user-select: none; }
.auth-check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--input); background: var(--card); display: inline-flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; transition: background-color .12s, border-color .12s; }
.auth-check.on { background: var(--avocado); border-color: var(--avocado); }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted-foreground); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; margin: 22px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.sso-list { display: flex; flex-direction: column; gap: 10px; }
.sso-btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 44px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--foreground); box-shadow: var(--shadow-xs); }
.sso-btn:hover { background: var(--accent); }
.sso-glyph { width: 18px; height: 18px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; }
.auth-foot { font-size: 12px; color: var(--muted-foreground); margin-top: 26px; text-align: center; line-height: 1.6; }
.auth-alert { display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--radius-md); font-size: 12.5px; line-height: 1.45; background: var(--danger-soft); color: var(--danger-fg); border: 1px solid oklch(from var(--destructive) l c h / 0.25); }
.auth-alert > svg { flex-shrink: 0; margin-top: 1px; }
.auth-success-ring { width: 60px; height: 60px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: inline-flex; align-items: center; justify-content: center; margin: 0 auto 18px; }

/* CORE-03 — role redirect interstitial */
.auth-redirect { text-align: center; max-width: 420px; }
.auth-spinner { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--muted); border-top-color: var(--avocado); animation: core-spin .8s linear infinite; margin: 0 auto 22px; }
@keyframes core-spin { to { transform: rotate(360deg); } }
.auth-role-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow-sm); margin: 22px 0; text-align: left; }
.auth-role-ic { width: 46px; height: 46px; border-radius: 12px; background: var(--avocado-soft); color: var(--avocado-fg); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.auth-route-list { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-top: 6px; }
.auth-route-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 12.5px; border-bottom: 1px solid var(--border); }
.auth-route-item:last-child { border-bottom: none; }
.auth-route-item.on { background: var(--avocado-soft); font-weight: 600; }
.auth-route-item .r { color: var(--muted-foreground); }
.auth-route-item.on .r { color: var(--avocado-fg); }
.auth-route-item .dest { margin-left: auto; color: var(--muted-foreground); font-size: 11.5px; }

/* ---- Profile & settings (CORE-04) ---------------------------------------- */
.core-prof-head { display: flex; align-items: center; gap: 18px; padding: 22px; }
.core-prof-avatar { width: 76px; height: 76px; border-radius: 20px; font-size: 28px; flex-shrink: 0; }
.core-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
@container app-main (max-width: 720px) { .core-form-grid { grid-template-columns: 1fr; } }
.core-form-grid .span-2 { grid-column: 1 / -1; }
.core-kv { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--border); gap: 14px; }
.core-kv:last-child { border-bottom: none; }
.core-kv .k { font-size: 13px; color: var(--muted-foreground); display: flex; align-items: center; gap: 9px; }
.core-kv .v { font-size: 13.5px; font-weight: 500; }
.core-session { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.core-session:last-child { border-bottom: none; }
.core-session-ic { width: 36px; height: 36px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); color: var(--muted-foreground); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.core-danger { border-color: oklch(from var(--destructive) l c h / 0.4) !important; }
.core-danger-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.core-danger-row:first-child { border-top: none; }

/* ---- Toggle list rows (prefs / 2FA) -------------------------------------- */
.core-toggle-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.core-toggle-row:last-child { border-bottom: none; }
.core-toggle-row .body { flex: 1; min-width: 0; }
.core-toggle-row .t { font-size: 13.5px; font-weight: 500; }
.core-toggle-row .d { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; line-height: 1.4; }

/* ---- User status dot + cell ---------------------------------------------- */
.core-user-cell { display: flex; align-items: center; gap: 11px; }
.core-seen { font-variant-numeric: tabular-nums; }

/* ---- RBAC permission matrix (CORE-08) ------------------------------------ */
.rbac-layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
@container app-main (max-width: 900px) { .rbac-layout { grid-template-columns: 1fr; } }
.rbac-roles { display: flex; flex-direction: column; }
.rbac-role { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid transparent; border-radius: var(--radius-lg); cursor: pointer; text-align: left; background: transparent; width: 100%; }
.rbac-role:hover { background: var(--accent); }
.rbac-role.on { background: var(--avocado-soft); border-color: oklch(from var(--avocado) l c h / 0.4); }
.rbac-role-ic { width: 34px; height: 34px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); color: var(--muted-foreground); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rbac-role.on .rbac-role-ic { background: var(--avocado); color: #fff; border-color: var(--avocado); }
.rbac-role .nm { font-size: 13.5px; font-weight: 600; }
.rbac-role .ct { font-size: 11.5px; color: var(--muted-foreground); margin-top: 1px; }

.rbac-matrix { width: 100%; border-collapse: collapse; }
.rbac-matrix th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground); padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--border); }
.rbac-matrix th:first-child { text-align: left; padding-left: 16px; }
.rbac-matrix td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: center; }
.rbac-matrix td:first-child { text-align: left; padding-left: 16px; font-size: 13px; font-weight: 500; }
.rbac-matrix tr:last-child td { border-bottom: none; }
.perm-cell { width: 100%; max-width: 96px; height: 34px; margin: 0 auto; border: 1px solid var(--border); background: var(--card); border-radius: 8px; cursor: pointer; color: var(--muted-foreground); display: flex; align-items: center; justify-content: center; transition: background-color .12s, border-color .12s, color .12s; }
.perm-cell:hover { background: var(--accent); color: var(--foreground); }
.perm-cell.on { color: #fff; border-color: transparent; }
.perm-cell.on.lvl-none { background: var(--muted-foreground); }
.perm-cell.on.lvl-view { background: var(--info); }
.perm-cell.on.lvl-edit { background: var(--avocado); }
.perm-cell.on.lvl-approve { background: oklch(0.55 0.13 145); }
.perm-cell.on.lvl-full { background: var(--soil); }
.perm-seg { display: inline-flex; gap: 3px; background: var(--muted); padding: 3px; border-radius: 9px; }
.perm-seg button { width: 30px; height: 26px; border: none; background: transparent; border-radius: 6px; cursor: pointer; color: var(--muted-foreground); display: inline-flex; align-items: center; justify-content: center; }
.perm-seg button:hover { color: var(--foreground); }
.perm-seg button.on { color: #fff; }
.perm-seg button.on.lvl-none { background: var(--muted-foreground); }
.perm-seg button.on.lvl-view { background: var(--info); }
.perm-seg button.on.lvl-edit { background: var(--avocado); }
.perm-seg button.on.lvl-approve { background: oklch(0.55 0.13 145); }
.perm-seg button.on.lvl-full { background: var(--soil); }
.perm-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted-foreground); }
.perm-legend .dot-sm { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: 0; }

/* ---- Notifications inbox (CORE-09) --------------------------------------- */
.notif-list { display: flex; flex-direction: column; }
.notif-item { display: flex; gap: 13px; padding: 15px 18px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--accent); }
.notif-item.unread { background: var(--surface); }
.notif-item.unread::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--avocado); }
.notif-ic { width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 13.5px; line-height: 1.4; }
.notif-item.unread .notif-title { font-weight: 600; }
.notif-desc { font-size: 12.5px; color: var(--muted-foreground); margin-top: 2px; line-height: 1.45; }
.notif-meta { display: flex; align-items: center; gap: 9px; margin-top: 6px; font-size: 11.5px; color: var(--muted-foreground); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--soil); flex-shrink: 0; align-self: center; }
.notif-link { font-size: 12px; font-weight: 600; color: var(--avocado-fg); display: inline-flex; align-items: center; gap: 3px; }

/* ---- Global search (CORE-10) --------------------------------------------- */
.gs-bar { position: relative; margin-bottom: 18px; }
.gs-bar > svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); }
.gs-bar .input { height: 52px; padding-left: 46px; font-size: 16px; }
.gs-scope { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.gs-group-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); margin: 18px 2px 8px; display: flex; align-items: center; gap: 8px; }
.gs-group-label .ct { background: var(--muted); color: var(--muted-foreground); border-radius: 9999px; padding: 0 7px; font-size: 10.5px; line-height: 16px; }
.gs-result { display: flex; align-items: center; gap: 13px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); cursor: pointer; margin-bottom: 8px; }
.gs-result:hover { background: var(--accent); border-color: oklch(from var(--avocado) l c h / 0.4); }
.gs-result-ic { width: 36px; height: 36px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); color: var(--muted-foreground); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.gs-result .nm { font-size: 13.5px; font-weight: 600; }
.gs-result .mt { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }
.gs-result .id { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-foreground); }
.gs-kbd { font-family: var(--font-mono); font-size: 11px; background: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--muted-foreground); }

/* ---- Audit log (CORE-12) ------------------------------------------------- */
.audit-act { font-family: var(--font-mono); font-size: 11.5px; padding: 2px 7px; border-radius: 6px; background: var(--muted); color: var(--foreground); white-space: nowrap; }
.audit-cat-auth { background: var(--info-soft); color: var(--info); }
.audit-cat-procurement { background: var(--avocado-soft); color: var(--avocado-fg); }
.audit-cat-qc { background: var(--pulp-soft); color: var(--pulp-fg); }
.audit-cat-users { background: var(--soil-soft); color: var(--soil-fg); }
.audit-cat-system { background: var(--warning-soft); color: oklch(0.45 0.13 65); }
.audit-cat-orders, .audit-cat-logistics, .audit-cat-maintenance, .audit-cat-production, .audit-cat-reports { background: var(--muted); color: var(--muted-foreground); }
.dark .audit-cat-system { color: oklch(0.82 0.12 82); }
.audit-detail { color: var(--muted-foreground); font-size: 12.5px; }
.audit-ip { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-foreground); }

/* ---- Shared bits --------------------------------------------------------- */
.core-sk { background: var(--muted); border-radius: 6px; height: 12px; position: relative; overflow: hidden; }
.core-sk::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, oklch(1 0 0 / 0.35), transparent); transform: translateX(-100%); animation: core-shim 1.3s infinite; }
.dark .core-sk::after { background: linear-gradient(90deg, transparent, oklch(1 0 0 / 0.07), transparent); }
@keyframes core-shim { 100% { transform: translateX(100%); } }
.core-chip-x { opacity: 0.6; }
