/* =========================================================
   0) BIẾN & RESET CƠ BẢN (mobile-first)
   ========================================================= */
:root {
  /* màu nền/chữ */
  --bg: #0f1115;
  --panel: #171a22;
  --panel-2: #1e222b;
  --text: #e6eaf2;
  --muted: #9aa3b2;

  /* màu chủ đạo & trạng thái */
  --primary: #4f67ff;
  --primary-2: #4153d9;
  --danger: #ef4444;
  --danger-2: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;

  /* viền/bo/shadow */
  --border: #2a2f3a;
  --radius: 18px;
  --shadow: 0 14px 40px rgba(0, 0, 0, .10);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, .18);
  --focus: 0 0 0 3px rgba(79, 103, 255, .35);

  /* app bg */
  --app-bg: linear-gradient(180deg, #0e1116, #0b0d11 60%, #090b0f);

  /* input/bảng */
  --input-bg: #0f131a;
  --thead-from: #1a1f27;
  --thead-to: #171b23;
  --thead-text: #cfd7e6;
  --row-hover: #141923;
  --row-alt: #131821;

  /* header & alert */
  --header-bg: rgba(15, 17, 21, .75);
  --alert-bg: rgba(239, 68, 68, .12);
  --alert-border: rgba(239, 68, 68, .35);
  --alert-text: #fecaca;

  /* scrollbar & khoảng đáy */
  --scroll-thumb: rgba(120, 120, 120, .65);
  --scroll-track: rgba(0, 0, 0, .08);
  --page-bottom-gap: 24px;

  /* UA controls theo theme */
  color-scheme: dark;
}

/* Dark tinh chỉnh scrollbar */
[data-theme="dark"] {
  --scroll-thumb: rgba(180, 180, 180, .7);
  --scroll-track: rgba(255, 255, 255, .1);
}

* {
  box-sizing: border-box
}

html {
  min-height: 100%;
  background: var(--app-bg)
}

body {
  margin: 0;
  min-height: 97svh;
  background: transparent;
  color: var(--text);
  font-family: Calibri, "Segoe UI", Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none
}

img {
  max-width: 100%;
  display: block
}

/* =========================================================
   1) LAYOUT CHUNG
   ========================================================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  min-height: 97svh;
  padding-bottom: var(--page-bottom-gap);
}

.container.login-center {
  max-width: 720px
}

.container-center {
  max-width: 1280px;
  margin: 30px auto;
  padding: 22px
}

.centered {
  width: min(720px, 100%);
  margin: 0 auto
}

/* Card */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card.table-page {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0
}

.card .title {
  margin: 6px 0 14px;
  font-size: 19px;
  font-weight: 700
}

/* Header */
header.top {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header-bg);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  margin: -22px -22px 22px;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  overflow: hidden;
  color: #fff;
  /* luôn trắng */
}

header.top .who {
  font-size: 19px
}

header.top .logo {
  justify-self: center
}

header.top .logo img {
  max-height: 79px;
  height: auto;
  width: auto
}

.top .main-nav {
  justify-self: end;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap
}

/* mọi phần tử trong header ăn theo màu trắng */
header.top a,
header.top button,
header.top .btn {
  color: inherit
}

header.top svg {
  stroke: currentColor;
  fill: currentColor
}

/* Toolbar & Pager */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: -6px 0 14px
}

.pager {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  flex-wrap: wrap;
}

.pager .page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px
}

.pager .goto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px
}

/* Alerts & helper text */
.alert {
  background: var(--alert-bg);
  border: 1px solid var(--alert-border);
  color: var(--alert-text);
  padding: 12px 14px;
  border-radius: 12px;
  margin: 10px 0 18px;
}

.notice {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px
}

/* =========================================================
   2) NÚT & FORM
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: .18s ease all;
  box-shadow: var(--shadow-soft);
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05)
}

.btn:active {
  transform: translateY(0)
}

.btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color: #fff
}

.btn.danger {
  background: linear-gradient(180deg, var(--danger), var(--danger-2));
  border-color: transparent;
  color: #fff
}

.btn.ghost {
  background: transparent;
  border-color: var(--border)
}

.btn.edit {
  background: linear-gradient(180deg, #34d399, #10b981);
  border-color: transparent;
  color: #fff
}

.btn.w100 {
  width: 100%
}

.btn.pill {
  border-radius: 9999px
}

.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 13px
}

.btn.slim {
  height: 32px;
  padding: 0 10px;
  border-radius: 10px
}

/* tiny button – dùng chung, không ghi đè lại ở dưới */
.btn.tiny {
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: 9999px;
  box-shadow: none;
}

/* nút nhỏ gọn trong pager */
.pager .btn {
  height: 32px;
  border-radius: 9999px
}

.form {
  display: grid;
  gap: 1px;
  height: 97%;
}

.row {
  display: grid;
  gap: 8px
}

.row label {
  font-size: 13px;
  color: var(--muted)
}

input:not([type]),
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  transition: border-color .18s, box-shadow .18s, transform .12s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), var(--shadow-soft);
}

textarea {
  min-height: 120px;
  padding: 10px 12px;
  line-height: 1.45;
  resize: vertical
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(79, 103, 255, .55)
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--focus), inset 0 1px 0 rgba(255, 255, 255, .06)
}

input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(220px, 1fr))
}

.find-form input[type="text"] {
  height: 44px;
  border-radius: 9999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 8px 20px rgba(0, 0, 0, .06);
}

/* Radio trong form tìm Sửa/Xoá/Admin */
.find-form .row label {
  font-size: 15px
}

.find-form .row label>input[type="radio"] {
  width: 18px;
  height: 18px;
  margin-right: 6px
}

/* Combo chọn ngày cho trang thêm/sửa */
.date-combo {
  display: grid;
  grid-template-columns: 1fr max-content;
  gap: 8px;
  align-items: center;
}

.date-combo input[type="date"] {
  height: 38px;
  padding: 0 10px;
  padding-right: 40px;
  border-radius: var(--radius);
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text)
}

/* =========================================================
   3) BẢNG & VÙNG CUỘN
   ========================================================= */
.table-wrap {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: auto;
  flex: 0 0 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

.card.table-page .table-wrap {
  flex: 1 1 auto
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel)
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, var(--thead-from), var(--thead-to));
  font-weight: 700;
  color: var(--thead-text);
}

tbody tr:hover {
  background: var(--row-hover)
}

tbody tr:nth-child(even) {
  background: var(--row-alt)
}

td .btn {
  height: 30px;
  padding: 0 10px
}

/* WebKit scrollbar */
.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px
}

.table-wrap::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 8px
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.table-wrap::-webkit-scrollbar-corner {
  background: transparent
}

/* =========================================================
   4) ĐĂNG NHẬP
   ========================================================= */
body.auth-guest {
  min-height: 97svh
}

.auth-guest .login-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 22px
}

.login-card .title {
  margin: 6px 0 18px
}

.login-card .row {
  display: grid;
  gap: 8px;
  margin-bottom: 14px
}

.login-card input[type="text"],
.login-card input[type="password"] {
  height: 44px;
  padding: 0 14px
}

.pwd {
  display: flex;
  align-items: center;
  gap: 6px
}

.pwd input {
  flex: 1
}

.pwd .eye {
  border: 1px solid var(--border);
  background: var(--input-bg);
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer
}

.login-card .pwd .eye {
  height: 44px;
  width: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px
}

.login-card .btn[type="submit"] {
  height: 44px;
  margin-top: 16px;
  font-weight: 600
}

/* =========================================================
   5) PICK TABLE (dropdown)
   ========================================================= */
.pick-table {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 8px
}

.pick-table select {
  min-width: 260px
}

/* =========================================================
   6) TIỆN ÍCH & ICON BUTTON
   ========================================================= */
.center {
  text-align: center
}

.hidden {
  display: none
}

.muted {
  color: var(--muted)
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px
}

.card+.card {
  margin-top: 18px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px
}

.btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap
}

.ml8 {
  margin-left: 8px
}

.inline {
  display: inline
}

.simple-list {
  list-style: none;
  padding: 0;
  margin: 10px 0;
  display: grid;
  gap: 8px
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace
}

.pwd-mask {
  letter-spacing: .8px
}

.col-func {
  display: inline-flex;
  align-items: center;
  gap: 6px
}

/* Icon button */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  width: 24px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .08);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  box-shadow: var(--shadow-soft);
  transition: .18s ease all;
  line-height: 0;
}

.icon-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08)
}

.icon-btn:active {
  transform: translateY(0)
}

.icon-btn .ico {
  width: 16px;
  height: 16px;
  display: block
}

/* =========================================================
   7) OVERLAY / MODAL
   ========================================================= */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 99
}

.overlay.open {
  display: flex
}

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
}

.modal-title {
  margin: 0 0 10px;
  font-size: 18px
}

.modal-body {
  color: var(--text)
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px
}

.input-copy {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text)
}

.big-pwd {
  font-size: 16px
}

/* =========================================================
   8) IMPORT CSV (Dropzone)
   ========================================================= */
.hidden-input {
  display: none
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 16px;
  margin: 12px 0;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: .18s ease all;
  box-shadow: var(--shadow-soft);
}

.dropzone:hover {
  filter: brightness(1.03)
}

.dropzone.drag {
  border-color: var(--primary);
  box-shadow: var(--focus);
  color: var(--text)
}

.dropzone.error {
  border-color: var(--danger);
  background: rgba(239, 68, 68, .08);
  color: var(--alert-text)
}

.dropzone:focus {
  outline: none;
  box-shadow: var(--focus);
  border-color: var(--primary)
}

/* =========================================================
   9) THEME SÁNG
   ========================================================= */
html[data-theme="light"] {
  --panel: #fff;
  --panel-2: #f3f4f6;
  --text: #0f172a;
  --muted: #475569;
  --border: #e5e7eb;
  --shadow: 0 8px 24px rgba(0, 0, 0, .08);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, .06);
  --focus: 0 0 0 3px rgba(65, 83, 217, .25);
  --app-bg: linear-gradient(180deg, #f8fbff, #f3f6fb 60%, #eef2f7);
  --input-bg: #fff;
  --thead-from: #f9fafb;
  --thead-to: #f3f4f6;
  --thead-text: #0f172a;
  --row-hover: #f6f7fb;
  --row-alt: #fbfcfe;
  --header-bg: rgba(30, 112, 183, .85);
  --alert-bg: #fff1f2;
  --alert-border: #fecaca;
  --alert-text: #b91c1c;
  color-scheme: light;
}

html[data-theme="light"] body {
  background: transparent
}

html[data-theme="light"] thead th {
  background: linear-gradient(180deg, #f7f8fb, #f1f3f7);
  color: #0f172a
}

html[data-theme="light"] .icon-btn {
  background: #f3f4f6;
  color: #0f172a;
  border-color: #e5e7eb
}

/* =========================================================
   10) BREAKPOINTS — PC/TABLET/MOBILE
   ========================================================= */

/* --- PC ≥1025px (ghi đè nhẹ cho bố cục rộng) --- */
@media (min-width:1025px) {
  header.top {
    padding: 12px 22px;
    margin: -22px -22px 22px
  }

  .container {
    padding: 22px
  }

  .btn {
    height: 36px;
    padding: 0 14px
  }

  .date-combo input[type="date"] {
    height: 38px
  }
}

/* --- Tablet ≤1024px --- */
@media (max-width:1024px) {
  .top .main-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: end;
    gap: 8px
  }

  header.top {
    padding: 10px 16px;
    margin: -18px -18px 18px
  }

  header.top .logo img {
    max-height: 60px
  }

  .card {
    padding: 16px;
  }

  .btn {
    height: 36px;
    padding: 0 12px
  }

  th,
  td {
    padding: 9px 10px
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(200px, 1fr))
  }

  .pager {
    gap: 8px
  }

  .pager .goto input[type="number"] {
    height: 32px;
    width: 72px;
    padding: 0 8px
  }

  .pager .page-size select {
    height: 32px
  }

  .dropzone {
    min-height: 130px
  }
}

/* --- Mobile ≤640px --- */
@media (max-width:640px) {
  :root {
    --radius: 12px
  }

  .container {
    padding: 14px
  }

  header.top {
    grid-template-columns: 1fr;
    row-gap: 8px;
    padding: 8px 12px;
    margin: -14px -14px 14px;
  }

  header.top .logo {
    order: 1;
    justify-self: center
  }

  header.top .who {
    order: 2;
    justify-self: center;
    text-align: center
  }

  .top .main-nav {
    order: 3;
    justify-self: center;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
    width: 100%;
  }

  header.top .logo img {
    max-height: 48px
  }

  .card {
    padding: 14px
  }

  .toolbar {
    gap: 6px;
    flex-wrap: wrap
  }

  .btn {
    height: 34px;
    padding: 0 10px;
    border-radius: 10px
  }

  table {
    font-size: 13px
  }

  th,
  td {
    padding: 8px 9px;
    white-space: nowrap
  }

  .table-wrap {
    border-radius: 10px
  }

  .form-grid {
    grid-template-columns: 1fr
  }

  input:not([type]),
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    height: 44px;
    padding: 0 12px;
    font-size: 15px
  }

  input[type="radio"],
  input[type="checkbox"] {
    width: 18px;
    height: 18px
  }

  .pager {
    gap: 6px
  }

  .pager .btn {
    height: 32px
  }

  .pager .page-size label {
    display: none
  }

  .pager .page-size select {
    height: 32px
  }

  .pager .goto {
    gap: 4px
  }

  .pager .goto input[type="number"] {
    width: 64px;
    height: 32px;
    padding: 0 8px
  }

  /* Dropdown “Chọn Bảng” ngắn lại */
  .pick-table {
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: center
  }

  .pick-table select {
    min-width: 0;
    width: clamp(170px, 58vw, 230px)
  }

  .pick-table .btn {
    flex: 0 0 auto
  }

  .dropzone {
    min-height: 140px
  }

  .date-combo input[type="date"] {
    height: 44px
  }
}

/* --- Rất nhỏ ≤360px --- */
@media (max-width:360px) {
  .btn {
    height: 32px;
    padding: 0 8px
  }

  .pager .goto input[type="number"] {
    width: 56px
  }

  th,
  td {
    padding: 7px 8px
  }
}

/* Bổ sung: đảm bảo tương phản tốt ở header khi dùng theme sáng */
html[data-theme="light"] header.top .btn.ghost {
  border-color: rgba(255, 255, 255, .35);
}

html[data-theme="light"] header.top .icon-btn {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .35);
  color: #fff;
}

/* =========================
   PATCH — Date input: icon luôn hiển thị, vẫn bấm mở lịch
   (đặt ở cuối file)
   ========================= */

/* Nút rất nhỏ (dùng cho form tìm kiếm ID giới hạn IP) */
.btn.chip {
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: 9999px;
  box-shadow: none;
  /* bỏ shadow cho đỡ “to” */
}

.find-form .btn.chip {
  box-shadow: none;
}

/* Hàng tìm ID trong trang giới hạn IP */
.rl-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rl-filter-row label {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* Ô nhập ID nhỏ gọn */
.rl-filter-row input[type="text"],
.rl-filter-row input {
  width: 160px;
  max-width: 100%;
}

/* Nút Tìm / Xoá lọc không bị kéo dài */
.rl-filter-row .btn {
  flex: 0 0 auto;
  min-width: 0;
}

/* ===== Log page ===== */

.card.log-page {
  width: 100%;
  max-width: 100%;
}

/* Log page chung */
.log-page .log-wrap {
  overflow: auto;
}

/* Bảng log License Server */
.log-page .log-table-license {
  table-layout: fixed;
}

/* Bảng log WebServer (IP + UA + Thao tác) */
.log-page .log-table-web {
  table-layout: fixed;
}

/* Alert thành công khi block */
.alert.success {
  background: #e0f7e9;
  color: #166534;
}

/* ===== Log pages ===== */
.log-wrap {
  /* vẫn cho scroll dọc, hạn chế scroll ngang */
  overflow-x: hidden;
}

/* Bảng log nói chung */
.log-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

/* License Server log */
.log-table-license th,
.log-table-license td {
  font-size: 13px;
}

/* 1) ID */
.log-table-license th:nth-child(1),
.log-table-license td:nth-child(1) {
  width: 70px;
}

/* 2) Tên */
.log-table-license th:nth-child(2),
.log-table-license td:nth-child(2) {
  width: 150px;
}

/* 3) DB */
.log-table-license th:nth-child(3),
.log-table-license td:nth-child(3) {
  width: 140px;
}

/* 4) Key – cắt bớt, hover vào xem full qua title */
.log-table-license th:nth-child(4),
.log-table-license td:nth-child(4) {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 5) Thời gian */
.log-table-license th:nth-child(5),
.log-table-license td:nth-child(5) {
  width: 170px;
}

/* 6) Thao tác – nhỏ gọn, không bị tràn */
.log-table-license th:nth-child(6),
.log-table-license td:nth-child(6) {
  width: 80px;
  text-align: center;
  white-space: nowrap;
}

/* =========================================================
   LOG TABLES – style chung (không lặp lại inline style)
   ========================================================= */

/* Cell ellipsis dùng chung */
.cell-ellipsis {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Cell action dùng chung (nút Block/Gỡ, ... ) */
.cell-actions {
  text-align: center;
  white-space: nowrap;
}

/* ---------- Log License ---------- */

.log-table-license col.log-col-id {
  width: 90px;
}

.log-table-license col.log-col-name {
  width: 160px;
}

.log-table-license col.log-col-db {
  width: 160px;
}

.log-table-license col.log-col-key {
  width: auto;
}

.log-table-license col.log-col-time {
  width: 170px;
}

.log-table-license col.log-col-actions {
  width: 90px;
}

/* ---------- Log Web (Caddy) ---------- */

.log-table-web col.log-web-col-ip {
  width: 130px;
}

.log-table-web col.log-web-col-ua {
  width: auto;
}

.log-table-web col.log-web-col-time {
  width: 170px;
}

.log-table-web col.log-web-col-actions {
  width: 120px;
}

/* =========================================================
   RATELIMIT ADMIN – Bảng Giới Hạn IP
   ========================================================= */

/* Bảng trong trang Giới Hạn IP */
.rl-table-wrap table {
  width: 100%;
  table-layout: fixed;
  /* đảm bảo chia cột theo width */
}

/* ID, IP, Vi phạm, Timeout, Thao tác – cột hẹp hơn */
.rl-table-wrap thead th:nth-child(1),
.rl-table-wrap tbody td:nth-child(1) {
  width: 80px;
  /* ID */
}

.rl-table-wrap thead th:nth-child(2),
.rl-table-wrap tbody td:nth-child(2) {
  width: 130px;
  /* IP */
}

.rl-table-wrap thead th:nth-child(4),
.rl-table-wrap tbody td:nth-child(4) {
  width: 90px;
  /* Vi phạm */
}

.rl-table-wrap thead th:nth-child(5),
.rl-table-wrap tbody td:nth-child(5) {
  width: 110px;
  /* Timeout (giây) */
}

.rl-table-wrap thead th:nth-child(6),
.rl-table-wrap tbody td:nth-child(6) {
  width: 90px;
  /* Thao tác */
}

/* Cột User Agent rộng, ưu tiên chiếm phần còn lại */
.rl-table-wrap thead th:nth-child(3),
.rl-table-wrap tbody td:nth-child(3) {
  width: auto;
}

/* =========================
   GIỚI HẠN IP – CỘT USER AGENT (FINAL)
   ========================= */

/* UA + nút "Xem hết" trên cùng một hàng, dùng full chiều ngang cột */
.rl-table-wrap .ua-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

/* Text UA */
.rl-table-wrap .ua-cell {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.3;
  overflow: hidden;
}

/* Trạng thái thu gọn: 1 dòng + ellipsis + hiệu ứng mờ */
.rl-table-wrap .ua-cell.is-collapsed {
  white-space: nowrap;
  text-overflow: ellipsis;
  position: relative;
}

.rl-table-wrap .ua-cell.is-collapsed::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 45%;
  height: 1.3em;
  background: linear-gradient(to left, var(--panel), transparent);
}

/* Khi bấm "Xem hết" → JS đổi sang .is-expanded, text dùng full chiều ngang cột */
.rl-table-wrap .ua-cell.is-expanded {
  white-space: normal;
  word-break: break-word;
}

/* Nút "Xem hết" / "Thu gọn" */
.rl-table-wrap .toggle-ua {
  flex: 0 0 auto;
  white-space: nowrap;
  padding-inline: 8px;
  font-size: 11px;
}

/* Một chút tinh chỉnh trên mobile: giảm width các cột nhỏ thêm 1 chút */
@media (max-width: 768px) {

  .rl-table-wrap thead th:nth-child(1),
  .rl-table-wrap tbody td:nth-child(1) {
    width: 60px;
  }

  .rl-table-wrap thead th:nth-child(2),
  .rl-table-wrap tbody td:nth-child(2) {
    width: 100px;
  }

  .rl-table-wrap thead th:nth-child(4),
  .rl-table-wrap tbody td:nth-child(4) {
    width: 70px;
  }

  .rl-table-wrap thead th:nth-child(5),
  .rl-table-wrap tbody td:nth-child(5) {
    width: 90px;
  }

  .rl-table-wrap thead th:nth-child(6),
  .rl-table-wrap tbody td:nth-child(6) {
    width: 80px;
  }
}

/* =========================
   GIỚI HẠN IP – BẢNG CHÍNH
   ========================= */

/* Căn giữa các cột số liệu cho gọn */
.rl-table-wrap th:nth-child(4),
.rl-table-wrap th:nth-child(5),
.rl-table-wrap th:nth-child(6),
.rl-table-wrap td:nth-child(4),
.rl-table-wrap td:nth-child(5),
.rl-table-wrap td:nth-child(6) {
  text-align: center;
}

/* Fallback: nếu JS bị lỗi, vẫn có max-height hợp lý */
.rl-table-wrap {
  max-height: 70vh;
  overflow: auto;
}

/* =========================
   GIỚI HẠN IP – TAB LOG
   ========================= */

/* Hàng tab log ở trên cùng */
.log-page .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Các nút tab (License Server / Admin Web / Giới Hạn IP) */
.log-page .toolbar .log-src {
  min-width: 130px;
  text-align: center;
  font-weight: 500;
}

/* Tab đang active cho dễ nhìn hơn */
.log-page .toolbar .log-src.active {
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.18);
}

/* Riêng tab Giới Hạn IP (class danger) khi active cho đỏ rõ hơn */
.log-page .toolbar .btn.danger.log-src.active {
  background: var(--danger);
  border-color: var(--danger-2);
  color: #fff;
}

/* Chừa chỗ cho icon và gắn icon như background của input */
input[type="date"] {
  padding-right: 40px;
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 18px 18px;
  /* icon trắng cho dark mode */
  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E6EAF2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'>\
<rect x='3' y='4' width='18' height='18' rx='3' ry='3'/>\
<line x1='16' y1='2' x2='16' y2='6'/>\
<line x1='8' y1='2' x2='8' y2='6'/>\
<line x1='3' y1='10' x2='21' y2='10'/>\
</svg>");
}

/* Light mode: icon đậm để nổi trên nền sáng */
html[data-theme="light"] input[type="date"] {
  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230F172A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'>\
<rect x='3' y='4' width='18' height='18' rx='3' ry='3'/>\
<line x1='16' y1='2' x2='16' y2='6'/>\
<line x1='8' y1='2' x2='8' y2='6'/>\
<line x1='3' y1='10' x2='21' y2='10'/>\
</svg>");
}

/* Giữ indicator gốc để click mở lịch, nhưng ẩn hoàn toàn hình/viền của nó */
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  /* ẩn nhưng vẫn nhận click */
  width: 36px;
  height: 100%;
  margin-right: 4px;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0;
}