/* =========================================================================
   ResidenceSystem — Theme Orange (cleaned & consolidated)
   ========================================================================= */

/* ------------------------
   Design tokens (light)
   ------------------------ */
:root{
  /* Surface & text */
  --bg:#fcdcbf;
  --panel:#fff8f0;
  --text:#1f2937;
  --muted:#4b5563;
  --sep:#efd4b8;        /* generic separator/border */

  /* Brand */
  --brand:#f58021;
  --brand-2:#fca667;
  --brand-3:#fcbc8b;

  /* Pills / badges */
  --pill-bg:#fff3e6;
  --pill-fg:#7a3e00;

  /* State */
  --ok:#16a34a;
  --warn:#f59e0b;
  --err:#dc2626;

  /* Buttons */
  --btn-fg:#1f2937;
  --btn-bg:#fcbc8b;
  --btn-bd:#fca667;

  /* Accents */
  --orange:#f58021;
  --orange-weak:#fca66733;
  --orange-fg:#1f1f1f;

  /* Inputs */
  --input-bg:#ffffff;
  --input-fg:#111;
  --input-bd:#efd4b8;

  /* Effects */
  --shadow:0 6px 28px rgba(0,0,0,.06);

  /* Icon sizing */
  --nav-icon-size:clamp(16px, calc(1.4vw + 12px), 24px);
  --inline-icon-size:56px;
  --card-height:260px;
  --sidebar-collapsed:240px;
  --sidebar-expanded:240px;
  --sidebar-current:var(--sidebar-collapsed, 240px);
  --topbar-height:80px;
}

html.sidebar-expanded{
  --sidebar-current:var(--sidebar-expanded, 240px);
}

/* ------------------------
   Design tokens (dark)
   ------------------------ */
html.dark{
  --bg:#1f1f22;
  --panel:#2a2a2e;
  --text:#e8ecf3;
  --muted:#9aa3af;
  --sep:#3a3a40;

  --brand:#fca667;
  --brand-2:#fcbc8b;
  --brand-3:#fcdcbf;

  --pill-bg:#2a2a2e;
  --pill-fg:#f8d2b0;

  --btn-fg:#e8ecf3;
  --btn-bg:#3a3a40;
  --btn-bd:#4a4a52;

  --orange:#f59e0b;
  --orange-weak:#f59e0b33;
  --orange-fg:#111;

  --input-bg:#121214;
  --input-fg:#e8ecf3;
  --input-bd:#3a3a40;

  --shadow:0 10px 28px rgba(0,0,0,.25);
}

/* ------------------------
   Reset & base
   ------------------------ */
*{box-sizing:border-box}
html,body{max-width:100%;overflow-x:hidden}
body{
  margin:0;
  min-height:100vh;
  display:flex;
  flex-direction:column;
  background:var(--bg);
  color:var(--text);
  font:14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,"Helvetica Neue",Arial,"Noto Sans","Apple Color Emoji","Segoe UI Emoji";
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
}
a{color:inherit;text-decoration:none}
main.container{
  max-width:1100px;
  width:100%;
  flex:1 0 auto;
  display:flex;
  flex-direction:column;
  margin:20px auto 0;
  padding:0 16px calc(140px + env(safe-area-inset-bottom, 0px));
}

.inline-icon{
  display:block;
  width:var(--inline-icon-size);
  height:auto;
  max-width:100%;
}

/* ------------------------
   Cards / sections
   ------------------------ */
.card{
  background:var(--panel);
  border:1px solid var(--sep);
  border-radius:16px;
  padding:20px;
  box-shadow:var(--shadow);
  min-height:var(--card-height);
}
.section{margin:18px 0}

/* ------------------------
   Navbar (sticky)
   ------------------------ */
.navbar{
  position:sticky; top:0; z-index:50;
  display:flex; align-items:center; gap:12px;
  padding:4px 18px;
  --nav-h: 50px;
  min-height: var(--nav-h);
  border-bottom:1px solid var(--sep);
  background:var(--panel);
  white-space:nowrap;
}
.brand-group{display:inline-flex;align-items:center;gap:10px;flex:0 0 auto;}
.brand{
  display:inline-flex; align-items:center; gap:8px;
  min-width:40px; color:var(--brand); font-weight:800;
}
.brand-logo{height:var(--nav-h); width:auto; display:block}
.honpar{height:var(--nav-h); width:auto; border-radius:10px;border:1px solid var(--sep);object-fit:contain;background:#fff}

.nav-links{
  display:flex; align-items:center; gap:12px;
  min-width:0; flex:1 1 auto; overflow-x:auto; scrollbar-width:thin;
}
.nav-link{
  padding:8px 10px; border-radius:10px; border:1px solid transparent;
}
.nav-link:hover{background:var(--brand-3); border-color:var(--brand-2)}
html.dark .nav-link:hover{background:#3a3a40; border-color:#4a4a52}
.nav-link.active{background:var(--pill-bg); border:1px solid var(--brand-2)}

.right-box{display:inline-flex;align-items:center;gap:10px;flex:0 0 auto}
.role-pill{
  font-weight:700; font-size:12px; padding:4px 10px; border-radius:999px;
  background:var(--pill-bg); color:var(--pill-fg); border:1px solid var(--sep);
}

/* Avatar + dropdown */
.avatar-menu{position:relative;display:inline-flex;align-items:center}
.avatar{
  width:42px;height:42px;border-radius:50%;
  border:1px solid var(--sep); object-fit:cover; background:#ddd; cursor:pointer;
}
.dropdown{
  position:absolute; right:0; top:calc(100% + 8px); min-width:240px;
  border:1px solid var(--sep); background:var(--panel); box-shadow:var(--shadow);
  border-radius:12px; padding:8px; display:none; z-index:100;
}
.avatar-menu .dropdown::before{ content:""; position:absolute; left:0; right:0; top:-8px; height:8px; }
.avatar-menu:hover .dropdown,
.avatar-menu:focus-within .dropdown{display:block}
.drop-title{font-size:12px;color:var(--muted);padding:6px 8px}
.drop-sep{height:1px;background:var(--sep);margin:6px 0}
.drop-item{display:block;padding:8px;border-radius:10px}
.drop-item:hover{background:var(--brand-3);border:1px solid var(--brand-2)}
html.dark .drop-item:hover{background:#3a3a40;border:1px solid #4a4a52}
.logout-btn{
  display:block;width:100%;text-align:left;background:transparent;border:none;
  color:var(--text);padding:8px;border-radius:10px;cursor:pointer;
}
.logout-btn:hover{background:var(--brand-3);border:1px solid var(--brand-2)}
html.dark .logout-btn:hover{background:#3a3a40;border:1px solid #4a4a52}

.icon-btn{
  border:1px solid var(--sep);
  background:transparent; color:var(--text);
  border-radius:10px; padding:10px 12px; cursor:pointer; font-size:18px;
}
.icon-btn:hover{background:var(--brand-3);border-color:var(--brand-2)}
html.dark .icon-btn:hover{background:#3a3a40;border-color:#4a4a52}

/* Responsive header */
@media (max-width:760px){
  .navbar{flex-wrap:wrap}
  .brand-group{order:1;width:100%;justify-content:center}
  .right-box{order:2}
  .nav-links{order:3;width:100%;justify-content:center}
}

/* ------------------------
   Buttons
   ------------------------ */
.btn{
  display:inline-block; line-height:1;
  padding:12px 16px; border-radius:10px;
  border:1px solid var(--btn-bd); background:var(--btn-bg); color:var(--btn-fg);
  cursor:pointer; font-weight:700;
}
.btn .inline-icon{
  width:1.2em;
  height:auto;
  margin-right:8px;
  vertical-align:middle;
  display:inline-block;
}
.btn:hover{filter:brightness(.97)}
.btn:disabled{opacity:.6;cursor:not-allowed}
.btn.full{width:100%}
.btn.sm{padding:8px 10px; font-weight:600}

.btn.brand{
  background:var(--brand); border-color:var(--brand-2); color:#1d1d1d;
}
.btn.orange{
  background:var(--orange); border-color:var(--brand-2); color:var(--orange-fg);
}
.btn.ghost{
  background:transparent; border-color:var(--sep); color:var(--text);
}
.btn.ghost:hover{background:var(--brand-3);border-color:var(--brand-2)}
html.dark .btn.ghost:hover{background:#3a3a40;border-color:#4a4a52}

/* ------------------------
   Notice overlays
   ------------------------ */
.notice-overlay{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:rgba(15,23,42,0.45);
  backdrop-filter:blur(2px);
  z-index:1400;
  opacity:0;
  pointer-events:none;
  visibility:hidden;
  transition:opacity .18s ease, visibility 0s linear .18s;
}
.notice-overlay.visible{
  opacity:1;
  pointer-events:auto;
  visibility:visible;
  transition:opacity .18s ease, visibility 0s linear 0s;
}
.notice-card{
  width:min(520px, 100%);
  background:var(--panel);
  color:var(--text);
  border-radius:16px;
  border:1px solid var(--sep);
  padding:24px;
  box-shadow:0 22px 60px rgba(15,23,42,0.22);
  display:flex;
  flex-direction:column;
  gap:16px;
  max-height:calc(100vh - 64px);
  overflow:auto;
  transform:translateY(12px);
  transition:transform .18s ease;
}
.notice-overlay.visible .notice-card{
  transform:translateY(0);
}
html.dark .notice-card{
  background:#0b1120;
  color:#e2e8f0;
  border-color:rgba(148,163,184,0.35);
  box-shadow:0 30px 60px rgba(8,15,30,0.65);
}
.notice-head{
  display:flex;
  align-items:center;
  gap:12px;
  font-weight:700;
  color:var(--brand);
}
.notice-icon{
  display:grid;
  place-items:center;
  width:36px;
  height:36px;
  border-radius:999px;
  background:rgba(245,128,33,0.15);
  color:inherit;
}
html.dark .notice-icon{
  background:rgba(251,146,60,0.25);
}
.notice-label{
  font-size:13px;
  letter-spacing:0.06em;
  text-transform:uppercase;
}
.notice-title{
  margin:0;
  font-size:1.18rem;
}
.notice-message{
  margin:0;
  line-height:1.55;
  color:var(--text);
}
html.dark .notice-message{
  color:#cbd5e1;
}
.notice-actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
}
.notice-overlay[aria-hidden="true"] .notice-card{
  pointer-events:none;
}

/* ------------------------
   Forms
   ------------------------ */
label{display:block;margin:6px 0 6px 2px;color:#374151}
html.dark label{color:#cbd5e1}
input,select,textarea{
  width:100%; padding:10px 12px; border-radius:10px;
  background:var(--input-bg); color:var(--input-fg); border:1px solid var(--input-bd);
}
input:focus,select:focus,textarea:focus{
  outline:none; border-color:var(--brand-2); box-shadow:0 0 0 3px var(--orange-weak);
}
.helper{color:var(--muted);font-size:12px;margin-top:4px}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media (max-width:720px){ .form-row{grid-template-columns:1fr} }

/* Toggle “pill” */
.pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 12px;
  border-radius:999px;
  border:1px solid var(--sep);
  background:var(--brand-3);
  font-size:12px;
  color:#111;
  line-height:1.2;
}
html.dark .pill{
  background:#3a3a40;
  border-color:#4a4a52;
  color:var(--text);
}
.pill input[type="checkbox"],
.pill input[type="radio"]{
  margin:0;
  accent-color:var(--brand);
}

.pill-toggle{
  border-radius:10px;
  background:transparent;
  border-color:var(--sep);
  color:var(--text);
}
html.dark .pill-toggle{
  background:#3a3a40;
  border-color:#4a4a52;
}

/* ------------------------
   Table
   ------------------------ */
table{width:100%;border-collapse:collapse}
thead th{
  font-size:12px; text-transform:uppercase; letter-spacing:.03em;
  color:var(--muted); border-bottom:1px solid var(--sep); padding:10px; text-align:left;
}
td{padding:10px;border-bottom:1px solid var(--sep);text-align:left}
tr:hover td{background:rgba(0,0,0,.02)}
html.dark tr:hover td{background:#26262a}

.table-scroll{overflow-x:auto}
.table-residentes{table-layout:fixed;min-width:1040px}
.table-residentes col.col-select{width:48px}
.table-residentes col.col-nome{width:320px}
.table-residentes col.col-ano{width:90px}
.table-residentes col.col-estagio{width:220px}
.table-residentes col.col-preceptor{width:230px}
.table-residentes col.col-tipo{width:160px}
.table-residentes th,.table-residentes td{white-space:nowrap}
.table-residentes td{overflow:hidden;text-overflow:ellipsis}
.table-residentes th.sortable{cursor:pointer;position:relative;padding-right:22px}
.table-residentes th.sortable::after{
  content:"\21C5";
  position:absolute;
  right:8px;
  font-size:11px;
  opacity:.4;
}
.table-residentes th.sort-asc::after{content:"\25B2";opacity:.8}
.table-residentes th.sort-desc::after{content:"\25BC";opacity:.8}

/* Row states */
.is-deleted{text-decoration:line-through;opacity:.7}
.warn td{background:rgba(252,166,103,.15)}
.muted{color:var(--muted)}
.hidden{display:none}

/* ------------------------
   Layout utils
   ------------------------ */
.grid{display:grid;gap:16px}
.grid.cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid.cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}
@media (max-width:900px){ .grid.cols-3{grid-template-columns:1fr 1fr} }
@media (max-width:620px){ .grid.cols-2,.grid.cols-3{grid-template-columns:1fr} }
.stack{display:grid;gap:12px}
.center{display:grid;place-items:center}

.dashboard-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
.dashboard-grid > .span-2{grid-column:span 2}
@media (max-width:1080px){
  .dashboard-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .dashboard-grid > .span-2{grid-column:span 3}
}
@media (max-width:900px){
  .dashboard-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .dashboard-grid > .span-2{grid-column:span 2}
}
@media (max-width:620px){
  .dashboard-grid{grid-template-columns:1fr}
  .dashboard-grid > .span-2{grid-column:span 1}
}

/* ------------------------
   Hub de Cadastros — cards grandes
   ------------------------ */
.page-head{display:flex;gap:8px;align-items:center;margin-bottom:16px}
.page-head h3{margin:0}

.grid-cards{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:18px;
}
.grid-cards--four{
  max-width:100%;
  margin:0 auto;
}
.grid-cards--compact{grid-template-columns:repeat(4,minmax(0,1fr))}
@media (max-width:1080px){
  .grid-cards,
  .grid-cards--compact{grid-template-columns:repeat(3,minmax(0,1fr))}
}
@media (max-width:900px){
  .grid-cards,
  .grid-cards--compact{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:620px){
  .grid-cards,
  .grid-cards--compact{grid-template-columns:1fr}
}
.card-link{
  display:flex;
  flex-direction:column;
  border:1px solid var(--sep);
  border-radius:14px;
  padding:24px 24px 22px;
  text-decoration:none;
  color:inherit;
  transition:transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  background:var(--panel);
  min-height:var(--card-height);
}
.card-link:hover{
  background:var(--brand-3);
  transform:translateY(-2px);
  box-shadow:0 8px 24px rgba(0,0,0,.06);
  border-color:var(--brand-2);
}
/* Dark mode: keep hover readable (avoid bright orange panel) */
html.dark .card-link:hover{
  background:#3a3a40;
  border-color:#4a4a52;
}
.card-link .icon{
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:42px;
  line-height:1;
  margin-bottom:10px;
}
.card-link .icon svg{
  width:48px;
  height:48px;
}
.card-link .icon img{
  display:block;
  width:56px;
  height:auto;
}
.card-icon--theme{
  width:60px;
  height:auto;
}
.card-link h4{margin:0 0 6px 0; font-weight:700}
.card-link p{margin:0}

/* ------------------------
   Settings pages
   ------------------------ */
.settings-page{display:flex;flex-direction:column;gap:22px;}
.settings-head{align-items:center;gap:16px;}
.settings-head-text{display:flex;flex-direction:column;gap:4px;}
.settings-card{position:relative;overflow:hidden;}
.settings-form{display:flex;flex-direction:column;gap:24px;}
.field-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;}
@media (max-width:780px){.field-grid{grid-template-columns:1fr;}}

.media-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;align-items:start;}
@media (max-width:960px){.media-grid{grid-template-columns:repeat(2,minmax(0,1fr));}}
@media (max-width:620px){.media-grid{grid-template-columns:1fr;}}
.media-field{display:flex;flex-direction:column;gap:12px;}
.media-preview-wrap{position:relative;border:1px solid var(--sep);border-radius:16px;overflow:hidden;background:var(--bg);aspect-ratio:1;display:flex;align-items:center;justify-content:center;}
.media-preview{width:100%;height:100%;object-fit:cover;display:block;}
.media-meta{display:flex;flex-direction:column;gap:6px;}
.field-label{font-weight:600;margin:0 0 2px 2px;}
.avatar-field .media-preview-wrap{border-radius:50%;aspect-ratio:1;max-width:220px;margin:0 auto;}
.avatar-controls{display:flex;flex-direction:column;gap:18px;align-items:center;}
.avatar-lower{display:flex;flex-direction:column;gap:14px;align-items:center;}
.avatar-preview{width:140px;height:140px;border-radius:50%;object-fit:cover;border:2px solid var(--sep);background:#ddd;}
.avatar-actions{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;}

.avatar-source{display:flex;flex-direction:column;gap:10px;align-items:center;text-align:center;}
.avatar-source-toggle{display:flex;align-items:center;gap:14px;font-weight:600;flex-wrap:wrap;justify-content:center;}
.avatar-source-text{font-size:13px;color:var(--muted);text-align:center;}
.avatar-source-toggle .avatar-source-text{white-space:nowrap;}
.avatar-source-toggle .avatar-source-text.avatar-source-text-on{color:var(--text);}
.avatar-source-toggle .avatar-source-text.avatar-source-text-off{color:var(--text);}
@media (max-width:600px){
  .avatar-source-toggle{flex-direction:column;gap:10px;}
  .avatar-source-toggle .avatar-source-text{white-space:normal;}
}

.avatar-switch{position:relative;display:inline-flex;align-items:center;justify-content:center;width:58px;height:30px;cursor:pointer;}
.avatar-switch input{position:absolute;inset:0;margin:0;opacity:0;}
.avatar-switch-track{position:relative;width:100%;height:100%;border-radius:999px;background:rgba(148,163,184,0.35);display:flex;align-items:center;padding:4px;transition:background .24s ease, box-shadow .24s ease;}
.avatar-switch-thumb{width:22px;height:22px;border-radius:50%;background:#fff;box-shadow:0 4px 10px rgba(15,23,42,0.18);transform:translateX(0);transition:transform .24s ease, background .24s ease;}
.avatar-switch input:checked + .avatar-switch-track{background:var(--brand-2);}
.avatar-switch input:checked + .avatar-switch-track .avatar-switch-thumb{transform:translateX(28px);background:var(--brand);}
html.dark .avatar-switch-track{background:rgba(148,163,184,0.28);}
html.dark .avatar-switch input:checked + .avatar-switch-track{background:var(--brand);}
html.dark .avatar-switch input:checked + .avatar-switch-track .avatar-switch-thumb{background:#111;}

.settings-actions{display:flex;gap:12px;justify-content:flex-end;flex-wrap:wrap;}
.settings-card.locked form{filter:grayscale(.25);pointer-events:none;}
.settings-card.locked .settings-lock-overlay{opacity:1;pointer-events:auto;}
.settings-lock-overlay{position:absolute;inset:0;background:linear-gradient(160deg,rgba(255,255,255,0.82),rgba(252,214,182,0.82));display:flex;align-items:center;justify-content:center;text-align:center;padding:18px;font-weight:600;color:#7a4b11;opacity:0;pointer-events:none;transition:opacity .2s ease;}
html.dark .settings-lock-overlay{background:linear-gradient(160deg,rgba(17,24,39,0.9),rgba(30,41,59,0.88));color:#f8d2b0;}

.avatar-editor-overlay{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(15,23,42,0.55);backdrop-filter:blur(2px);z-index:1600;}
.avatar-editor-overlay[hidden]{display:none !important;}
.avatar-editor-modal{width:min(640px,100%);max-height:calc(100vh - 80px);overflow:auto;background:var(--panel);border-radius:18px;border:1px solid var(--sep);padding:24px;display:flex;flex-direction:column;gap:18px;}
html.dark .avatar-editor-modal{background:#111827;border-color:#334155;}
.avatar-editor-header,.avatar-editor-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;}
.avatar-editor-body{display:grid;grid-template-columns:1fr 220px;gap:18px;align-items:start;}
.avatar-editor-body canvas{display:block;width:100%;height:auto;max-width:360px;border-radius:18px;border:1px solid var(--sep);background:rgba(148,163,184,0.15);}
html.dark .avatar-editor-body canvas{border-color:#334155;background:rgba(30,41,59,0.45);}
.avatar-editor-controls{display:flex;flex-direction:column;gap:16px;}
.avatar-editor-zoom input[type="range"]{width:100%;}
.avatar-editor-buttons{display:flex;flex-direction:column;gap:10px;}
@media (max-width:780px){
  .avatar-editor-body{grid-template-columns:1fr;grid-template-rows:auto auto;}
  .avatar-editor-controls{flex-direction:row;flex-wrap:wrap;justify-content:center;}
  .avatar-editor-buttons{flex-direction:row;justify-content:center;}
}

/* ------------------------
   Login
   ------------------------ */
.login-wrap{
  flex:1 0 auto;
  width:100%;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  padding:40px 24px 80px;
  gap:32px;
}
.login-grid{
  display:grid; grid-template-columns: 1fr 420px; gap:28px; align-items:center;
  width:100%; max-width:1100px;
}
.coreme-left-logo{display:block; max-width:100%; height:auto; max-height:220px; object-fit:contain; margin:0 auto}
.login-card{ width:100% }
@media (max-width:800px){ .login-grid{grid-template-columns:1fr} .coreme-left-logo{max-height:140px} }

/* ------------------------
   Footer
   ------------------------ */
.site-footer{
  position:fixed;
  left:0; right:0; bottom:0;
  padding:12px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  background:var(--bg);
  border-top:1px solid var(--sep);
  text-align:center;
  color:var(--muted);
  z-index:30;
}
.site-footer .copy{margin:0 0 6px 0;font-size:13px;}
.site-footer .footer-logo{margin-top:8px;display:flex;justify-content:center}
.site-footer .footer-logo img{height:30px;width:auto;opacity:.85}
.site-footer .egg{color:var(--bg);font-size:12px;}

/* ------------------------
   Menus específicos (legado)
   ------------------------ */
.menu-cads{
  display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:14px;
}
.menu-cads a{
  display:block;padding:14px;border-radius:12px;border:1px solid var(--sep);
  background:var(--panel); text-align:center; font-weight:700;
}
.menu-cads a:hover{background:var(--brand-3);border-color:var(--brand-2)}
html.dark .menu-cads a:hover{background:#3a3a40;border-color:#4a4a52}

/* -----------------------
   Swatches para Cadastro de Residentes
  ------------------------ */

.swatch-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(34px,1fr));gap:8px}
.swatch{
  width:34px;height:34px;border-radius:8px;border:1px solid var(--border);
  cursor:pointer; position:relative;
}
.swatch.used::after{
  content:""; position:absolute; inset:0; border-radius:8px;
  background:repeating-linear-gradient(45deg, rgba(0,0,0,.12), rgba(0,0,0,.12) 6px, transparent 6px, transparent 12px);
}
.swatch.selected{outline:2px solid var(--brand); outline-offset:2px}

/* ------------------------
   Overrides — header/login adjustments
   ------------------------ */
/* Increase COREME logo in login by ~50% (from prior) */
.coreme-left-logo{ max-height:429px; }
@media (max-width:800px){ .coreme-left-logo{ max-height:273px; } }
/* Header logos: no border/radius; HONPAR transparent background */
.brand-logo{ border:none; border-radius:0; }
.honpar{ background:transparent; border:none; border-radius:0; }

/* ------------------------
   App shell & navigation
   ------------------------ */
.app-shell{
  display:flex;
  flex-direction:row;
  min-height:100vh;
  padding-left:var(--sidebar-current, 240px);
  transition:padding-left .24s ease;
}
.app-shell__main{flex:1 1 auto;display:flex;flex-direction:column;min-height:100vh;}

.app-sidebar{
  position:fixed;
  top:var(--topbar-height, 0px);
  left:0;
  height:calc(100vh - var(--topbar-height, 0px));
  width:var(--sidebar-collapsed, 240px);
  background:var(--panel);
  border-right:1px solid var(--sep);
  box-shadow:0 24px 44px rgba(15,23,42,0.1);
  transition:width .24s ease, box-shadow .24s ease;
  z-index:80;
}
html.dark .app-sidebar{box-shadow:0 26px 50px rgba(0,0,0,0.32);}
.app-sidebar.expanded{width:var(--sidebar-expanded, 240px);}
.app-sidebar__inner{display:flex;flex-direction:column;height:100%;padding:14px 10px;gap:8px;overflow-y:auto;}
.app-sidebar__top{display:flex;align-items:center;justify-content:flex-start;gap:12px;padding:2px 4px 8px;}
.app-sidebar__top-controls{display:flex;align-items:center;gap:6px;}
.app-sidebar__toggle{
  width:44px;
  height:44px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:none;
  background:transparent;
  color:var(--muted);
  border-radius:12px;
  cursor:pointer;
  transition:color .18s ease, background .18s ease;
}
.app-sidebar__toggle:hover,
.app-sidebar__toggle:focus-visible{
  background:var(--brand-3);
  color:var(--brand);
  outline:none;
}
html.dark .app-sidebar__toggle:hover,
html.dark .app-sidebar__toggle:focus-visible{
  background:#3a3a40;
  color:var(--brand-2);
}
.app-sidebar__menu{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top:8px;
}
.app-sidebar__link,
.app-sidebar__action{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid transparent;
  color:var(--text);
  text-decoration:none;
  transition:background .18s ease, border-color .18s ease, color .18s ease;
}
.app-sidebar__link:hover,
.app-sidebar__action:hover{
  background:var(--brand-3);
  border-color:var(--brand-2);
}
html.dark .app-sidebar__link:hover,
html.dark .app-sidebar__action:hover{
  background:#3a3a40;
  border-color:#4a4a52;
}
.app-sidebar__link.active{
  background:var(--pill-bg);
  border-color:var(--brand-2);
  color:var(--brand);
}
.app-sidebar__icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:var(--nav-icon-size);
  height:var(--nav-icon-size);
  flex:0 0 var(--nav-icon-size);
}
.app-sidebar__icon svg{
  width:100%;
  height:100%;
  display:block;
}
.app-sidebar__label{
  flex:1 1 auto;
  min-width:0;
  font-weight:600;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.app-sidebar__footer{
  display:flex;
  flex-direction:column;
  gap:12px;
  padding:16px 8px 10px;
  border-top:1px solid var(--sep);
  color:var(--muted);
  font-size:12px;
  line-height:1.4;
  margin-top:auto;
  align-items:center;
  text-align:center;
}
.app-sidebar__footer-logos{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
  width:100%;
}
.app-sidebar__footer-logo-wrap{
  width:100%;
  display:flex;
  justify-content:center;
}
.app-sidebar__footer-logo-wrap + .app-sidebar__footer-logo-wrap{
  margin-top:8px;
}
.app-sidebar__footer-logo{
  width:112px;
  max-width:100%;
  height:auto;
  display:block;
}
.app-sidebar__footer-logo--app{width:132px;}
.app-sidebar__footer-logo--ihtech{width:104px;}
.app-sidebar__footer-text{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:4px;
  width:100%;
}
.app-sidebar__footer-text span{
  display:block;
  width:100%;
}
.app-sidebar__footer-secret{
  color:var(--panel);
  font-size:10px;
  opacity:.6;
}
.app-sidebar:not(.expanded) .app-sidebar__label{
  opacity:0;
  pointer-events:none;
  max-width:0;
  margin:0;
}
.app-sidebar:not(.expanded) .app-sidebar__link,
.app-sidebar:not(.expanded) .app-sidebar__action{
  justify-content:center;
  padding:10px 0;
  gap:0;
}
.app-sidebar:not(.expanded) .app-sidebar__icon{margin:0;}
.app-sidebar:not(.expanded) .app-sidebar__footer{display:none;}

.mobile-nav-backdrop{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,0.55);
  opacity:0;
  transition:opacity .24s ease;
  z-index:110;
  pointer-events:none;
}
.mobile-nav-backdrop.visible{opacity:1;pointer-events:auto;}
.mobile-nav-backdrop[hidden]{display:none !important;}

.mobile-nav{
  position:fixed;
  z-index:115;
  top:var(--topbar-height, 80px);
  left:0;
  width:min(320px, calc(100vw - 48px));
  height:calc(100vh - var(--topbar-height, 80px));
  background:var(--panel);
  border-right:1px solid var(--sep);
  box-shadow:0 24px 48px rgba(15,23,42,0.28);
  transform:translateX(-100%);
  transition:transform .24s ease;
  padding:20px;
  display:flex;
  flex-direction:column;
  gap:18px;
  overflow:hidden;
}
.mobile-nav.open{transform:translateX(0);}
.mobile-nav__body{
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
  gap:18px;
  overflow-y:auto;
  padding-right:6px;
}
.mobile-nav__section{display:flex;flex-direction:column;gap:12px;}
.mobile-nav__user{flex-direction:row;align-items:center;gap:14px;}
.mobile-nav__avatar{width:52px;height:52px;display:block;border-radius:50%;object-fit:cover;border:1px solid var(--sep);background:#ddd;}
.mobile-nav__user-name{font-weight:700;}
.mobile-nav__user-role{color:var(--muted);font-size:13px;margin-top:4px;}
.mobile-nav__links,.mobile-nav__actions{gap:8px;}
.mobile-nav__link,
.mobile-nav__action{
  display:block;
  width:100%;
  text-align:left;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid transparent;
  background:transparent;
  color:var(--text);
  font-weight:600;
}
.mobile-nav__link{
  display:flex;
  align-items:center;
  gap:12px;
}
.mobile-nav__link-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:var(--nav-icon-size);
  height:var(--nav-icon-size);
  color:var(--muted);
  flex:0 0 var(--nav-icon-size);
}
.mobile-nav__link-icon svg{
  width:100%;
  height:100%;
  display:block;
}
.mobile-nav__link-label{flex:1 1 auto;}
.mobile-nav__action{cursor:pointer;}
.mobile-nav__link:hover,
.mobile-nav__action:hover{background:var(--brand-3);border-color:var(--brand-2);}
html.dark .mobile-nav__link:hover,
html.dark .mobile-nav__action:hover{background:#3a3a40;border-color:#4a4a52;}
.mobile-nav__link.active{background:var(--pill-bg);border-color:var(--brand-2);}
.mobile-nav__link.active .mobile-nav__link-icon{color:var(--brand);}
.mobile-nav__footer{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  gap:18px;
}

.app-topbar{
  position:-webkit-sticky;
  position:sticky;
  top:0;
  left:0;
  right:0;
  z-index:120;
  display:flex;
  align-items:center;
  gap:16px;
  padding:0 24px;
  min-height:var(--topbar-height, 80px);
  background:var(--panel);
  transition:padding .24s ease;
  overflow:visible;
}
.app-topbar::before{
  content:"";
  position:absolute;
  top:0;
  bottom:0;
  left:calc(-1 * var(--sidebar-current, 240px));
  right:0;
  background:var(--panel);
  border-bottom:1px solid var(--sep);
  pointer-events:none;
  z-index:-1;
}
.app-topbar__left{
  display:flex;
  align-items:center;
  gap:16px;
  flex:1 1 auto;
  min-width:0;
}
.app-topbar__right{margin-left:auto;display:flex;align-items:center;gap:16px;flex-wrap:wrap;justify-content:flex-end;}
.app-topbar__brand{
  display:inline-flex;
  align-items:center;
  justify-content:flex-start;
  gap:14px;
  text-decoration:none;
  padding:0;
  border:none;
  background:transparent;
  flex:1 1 auto;
  min-width:0;
}
.app-topbar__logo{
  height:72px;
  max-height:calc(var(--topbar-height, 80px) - 8px);
  width:auto;
  display:block;
}

@media (min-width:901px){
  .app-topbar{
    padding-left:0;
    padding-right:32px;
  }
  .app-topbar__left{
    margin-left:calc(-1 * var(--sidebar-current, 240px));
    padding-left:0;
  }
}
.nav-toggle-icon{
  display:inline-block;
  width:20px;
  height:2px;
  border-radius:999px;
  background:currentColor;
  position:relative;
  box-shadow:0 6px 0 currentColor, 0 -6px 0 currentColor;
}
.app-topbar__menu,
.app-topbar__theme{
  width:44px;
  height:44px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--sep);
  background:var(--panel);
  border-radius:12px;
  cursor:pointer;
  transition:color .18s ease, background .18s ease;
}
.app-topbar__menu{
  color:var(--text);
  display:none;
}
.app-topbar__theme{color:var(--brand);}
.app-topbar__theme-label{display:none;}
.app-topbar__theme #themeIconTopbar{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:var(--nav-icon-size);
  height:var(--nav-icon-size);
}
.app-topbar__theme #themeIconTopbar svg{
  width:100%;
  height:100%;
  display:block;
}
.app-topbar__menu:hover,
.app-topbar__menu:focus-visible,
.app-topbar__theme:hover,
.app-topbar__theme:focus-visible{
  background:var(--brand-3);
  color:var(--brand);
  outline:none;
}
html.dark .app-topbar__menu:hover,
html.dark .app-topbar__menu:focus-visible,
html.dark .app-topbar__theme:hover,
html.dark .app-topbar__theme:focus-visible{
  background:#3a3a40;
  color:var(--brand-2);
}
.app-topbar__theme,
.app-topbar__menu{box-shadow:0 0 0 1px transparent;}
html.dark .app-topbar__menu,
html.dark .app-topbar__theme{border-color:#3a3a40;background:#242428;}
.app-topbar__theme span svg{display:block;}
.app-topbar__user{display:flex;align-items:center;gap:14px;flex-wrap:wrap;}
.app-topbar__user-meta{display:flex;flex-direction:column;align-items:flex-end;gap:3px;line-height:1.1;}
.app-topbar__user-name{font-weight:700;font-size:14px;max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.app-topbar__user-role{color:var(--brand);font-size:12px;text-decoration:none;}
.app-topbar__user-role:hover,
.app-topbar__user-role:focus-visible{text-decoration:underline;}
.app-topbar__avatar-link{position:relative;display:grid;place-items:center;width:44px;height:44px;border-radius:50%;overflow:hidden;border:1px solid var(--sep);background:var(--panel);}
.app-topbar__avatar{width:100%;height:100%;display:block;object-fit:cover;border-radius:50%;background:#ddd;}
html.dark .app-topbar__avatar-link{border-color:#3a3a40;background:#1f2937;}
html.dark .app-topbar__avatar{background:#333;}
.app-topbar__avatar-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(15,23,42,0.55);color:#fff;opacity:0;transition:opacity .18s ease;pointer-events:none;}
.app-topbar__avatar-overlay svg{width:20px;height:20px;}
.app-topbar__avatar-link:hover .app-topbar__avatar-overlay,
.app-topbar__avatar-link:focus-visible .app-topbar__avatar-overlay{opacity:1;}
html.dark .app-topbar__avatar-overlay{background:rgba(8,47,73,0.6);}
.app-topbar__logout{
  width:44px;
  height:44px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--sep);
  background:var(--panel);
  border-radius:12px;
  color:var(--text);
  cursor:pointer;
  transition:color .18s ease, background .18s ease;
}
.app-topbar__logout:hover,
.app-topbar__logout:focus-visible{
  background:var(--brand-3);
  color:var(--brand);
  outline:none;
}
html.dark .app-topbar__logout{border-color:#3a3a40;background:#242428;}
html.dark .app-topbar__logout:hover,
html.dark .app-topbar__logout:focus-visible{background:#3a3a40;color:var(--brand-2);}
.app-topbar__logout-icon{width:22px;height:22px;display:block;}
.app-topbar__login{font-weight:600;color:var(--brand);text-decoration:none;}
.app-topbar__login:hover,
.app-topbar__login:focus-visible{text-decoration:underline;}

@media (max-width:900px){
  .app-sidebar{display:none;}
  .app-shell{padding-left:0;}
  .app-shell__main{width:100%;}
  .app-topbar{padding:0 18px;min-height:64px;gap:12px;}
  .app-topbar::before{left:0;}
  .app-topbar__right{gap:12px;}
  .app-topbar__left{margin-left:0;padding-left:0;}
  .app-topbar__logo{height:48px;max-height:52px;}
  .app-topbar__user{display:none;}
  .app-topbar__avatar-link{width:40px;height:40px;}
  .app-topbar__menu{display:inline-flex;}
}

@media (max-width:780px){
  .app-topbar{padding:10px 14px;}
  .app-topbar__right{gap:10px;}
  .app-topbar__user{gap:10px;}
}

@media (min-width:901px){
  .mobile-nav,
  .mobile-nav-backdrop{display:none !important;}
}
