:root{
  --bg1:#f6f7fb;
  --bg2:#eef2ff;

  --panel: rgba(255,255,255,.82);
  --panel2: rgba(255,255,255,.68);

  --text:#0f172a;
  --muted:#475569;

  --line: rgba(15,23,42,.10);
  --brand:#4f46e5;

  --good:#16a34a;
  --bad:#dc2626;
  --warn:#d97706;

  --shadow: 0 12px 34px rgba(15,23,42,.10);
  --radius:16px;
  --radius2:18px;
  --max: 1120px;

  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{box-sizing:border-box}
html,body{height:100%}

body{
  margin:0;
  font-family:var(--font);
  color:var(--text);
  background:
    radial-gradient(1100px 700px at 12% 12%, rgba(79,70,229,.12), transparent 55%),
    radial-gradient(900px 600px at 88% 18%, rgba(14,165,233,.10), transparent 55%),
    radial-gradient(900px 600px at 55% 115%, rgba(34,197,94,.08), transparent 55%),
    linear-gradient(180deg, var(--bg2), var(--bg1));
}

a{color:inherit;text-decoration:none}
a:hover{opacity:.96}

.container{
  max-width:var(--max);
  margin:0 auto;
  padding:26px 18px 56px;
}

/* =========================
   HEADER / TOPBAR
========================= */

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:14px 16px;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:20px;
  box-shadow:var(--shadow);
  backdrop-filter: blur(10px);
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
}

.brand img{
  width:52px;
  height:52px;
  object-fit:contain;
  border-radius:14px;
  background:rgba(79,70,229,.08);
  padding:8px;
  flex:0 0 52px;
}

.brand .title{
  font-weight:700;
  letter-spacing:.2px;
  font-size:15px;
}

.brand .subtitle{
  font-size:12px;
  color:var(--muted);
  margin-top:2px;
}

.userbox{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.65);
  color:var(--muted);
  font-size:13px;
}

.pill strong{
  color:var(--text);
  font-weight:600;
}

.actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

/* =========================
   BUTTONS
========================= */

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.72);
  color:var(--text);
  cursor:pointer;
  font-weight:600;
  transition:transform .06s ease, border-color .2s ease, background .2s ease;
}

.btn:hover{
  border-color:rgba(79,70,229,.22);
  background:rgba(255,255,255,.92);
}

.btn:active{
  transform:translateY(1px);
}

.btn.primary{
  background:linear-gradient(180deg, rgba(79,70,229,.95), rgba(79,70,229,.78));
  border-color:rgba(79,70,229,.45);
  color:#fff;
}

.btn.good{
  background:linear-gradient(180deg, rgba(22,163,74,.92), rgba(22,163,74,.74));
  border-color:rgba(22,163,74,.35);
  color:#fff;
}

.btn.bad{
  background:linear-gradient(180deg, rgba(220,38,38,.92), rgba(220,38,38,.74));
  border-color:rgba(220,38,38,.35);
  color:#fff;
}

.btn.ghost{background:transparent}

/* =========================
   GRID / CARDS
========================= */

.grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap:16px;
  margin-top:18px;
  grid-column: 1 / -1;
}

.card{
  grid-column: span 12;
  width:100%;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:20px;
  box-shadow:var(--shadow);
  padding:16px;
  backdrop-filter: blur(10px);
}

.card.half{grid-column: span 6}
.card.third{grid-column: span 4}

@media (max-width:900px){
  .card.half,.card.third{grid-column: span 12}
}

/* =========================
   TYPO
========================= */

.h1{
  font-size:22px;
  font-weight:700;
  margin:0 0 6px;
}

.h2{
  font-size:15px;
  font-weight:650;
  margin:0 0 10px;
  color:var(--text);
}

.muted{color:var(--muted)}
.sep{height:1px;background:var(--line);margin:14px 0}
.small{font-size:12px}
.right{text-align:right}
.pre{white-space:pre-wrap;word-break:break-word}

/* =========================
   TABLES
========================= */

.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:14px;
  background:rgba(255,255,255,.55);
}

.table th, .table td{
  padding:10px 12px;
  border-bottom:1px solid var(--line);
  vertical-align:top;
  font-size:14px;
}

.table th{
  color:var(--muted);
  font-weight:650;
  text-align:left;
  background:rgba(15,23,42,.03);
}

.table tr:last-child td{border-bottom:none}
.table tr:hover td{background:rgba(79,70,229,.04)}

/* =========================
   FORMS
========================= */

.input, .select, .textarea{
  width:100%;
  padding:14px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.85);
  color:var(--text);
  outline:none;
  font-size:16px;
}

.input:focus,.select:focus,.textarea:focus{
  border-color:rgba(79,70,229,.35);
  box-shadow:0 0 0 4px rgba(79,70,229,.10);
}

.textarea{
  min-height:120px;
  resize:vertical;
}

.label{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
}

.notice{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.70);
}

.notice.good{border-color:rgba(22,163,74,.25)}
.notice.bad{border-color:rgba(220,38,38,.25)}

.row{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap:12px;
}

.col12{grid-column: span 12}
.col9{grid-column: span 9}
.col6{grid-column: span 6}
.col4{grid-column: span 4}
.col3{grid-column: span 3}

@media (max-width:900px){
  .col9,.col6,.col4,.col3{grid-column: span 12}
}

.grid2{
  display:grid;
  grid-template-columns: repeat(2,1fr);
  gap:12px;
}

@media (max-width:900px){
  .grid2{grid-template-columns:1fr}
}

.footer{
  margin-top:18px;
  padding:10px 2px;
  opacity:.85;
}

.kbd{
  padding:2px 8px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.70);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:12px;
}

.badge{
  display:inline-flex;
  align-items:center;
  padding:5px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.70);
  font-size:12px;
  color:var(--muted);
}

.badge.pending{border-color:rgba(217,119,6,.25); color:#92400e}
.badge.accepted{border-color:rgba(22,163,74,.25); color:#166534}
.badge.rejected{border-color:rgba(220,38,38,.25); color:#991b1b}

/* =========================
   SUBNAV
========================= */

.subnav{
  margin-top:16px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.subnav-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.72);
  color:var(--text);
  font-weight:600;
}

.subnav-link:hover{
  border-color:rgba(79,70,229,.22);
  background:rgba(255,255,255,.92);
}

.subnav-link.is-active{
  background:linear-gradient(180deg, rgba(79,70,229,.95), rgba(79,70,229,.78));
  border-color:rgba(79,70,229,.45);
  color:#fff;
}

/* =========================
   APP-SPECIFIC LAYOUT
========================= */

.app-shell{
  grid-column:1 / -1;
  width:100%;
  display:flex;
  flex-direction:column;
  gap:14px;
  align-items:center;
}

.app-shell .app-back{
  width:100%;
  max-width:760px;
}

.app-shell .app-main-card{
  width:100%;
  max-width:760px;
}

.app-title-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:10px;
}

.app-meta{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:10px;
}

.app-form{
  display:grid;
  gap:14px;
  margin-top:16px;
}

.app-submit{
  min-height:54px;
  font-size:18px;
}

.chat-box{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-top:18px;
  margin-bottom:18px;
}

.msg{
  max-width:min(82%, 560px);
  padding:12px 14px;
  border-radius:16px;
  border:1px solid var(--line);
  white-space:pre-wrap;
  word-break:break-word;
  line-height:1.45;
}

.msg.user{
  align-self:flex-end;
  background:rgba(79,70,229,.10);
  border-color:rgba(79,70,229,.18);
}

.msg.admin{
  align-self:flex-start;
  background:rgba(255,255,255,.92);
}

.msg-meta{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  margin-bottom:6px;
  font-size:12px;
  color:var(--muted);
}

.app-empty{
  padding:18px;
  border:1px dashed var(--line);
  border-radius:14px;
  color:var(--muted);
  background:rgba(255,255,255,.42);
}

.app-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.app-actions .btn{
  min-height:48px;
}

/* =========================
   TIMER PILL
========================= */

#global-timer-pill{
  min-width:132px;
  justify-content:center;
}

#global-timer-display{
  font-variant-numeric: tabular-nums;
}

/* =========================
   POPUPS
========================= */

.thread-alert-overlay{
  position:fixed;
  inset:0;
  z-index:2147483647;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:rgba(15,23,42,.78);
  pointer-events:auto;
  -webkit-backdrop-filter:none;
  backdrop-filter:none;
}

.thread-alert-overlay[hidden]{
  display:none !important;
}

.thread-alert-box{
  position:relative;
  z-index:2147483647;
  width:min(760px,94vw);
  min-height:240px;
  background:rgba(255,255,255,.99);
  border:1px solid rgba(15,23,42,.12);
  border-radius:24px;
  box-shadow:0 30px 80px rgba(15,23,42,.34);
  padding:30px;
  text-align:center;
  pointer-events:auto;
}

.thread-alert-box-sos{
  border-color:rgba(220,38,38,.22);
  background:rgba(255,250,250,.99);
}

.thread-alert-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 14px;
  border-radius:999px;
  border:1px solid rgba(79,70,229,.20);
  background:rgba(79,70,229,.08);
  color:#3730a3;
  font-size:13px;
  font-weight:700;
  margin-bottom:18px;
}

.thread-alert-badge-sos{
  border-color:rgba(220,38,38,.24);
  background:rgba(220,38,38,.08);
  color:#991b1b;
}

.thread-alert-title{
  font-size:30px;
  line-height:1.2;
  font-weight:800;
  margin-bottom:12px;
}

.thread-alert-meta{
  font-size:16px;
  color:var(--muted);
}

.thread-alert-actions,
.thread-alert-actions *{
  pointer-events:auto !important;
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}

.thread-alert-initial-message{
  margin-top:6px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.78);
  color:var(--text);
  white-space:pre-wrap;
  word-break:break-word;
}

/* =========================
   MOBILE
========================= */

@media (max-width:768px){
  .container{
    padding:14px 12px 40px;
  }

  .topbar{
    flex-direction:column;
    align-items:flex-start;
  }

  .userbox{
    width:100%;
    justify-content:space-between;
  }

  .brand img{
    width:46px;
    height:46px;
    flex:0 0 46px;
  }

  .app-shell .app-back,
  .app-shell .app-main-card{
    max-width:100%;
  }

  .msg{
    max-width:90%;
  }

  .thread-alert-box{
    width:min(94vw, 94vw);
    padding:22px;
  }

  .thread-alert-title{
    font-size:24px;
  }
}