:root{
  --bg:#0A0A0A; --panel:#111316; --text:#E6E6E6; --muted:#A8B0B9; --line:#23262B;
  --gold:#D4AF37; --gold-700:#B8961F; --field:#14171B; --field-border:#2A2F35;
  --shadow:0 10px 30px rgba(0,0,0,.45); --ring:1.5px;
  --kb-item-h: 44px;
  --kb-item-gap: 8px;
  --kb-visible: 10;
}

*{ box-sizing:border-box }
html,body{ margin:0; padding:0; min-height:100% }
body{
  background:var(--bg); color:var(--text);
  font-family:Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  display:flex; justify-content:center; align-items:center; min-height:100vh;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
}
.hidden{ display:none }
h1,h2{ margin:0 0 16px; color:var(--text) }
h3{ margin:0; }

label{ display:block; margin-top:18px; margin-bottom:6px; font-weight:600; color:var(--muted) }

.container, .login-screen{
  width:100%; max-width:980px; background:var(--panel);
  border: var(--ring) solid var(--gold); border-radius:16px;
  padding:28px; margin:28px 16px 32px;
  box-shadow:var(--shadow), 0 0 0 1px rgba(212,175,55,.06), 0 0 24px rgba(212,175,55,.12);
  position:relative; overflow:hidden;
}
.login-screen{ max-width:420px; padding:32px; }

.header-row{ display:flex; justify-content:center; align-items:center; }

@media (max-width:560px){
  .header-row h1{ text-align:center }
  .header-row .h1-second{ display:block; margin-top:2px }
}

@media (max-width:560px){
  .container, .login-screen{ margin:20px 12px 24px; border-radius:14px; padding:22px; }
  label{ margin-top:14px }
}
input, select, textarea, button{ width:100%; margin:10px 0; font-size:16px; border-radius:10px; }
input, select, textarea{
  background:var(--field); color:var(--text); border:1px solid var(--field-border);
  padding:12px 14px; outline:none; transition:border-color .2s, box-shadow .2s, background .2s;
}
input::placeholder, textarea::placeholder{ color:#8A929B; }
input:focus, select:focus, textarea:focus{ border-color:var(--gold); box-shadow:0 0 0 3px rgba(212,175,55,.18); }
textarea{ resize:vertical; min-height:110px }

input[type="radio"], input[type="checkbox"]{ width:auto; margin:0; }

.break{ word-break:break-word; white-space:normal; }

button{
  background:var(--gold); color:#0A0A0A; border:none;
  padding:12px 16px; font-weight:700; cursor:pointer;
  transition:transform .06s, box-shadow .2s, background .2s;
  box-shadow:0 6px 16px rgba(212,175,55,.25);
}
button:hover{ background:var(--gold-700); box-shadow:0 8px 22px rgba(212,175,55,.32) }
button:active{ transform:translateY(1px) }
button.logout-btn{
  background:transparent;
  border:1px solid #c73b3b;
  color:#c73b3b;
  width:100%;
  padding:12px 0;
  font-weight:600;
  border-radius:12px;
  transition:.2s;
}
button.logout-btn:hover{
  background:#c73b3b;
  color:#000;
  box-shadow:0 0 12px rgba(215,70,70,.3);
}
button.ghost{ background:transparent; color:#d4c48f; border:1px dashed #3a3f46 }
button.ghost.danger{ color:#ffb3b7; border-color:#5a2226 }
button.small{ padding:6px 10px; font-size:13px }

@media (max-width:640px){
  #config-screen > .header-row{ flex-wrap:wrap; align-items:flex-start }
  #config-screen > .header-row h1{ flex:1 1 100%; margin:0 0 10px; line-height:1.2 }
  #logout-btn{ margin-left:auto; width:auto; white-space:nowrap }
}

.group{ border:1px solid var(--line); border-radius:14px; padding:14px 14px 10px; margin:16px 0; background:#0f1114 }
.group-head{ display:flex; gap:8px; align-items:baseline; justify-content:space-between; margin-bottom:4px; flex-wrap:wrap }
.muted{ color:#A8B0B9 } .small{ font-size:12px }

.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:10px }
.grid-3{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px }
@media (max-width:720px){ .grid-2{ grid-template-columns:1fr } .grid-3{ grid-template-columns:1fr } }

.tabs{
  display:grid; grid-template-columns: repeat(3, 1fr);
  gap:8px; margin:16px 0 18px; padding:6px 12px;
  border:1px solid var(--line); border-radius:12px; background:#0e1114; overflow:visible;
}

@media (max-width:560px){
  .tabs{ padding:6px 14px; gap:6px; }
  .tabs .tab{ min-width:0; }
}
@media (max-width:560px){
  .tab{ font-size:15px; padding:9px 12px; }
}

.tabs .tab{ width:auto !important; text-align:center }
.tab{
  position:relative; display:flex; align-items:center; justify-content:center;
  padding:10px 14px; background:#15181d; color:var(--text);
  border:1px solid #22262b; border-radius:10px; font-weight:600;
  white-space:nowrap; overflow:visible; text-overflow:ellipsis; min-width:0;
  transition:background .2s, box-shadow .2s, color .2s, border-color .2s;
}

.tab:hover{ background:#191d22; border-color:#2a2f35 }
.tab.is-active{
  background:linear-gradient(180deg, #1a1f24, #14171b);
  border-color:rgba(212,175,55,.55); color:#fff;
  box-shadow:0 0 0 1px rgba(212,175,55,.35), 0 8px 22px rgba(212,175,55,.18);
}
.tab::after{
  content:""; position:absolute; left:10px; right:10px; bottom:-6px; height:2px;
  background:linear-gradient(90deg, #b1871f, #d4af37, #ffd66a, #d4af37, #a27f1b);
  opacity:0; transition:opacity .2s;
}
.tab.is-active::after{ opacity:1 }

.tab-panel{ }
.tab-panel.hidden{ display:none }
.save-row{ margin-top:18px }

.roles-toolbar{
  display:grid;
  grid-template-columns: auto 1fr auto;
  align-items:center;
  column-gap:8px;
  row-gap:0;
  margin-bottom:12px;
}
.roles-toolbar .switch{ display:flex; align-items:center; gap:8px; height:48px; }
.roles-toolbar .switch input{ margin:0; }
.roles-toolbar .switch span{ line-height:1; }

.roles-search{ width:100% }
.switch{ display:flex; align-items:center; gap:8px; color:#9aa3ac }
.roles-grid{ display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:12px; }
@media (max-width:640px){ .roles-grid{ grid-template-columns: 1fr } }
.role-card{ background:#121519; border:1px solid #23262b; border-radius:12px; padding:14px; }
.role-head{ display:flex; align-items:center; gap:10px; margin-bottom:6px }
.role-icon{ font-size:20px }
.chip{ margin-left:auto; padding:2px 8px; background:#1b1f24; border:1px solid #2b3037; border-radius:999px; font-size:12px; color:#d4c48f }
.role-teaser{ margin:8px 0 10px; color:#b8bfc7; font-size:14px }
.role-actions{ display:flex; gap:8px; flex-wrap:wrap }
.role-card--add{ display:flex; align-items:center; justify-content:center; border:1px dashed #3a3f46; background:#0f1317 }

.access-mode{ display:grid; gap:8px; margin:8px 0 12px }
.radio{
  display:grid; grid-template-columns:auto 1fr; align-items:center; column-gap:10px;
  color:var(--text);
}
.radio span{ line-height:1.35 }

.chips{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:10px }
.chip{ display:inline-flex; align-items:center; gap:6px; padding:6px 10px; background:#15191e; border:1px solid #2a2f35; border-radius:999px; font-size:14px }
.chip .x{ background:transparent; border:0; padding:0 4px; cursor:pointer; color:#d4c48f }
.access-add{ display:grid; grid-template-columns: 1fr auto; gap:8px; margin:10px 0 12px }
.access-table-wrap{ overflow-x:auto }
.access-table{ width:100%; border-collapse:collapse; }
.access-table th, .access-table td{ text-align:left; padding:10px 8px; border-bottom:1px solid #23262b }

.commands{ margin-top:10px }
.commands-head{ display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:8px }
.commands-head button{ white-space:nowrap }
.cmd-list .cmd-row{ display:grid; grid-template-columns: 200px 1fr auto; gap:8px; margin-bottom:8px }
@media (max-width:560px){ .cmd-list .cmd-row{ grid-template-columns: 1fr 1fr auto } }

.kb-layout{ display:grid; grid-template-columns: 280px 1fr; gap:12px; }
@media (max-width:900px){ .kb-layout{ grid-template-columns: 1fr } }
.kb-list{ border:1px solid var(--line); border-radius:12px; padding:10px; background:#0f1114; }
.kb-list-head{ display:grid; gap:8px; margin-bottom:8px }

.kb-items{
  list-style:none; padding:0; margin:0;
  max-height: calc(var(--kb-item-h) * var(--kb-visible) + var(--kb-item-gap) * (var(--kb-visible) - 1));
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y proximity;
  padding-right: 4px;
}
.kb-items li{
  height: var(--kb-item-h);
  line-height: var(--kb-item-h);
  margin-bottom: var(--kb-item-gap);
  padding: 0 12px;
  border:1px solid #23262b; background:#121519; border-radius:10px;
  cursor:pointer; transition:background .2s, border-color .2s;
  scroll-snap-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-items li:hover{ background:#141a20; }
.kb-items li.is-active{ border-color:rgba(212,175,55,.45); box-shadow:0 0 0 1px rgba(212,175,55,.25) }

@media (max-width: 640px){
  :root{ --kb-visible: 4; --kb-item-h: 48px; }
}

.chip{ white-space: nowrap; }

.kb-editor{ border:1px solid var(--line); border-radius:12px; padding:12px; background:#0f1114; }
.kb-header{ margin-bottom:8px }

.subtabs{
  display:flex; gap:8px; margin-bottom:10px; flex-wrap:wrap; overflow-x:auto; padding-bottom:2px;
}
.subtab{ background:#15181d; border:1px solid #22262b; color:var(--text); padding:8px 12px; border-radius:8px; font-weight:600; white-space:nowrap }
.subtab.is-active{ border-color:rgba(212,175,55,.5); box-shadow:0 0 0 1px rgba(212,175,55,.25) }
.subpanel.hidden{ display:none }
.row-actions{ display:flex; gap:8px; flex-wrap:wrap; margin-top:10px }

.container, .login-screen { position: relative; overflow: hidden; }
@property --sheen { syntax:'<angle>'; inherits:false; initial-value:0deg; }
@keyframes sheen-roll { to { --sheen:360deg; } }
.container::after, .login-screen::after{
  content:""; position:absolute;
  --sheen-extra: 3px; inset: calc(-1 * (var(--ring) + var(--sheen-extra)));
  padding: calc(var(--ring) + var(--sheen-extra)); border-radius: inherit;
  pointer-events:none; z-index:2;
  background: conic-gradient(from var(--sheen),
    #5a4310 0deg, #6d5414 40deg, #8e6f1b 70deg, #b1871f 90deg,
    #d4af37 105deg, #ffd66a 118deg, #d4af37 130deg, #a27f1b 155deg,
    #735816 200deg, #5a4310 360deg) border-box;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  mix-blend-mode: normal; opacity: 1;
  box-shadow: 0 0 0 1px rgba(212,175,55,.25),
              0 0 calc((var(--ring) + var(--sheen-extra)) * 3) rgba(184,150,31,.45);
  animation: sheen-roll 6s linear infinite;
}

.kb-list{
  position: relative;
}
.kb-list::before,
.kb-list::after{
  content:""; position:absolute; left:10px; right:10px; height:18px; z-index:1; pointer-events:none;
  background: linear-gradient(to bottom, rgba(15,17,20,1), rgba(15,17,20,0));
}
.kb-list::before{ top:10px; }
.kb-list::after{
  bottom:10px;
  transform: rotate(180deg);
}

#kb-notes .grid-2 > *{ min-width:0; }
#kb-notes input[type="date"]{ width:100%; max-width:100%; box-sizing:border-box; display:block; }

@media (max-width:640px){
  .roles-toolbar{
    display:grid;
    grid-template-areas:
      "add add"
      "search toggle";
    grid-template-columns:3fr 2fr;
    column-gap:8px;
    row-gap:6px;
  }
  .roles-toolbar > :first-child{ grid-area:add; width:100%; white-space:nowrap; }
  .roles-search{ grid-area:search; }
  .roles-search input{ width:100%; }
  .roles-toolbar .switch{ grid-area:toggle; justify-self:end; }

  .roles-toolbar button,
  .roles-toolbar input{ margin:0; }
}

#kb-notes .grid-2{ align-items:flex-start; }
#kb-notes .grid-2 > *{ display:flex; flex-direction:column; }
#kb-notes .grid-2 input{
  margin-top:12px;
  height:48px; min-height:48px; padding:12px 14px; line-height:1.2;
}
#kb-notes input[type="date"]{
  width:100%; max-width:100%; display:block;
  appearance:none; -webkit-appearance:none;
}

.group .logout-btn{ width:100%; }

@media (max-width: 768px) {
  .group .logout-btn {
    display:block !important;
    width:100% !important;
    max-width:100% !important;
    box-sizing:border-box !important;
    padding:14px 0 !important;
    font-size:16px !important;
    margin-top:10px !important;
  }
}


* {
  scrollbar-width: thin;
  scrollbar-color: #2a2f35 #0f1114;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: #0f1114;
  border: 1px solid var(--line);
  border-radius: 10px;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #2f353d, #1b1f24);
  border: 2px solid #0f1114;
  border-radius: 10px;
}
*::-webkit-scrollbar-thumb:hover {
  background: #383f47;
}
*::-webkit-scrollbar-button {
  height: 8px;
  background: transparent;
}


.toast{
  position:fixed; left:50%; bottom:22px; transform:translateX(-50%);
  padding:12px 16px; border-radius:12px; font-weight:700; letter-spacing:.2px;
  background:#0f1114; color:#e8e2cf; border:1px solid rgba(212,175,55,.35);
  box-shadow:
    0 12px 28px rgba(0,0,0,.45),
    0 0 0 1px rgba(212,175,55,.15) inset,
    0 8px 22px rgba(212,175,55,.16);
  z-index:9999; opacity:0; pointer-events:none; transition:opacity .2s, transform .2s;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
.toast.hidden{ opacity:0; transform:translateX(-50%) translateY(8px); }

.toast.success{
  border-color:rgba(212,175,55,.55);
  box-shadow:
    0 12px 28px rgba(0,0,0,.45),
    0 0 0 1px rgba(212,175,55,.25) inset,
    0 10px 26px rgba(212,175,55,.22);
  color:#f3e9c8;
}
.toast.error{
  border-color:#6b2a2f;
  box-shadow:
    0 12px 28px rgba(0,0,0,.45),
    0 0 0 1px rgba(255,68,68,.18) inset,
    0 10px 26px rgba(255,68,68,.14);
  color:#ffced0;
}
@media (max-width:560px){ .toast{ bottom:16px; padding:10px 14px; font-size:14px; } }


.radio{ cursor:pointer; }
.radio input{ width:18px !important; height:18px; cursor:pointer; }
input[type="radio"], input[type="checkbox"]{ width:auto !important; margin:0; display:inline-block; }

.modal{ position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background:rgba(0,0,0,.55); z-index:9998 }
.modal.hidden{ display:none }

.modal-card{
  width:min(860px, 92vw);
  max-height:92vh;
  overflow:auto;
  margin:6vh 0 2vh;
  background:#0f1114; border:1px solid var(--line); border-radius:14px; padding:16px; box-shadow:var(--shadow);
}

.modal-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:8px }
.modal-head h3{ margin:0 }

.modal-card{ position:relative; }
.modal-close{
  position:absolute; top:10px; right:10px;
  width:34px; height:34px; border-radius:999px;
  background:#14171b; color:#d4c48f; border:1px solid #2a2f35;
  display:flex; align-items:center; justify-content:center;
  font-size:16px; line-height:1; cursor:pointer;
  transition:background .2s, border-color .2s, box-shadow .2s, color .2s, transform .06s;
}
.modal-close:hover{
  background:#1a1f24; border-color:rgba(212,175,55,.55); color:#fff;
  box-shadow:0 0 0 1px rgba(212,175,55,.25);
}
.modal-close:active{ transform:translateY(1px); }

body.modal-open{
  position: fixed;
  overflow: hidden;
  inset: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.modal, .modal-card {
  overscroll-behavior: contain;
}
.modal-card {
  -webkit-overflow-scrolling: touch;
}



