:root{
  --bg:#ffffff;
  --border:#e6e8ee;
  --text:#101828;
  --muted:#667085;
  --accent:#2563eb;
  --danger:#dc2626;
  --card:#ffffff;

  /* ===== D2 PATCH: global sizing ===== */
  --page-pad: 16px;
  --content-max: 100%;
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

*{ box-sizing:border-box; }

html, body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans Thai", Arial;
  color:var(--text);
  background:var(--bg);
}

/* ===== topbar ===== */
.topbar{
  height:var(--topbar-h);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 var(--page-pad);
  border-bottom:1px solid var(--border);
  background:#fff;
  position:sticky;
  top:0;
  z-index:10;
}

.brand{
  font-weight:700;
  letter-spacing:.2px;
}

.topbar-right{
  display:flex;
  gap:10px;
  align-items:center;
}

/* ===== layout ===== */
.layout{
  display:grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-h));
}

/* ===== sidebar base only =====
   D2 FULL BUILD 2026-03-17F
   - ดูแลเฉพาะ layout/container
   - ไม่ทับ .nav / .nav:hover / .nav.active ใน base.html
*/
.sidebar{
  border-right:1px solid var(--border);
  padding:12px;
  background:#fff;
  position:sticky;
  top:var(--topbar-h);
  align-self:start;
  height: calc(100vh - var(--topbar-h));
  overflow:auto;
}

.nav-sep{
  height:12px;
}

.nav-title{
  font-size:12px;
  color:var(--muted);
  margin:6px 8px;
}

/* ===== generic nav outside sidebar only ===== */
body > .nav,
.content .nav,
.card .nav,
.panel .nav,
.item .nav{
  display:block;
  padding:10px 10px;
  border-radius:10px;
  color:var(--text);
  text-decoration:none;
  border:1px solid transparent;
}

body > .nav:hover,
.content .nav:hover,
.card .nav:hover,
.panel .nav:hover,
.item .nav:hover{
  border-color:var(--border);
  background:#fafafa;
}

/* ===== content ===== */
.content{
  padding: var(--page-pad);
  max-width: var(--content-max);
  width:100%;
  min-width:0;
}

/* ===== card ===== */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
}

/* ===== login center ===== */
.card-login{
  width:min(420px, 92vw);
}

.center{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:100vh;
}

.row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  margin-top:10px;
}

.lbl{
  display:block;
  margin-top:10px;
  font-size:13px;
  color:var(--muted);
}

/* ===== inputs ===== */
.input{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:10px;
  outline:none;
  background:#fff;
}

.input:focus{
  border-color:#c7d2fe;
  box-shadow:0 0 0 3px rgba(37,99,235,.08);
}

.input--sm{
  padding:7px 10px;
  font-size:13px;
  border-radius:10px;
}

/* ===== buttons ===== */
.btn{
  padding:10px 12px;
  border-radius:10px;
  border:1px solid var(--accent);
  background:var(--accent);
  color:#fff;
  cursor:pointer;
}

.btn:hover{
  filter:brightness(.98);
}

.btn--ghost{
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
}

.btn--danger{
  border:1px solid var(--danger);
  background:var(--danger);
}

.btn--ok{
  background:rgba(40, 160, 90, .28);
  border:1px solid rgba(40,255,160,.35);
}

.btn--ok:hover{
  filter:brightness(1.08);
}

.btn--danger:hover{
  filter:brightness(1.08);
}

/* ===== links ===== */
.link{
  color:var(--accent);
  text-decoration:none;
}

.link:hover{
  text-decoration:underline;
}

.muted{
  color:var(--muted);
  font-size:13px;
}

.big{
  font-size:22px;
  font-weight:700;
  margin-top:6px;
}

/* ===== tables ===== */
.table-wrap{
  overflow:auto;
  border:1px solid var(--border);
  border-radius:12px;
  width:100%;
  max-width:100%;
}

.table{
  width:100%;
  border-collapse:collapse;
  min-width:1100px;
}

.table th,
.table td{
  padding:10px;
  border-bottom:1px solid var(--border);
  text-align:left;
  vertical-align:middle;
  white-space:nowrap;
}

.table thead th{
  background:#fafafa;
  font-size:13px;
  color:var(--muted);
  font-weight:600;
  position:sticky;
  top:0;
  z-index:1;
}

/* ===== flash ===== */
.flash-wrap{
  margin-bottom:10px;
}

.flash{
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fafafa;
}

.flash-error{
  border-color:#fecaca;
  background:#fff5f5;
}

.flash-success{
  border-color:#bbf7d0;
  background:#f0fdf4;
}

/* ===== chips ===== */
.chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  border:1px solid rgba(255,255,255,.16);
  background:#fff;
}

.chip-ok{
  background: rgba(40, 160, 90, .22);
  border-color: rgba(40, 255, 160, .35);
}

.chip-warn{
  background: rgba(200, 180, 40, .22);
  border-color: rgba(255, 235, 80, .35);
}

.chip-high{
  background: rgba(210, 120, 30, .22);
  border-color: rgba(255, 170, 60, .35);
}

.chip-bad{
  background: rgba(190, 40, 70, .22);
  border-color: rgba(255, 80, 120, .35);
}

.chip-muted{
  background: rgba(120,120,120,.18);
  border-color: rgba(255,255,255,.16);
}

/* ===== panels / grids ===== */
.grid2{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.panel{
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  background:#fff;
}

/* ===== map ===== */
.map{
  height:min(70vh, 760px);
  border:1px solid var(--border);
  border-radius:12px;
  margin-top:12px;
}

.page--map .content{
  padding:0;
}

.page--map .card{
  border:none;
  border-radius:0;
  padding:0;
}

.page--map .map,
.page--map #map{
  height: calc(100vh - var(--topbar-h));
  margin-top:0;
  border:none;
  border-radius:0;
}

/* ===== lists ===== */
.list{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.item{
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
  background:#fff;
}

.item .title{
  font-weight:700;
}

.item .sub{
  color:var(--muted);
  font-size:13px;
  margin-top:4px;
}

.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono";
}

/* ===== logout ===== */
.link-logout{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 12px;
  border-radius:10px;
  background:#ffe4ec;
  color:#334155;
  font-size:13px;
  font-weight:600;
  text-decoration:none;
  transition:
    background .15s ease,
    transform .08s ease,
    box-shadow .12s ease;
}

.link-logout:hover{
  background:#ffd6e4;
  box-shadow:0 4px 10px rgba(0,0,0,.08);
}

/* ===== login form center button ===== */
.card-login form{
  display:flex;
  flex-direction:column;
}

.card-login .btn{
  margin:18px auto 0 auto;
  min-width:140px;
}

/* ===== responsive ===== */
@media (max-width: 980px){
  .layout{
    grid-template-columns:1fr;
  }

  .sidebar{
    position:relative;
    top:0;
    height:auto;
    border-right:none;
    border-bottom:1px solid var(--border);
  }
}


/* =========================================================
   SmartSchool Admin: Users
   หน้า /admin/smartschool/users
   ========================================================= */

.ss-page-note {
  margin: 6px 0 0;
  color: #64748b;
  line-height: 1.65;
}

.ss-card {
  padding: 22px;
  margin-bottom: 20px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,250,252,.96));
  box-shadow: 0 18px 45px rgba(15, 23, 42, .08);
}

.ss-card h3 {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -.01em;
  color: #0f172a;
}

.ss-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 16px;
  align-items: end;
}

.ss-form-grid > div {
  min-width: 0;
}

.ss-form-grid label {
  display: block;
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 800;
  color: #334155;
}

.ss-form-grid .text-muted {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
}

.ss-form-grid .form-control,
.ss-form-grid input,
.ss-form-grid select {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: #ffffff;
  color: #0f172a;
  font: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.ss-form-grid select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

.ss-form-grid .form-control:focus,
.ss-form-grid input:focus,
.ss-form-grid select:focus {
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.ss-form-grid .form-control::placeholder,
.ss-form-grid input::placeholder {
  color: #94a3b8;
}

.ss-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  align-items: center;
}

.ss-actions form {
  margin: 0;
}

.ss-actions .btn,
.ss-form-grid .btn {
  min-height: 40px;
  border-radius: 13px;
  font-weight: 800;
}

.ss-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

.ss-table thead th {
  background: #f1f5f9;
  color: #334155;
  font-size: 13px;
  font-weight: 850;
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.ss-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
}

.ss-table tbody tr:hover {
  background: #f8fafc;
}

.ss-table code {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef6ff;
  color: #1d4ed8;
  font-weight: 800;
}

.ss-table-empty {
  text-align: center;
  color: #64748b;
  padding: 22px;
}

.ss-status-on,
.ss-status-off {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 54px;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.ss-status-on {
  color: #047857;
  background: #d1fae5;
}

.ss-status-off {
  color: #b91c1c;
  background: #fee2e2;
}

.ss-btn-danger {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.ss-btn-danger:hover {
  background: #ffe4e6;
  color: #9f1239;
}

@media (max-width: 720px) {
  .ss-card {
    padding: 16px;
    border-radius: 18px;
  }

  .ss-form-grid {
    grid-template-columns: 1fr;
  }

  .ss-actions {
    gap: 7px;
  }

  .ss-table thead {
    display: none;
  }

  .ss-table,
  .ss-table tbody,
  .ss-table tr,
  .ss-table td {
    display: block;
    width: 100%;
  }

  .ss-table tbody tr {
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 10px;
    margin-bottom: 12px;
    background: #fff;
  }

  .ss-table tbody td {
    border: 0;
    padding: 8px 6px;
  }
}


.ss-settings-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin: 10px 0 6px;
}

.ss-settings-box > div {
  padding: 14px;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  background: #eff6ff;
}

.ss-settings-label {
  display: block;
  margin-bottom: 6px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.ss-settings-box strong {
  display: block;
  color: #0f172a;
  font-size: 16px;
}

.ss-settings-box code {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff;
  color: #1d4ed8;
  font-weight: 800;
}


.ss-inline-form {
  display: inline-block;
  margin: 0;
}

.ss-inline-form .btn {
  white-space: nowrap;
}

