/* hub_manage.css */
:root { --gap:12px; --primary-color: #487564; --danger-color: #dc3545; --warning-bg: #fff3cd; }
html, body { max-width: 100%; overflow-x: hidden; font-family: sans-serif; }
*, *::before, *::after { box-sizing: border-box; }
.wrap { max-width: 1280px; margin: 12px auto; padding: 12px; width:100%; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
.card { background:#fff; border:1px solid #dee2e6; border-radius:12px; padding:14px; margin-bottom: var(--gap); }
h2 { margin:0 0 8px; font-size:1.25rem; }
h3 { margin:0 0 10px; font-size:1.1rem; display: flex; justify-content: space-between; align-items: center; }
.muted { color:#6c757d; font-size:.95rem; }
.form-row, .form-row-1, .form-row-3 { display:grid; gap: var(--gap); }
.form-row { grid-template-columns: 1fr; }
.form-row-1 { grid-template-columns: 1fr; }
label { font-weight:600; display:block; margin-bottom:6px; }
input[type="text"], input[type="search"], input[type="number"], input[type="email"], select, textarea { width:100%; padding:10px 12px; border:1px solid #ced4da; border-radius:10px; box-sizing:border-box; font-size:16px; }
textarea { min-height: 90px; }
.table { width:100%; border-collapse: collapse; }
.table th, .table td { border-bottom:1px solid #eee; padding:10px; vertical-align:top; font-size:14px; }
.table th { background:#f8f9fa; text-align:left; position:sticky; top:0; z-index:1; }
.table-wrapper { width:100%; overflow:auto; -webkit-overflow-scrolling:touch; border:1px solid #eee; border-radius:8px; }
.actions button { margin-right:6px; margin-bottom:6px; width:100%; }
.btn { padding:10px 12px; border:0; border-radius:10px; cursor:pointer; font-weight:700; font-size:15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;}
.btn-primary { background: var(--primary-color); color:#fff; }
.btn-danger  { background: var(--danger-color); color:#fff; }
.btn-secondary{ background:#6c757d; color:#fff; }
.btn-sm { padding: 6px 10px; font-size: 14px; }
.btn:disabled { background-color: #adb5bd; cursor: not-allowed; }
.flex { display:flex; gap:8px; flex-wrap: wrap; }
.flex > * { flex:1 1 140px; min-width:0; }
.hint { font-size:.9rem; color:#6c757d; }
.pill { display:inline-block; background:#e9ecef; border-radius:999px; padding:4px 10px; font-size:.85rem; margin-left:6px;}
.badge { display:inline-block; padding:3px 10px; border-radius:999px; background:#f1f3f5; font-size:.85rem;}
.badge.on { background:#d1e7dd; color:#0f5132; }
.badge.off{ background:#f8d7da; color:#842029; }
.note { font-size:.95rem; color:#495057; background:#f8f9fa; padding:10px; border-radius:8px; }
.hidden { display:none !important; }

/* Tabs */
.tab-nav { display: flex; gap: 4px; border-bottom: 2px solid #dee2e6; margin-bottom: var(--gap); }
.tab-button { background: #f8f9fa; border: 1px solid #dee2e6; border-bottom: none; padding: 10px 16px; border-radius: 8px 8px 0 0; cursor: pointer; font-weight: 600; color: #495057; }
.tab-button.active { background: #fff; border-bottom: 2px solid #fff; position: relative; top: 2px; color: var(--primary-color); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Sub Tabs */
.subtab-nav { display:flex; gap:6px; margin:8px 0 12px; border-bottom:1px dashed #dee2e6; }
.subtab-button { background:#f8f9fa; border:1px solid #dee2e6; padding:8px 12px; border-radius:8px 8px 0 0; cursor:pointer; font-weight:600; }
.subtab-button.active { background:#fff; border-bottom:2px solid #fff; color:var(--primary-color); }
.subtab-pane { display:none; }
.subtab-pane.active { display:block; }

.table-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.table-controls .search-box { width: 100%; max-width: 300px; }
.table tbody tr.is-editing { background-color: #fff3cd; }
.table tbody tr.is-editing td { font-weight: 600; }
.table tbody tr.expiring-soon { background-color: var(--warning-bg); }

/* small code font */
.codeish { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 13px; }

@media (min-width: 768px){ .grid-2 { grid-template-columns: 1.25fr 1fr; } .form-row { grid-template-columns: 1fr 1fr; } .actions button { width:auto; } .table-controls .search-box { width: auto; } }
@media (max-width: 420px){ .flex { gap:6px; } .flex > * { flex:1 1 100%; } .btn { width:100%; } }

/* กัน sticky header ล้นบริบท */
.table-wrapper { position: relative; }

/* ดันแท็บให้ลอยบนชั้นสูงกว่า table header/ของลอยอื่น ๆ */
.tab-nav { position: relative; z-index: 5; }

/* กันลากเลือกข้อความเวลาคลิก และชัดเจนตอน disable */
.tab-button { user-select: none; }
.tab-button[disabled] { pointer-events: none; opacity: .5; }

/* ย้ำกฎแสดง/ซ่อนเผื่อมี CSS อื่นแทรก */
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.subtab-pane { display: none; }
.subtab-pane.active { display: block; }