.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: rgba(30, 41, 59, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.18s;
}
.modal.hidden { display: none; }
.modal-dialog {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(15,23,42,0.18);
  min-width: 340px;
  max-width: 98vw;
  max-height: 92vh;
  overflow-y: auto;
  padding: 0;
  animation: modalIn 0.18s;
}
@keyframes modalIn {
  from { transform: translateY(32px) scale(0.98); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 8px 22px;
  border-bottom: 1px solid #e5e7eb;
}
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: #64748b;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.12s;
}
.modal-close:hover { background: #e5e7eb; color: #1d4ed8; }
.modal-body {
  padding: 18px 22px 22px 22px;
}
.wg-result-dialog {
  width: min(920px, 96vw);
}
.wg-result-body {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: start;
}
.wg-result-copy textarea {
  min-height: 288px;
  resize: vertical;
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.45;
}
.wg-result-actions {
  margin-top: 12px;
  justify-content: flex-start;
}
.wg-result-qr-panel {
  border: 1px solid #dbe5f1;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
  padding: 16px;
}
.wg-result-qr-panel strong {
  display: block;
  margin-bottom: 12px;
}
.link-result-dialog {
  width: min(1120px, 96vw);
}
.link-result-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.link-result-notice {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #bfdbfe;
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.5;
}
.link-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.link-result-card {
  border: 1px solid #dbe5f1;
  border-radius: 12px;
  background: #fff;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.link-result-card strong {
  display: block;
  font-size: 15px;
  color: #0f172a;
}
.link-result-card-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: #475569;
}
.link-result-card textarea {
  min-height: 260px;
  resize: vertical;
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.45;
}
.link-result-private label {
  font-size: 12px;
  color: #475569;
}
.link-result-private textarea {
  min-height: 72px;
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.45;
}
.link-result-actions {
  flex-wrap: wrap;
}
.field-help {
  margin: 10px 0 0;
  color: #475569;
  font-size: 12px;
  line-height: 1.5;
}
.wg-qr-code {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 316px;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #dbe5f1;
  overflow: auto;
}
.wg-qr-code svg {
  display: block;
  width: min(100%, 320px);
  height: auto;
}
.wg-result-meta {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #475569;
}
body { font-family: "IBM Plex Sans", "Segoe UI", sans-serif; margin: 0; background: linear-gradient(180deg, #eef4ff 0%, #f8fafc 52%, #f1f5f9 100%); color: #1f2937; }
nav { background: #0f172a; color: #fff; padding: 12px 20px; display: flex; gap: 14px; align-items: center; box-shadow: 0 4px 16px rgba(15, 23, 42, 0.2); }
nav button { background: transparent; border: 0; color: #cbd5e1; cursor: pointer; font-size: 14px; padding: 0; }
nav button.active, nav button:hover { color: #fff; }
main { max-width: 1240px; margin: 22px auto; padding: 0 16px; }
h1 { margin: 0 0 16px; letter-spacing: 0.2px; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 0; font-size: 16px; }
.card { background: #fff; border: 1px solid #dbe5f1; border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05); }
.ok { background: #ecfdf5; border: 1px solid #86efac; color: #166534; padding: 10px; border-radius: 8px; margin-bottom: 12px; }
.err { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; padding: 10px; border-radius: 8px; margin-bottom: 12px; }
.table-card { padding-bottom: 12px; }
.table-scroll { overflow-x: auto; overflow-y: hidden; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; }
.data-table { width: 100%; min-width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
th, td { border-bottom: 1px solid #e7edf5; text-align: left; padding: 10px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td { color: #334155; font-size: 13px; text-overflow: ellipsis; overflow: hidden; }
thead th { position: sticky; top: 0; z-index: 4; background: #f8fbff; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #0f172a; box-shadow: inset 0 -1px 0 #dbe5f1; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; position: sticky; top: 8px; z-index: 5; background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0.96) 100%); border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 12px; }
.toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar strong { font-size: 14px; color: #1e293b; }
.data-table tbody tr:nth-child(odd) { background: #fcfdff; }
.data-table tbody tr:hover { background: #eef6ff; }
.table-link { cursor: pointer; color: #1d4ed8; text-decoration: none; border-bottom: 1px dashed #93c5fd; }
.table-link:hover { color: #1e3a8a; border-bottom-color: #1e3a8a; }

.th-content { display: flex; align-items: center; gap: 6px; position: relative; padding-right: 16px; min-width: 0; }
.th-label { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #eaf4ff; }
th.sorted-asc,
th.sorted-desc { background: #dbeafe; }
.sort-indicator { font-size: 11px; color: #64748b; line-height: 1; flex: 0 0 auto; }
th.sorted-asc .sort-indicator,
th.sorted-desc .sort-indicator { color: #1d4ed8; }
.col-resize-handle { position: absolute; right: -2px; top: 50%; transform: translateY(-50%); width: 8px; height: 24px; cursor: col-resize; border-radius: 6px; }
.col-resize-handle:hover { background: rgba(59, 130, 246, 0.22); }
.col-resize-handle::after { content: ""; position: absolute; top: 3px; bottom: 3px; right: 3px; width: 2px; background: #93c5fd; border-radius: 2px; }
body.col-resizing { user-select: none; cursor: col-resize; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 10px; }
.link-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; font-size: 13px; margin-bottom: 4px; color: #4b5563; }
input, select, textarea { width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #d1d5db; border-radius: 8px; }
button { border: 0; background: #1d4ed8; color: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 0 rgba(15, 23, 42, 0.18); }
button:hover { filter: brightness(1.06); }
button.gray { background: #64748b; }
button.red { background: #dc2626; }
.btn { display: inline-block; text-decoration: none; background: #e5e7eb; color: #111827; padding: 6px 10px; border-radius: 8px; }
.actions { display: flex; gap: 8px; align-items: center; }
.full { grid-column: 1 / -1; }
.hidden { display: none; }
.danger-zone { margin-top: 16px; padding-top: 12px; border-top: 1px solid #e5e7eb; }

.top-toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2200;
  min-width: 220px;
  max-width: min(88vw, 720px);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  border: 1px solid transparent;
  text-align: center;
}

.top-toast.info {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e3a8a;
}

.top-toast.success {
  background: #ecfdf5;
  border-color: #86efac;
  color: #166534;
}

.top-toast.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

@media (max-width: 900px) {
  .link-cols { grid-template-columns: 1fr; }
  .wg-result-body { grid-template-columns: 1fr; }
  .link-result-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
  .toolbar { position: static; }
  .wg-result-dialog {
    width: min(98vw, 98vw);
  }
  .link-result-dialog {
    width: min(98vw, 98vw);
  }
  .wg-qr-code {
    min-height: 260px;
  }
}
