:root, [data-theme="light"] {
  --page: #ffffff;
  --canvas: #e7eaed;
  --navy: #355269;
  --border: #000000;
  --text: #000000;
  --row-hover: #edf3f6;
  --green: #277c4e;
  --red: #b93838;
}
[data-theme="dark"] {
  --page: #17212b;
  --canvas: #0e151c;
  --navy: #27465e;
  --border: #6e8495;
  --text: #edf4f8;
  --row-hover: #223342;
  --green: #2f9c64;
  --red: #dc5353;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  padding: 18px;
}

.header, .section { width: min(100%, 1120px); margin-inline: auto; }
.header { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: stretch; background: var(--navy); color: #fff; border: 1px solid var(--border); min-height: 88px; }
.header-main { display: grid; place-items: stretch; text-align: center; min-width: 0; overflow: hidden; }
.header-title { width: 100%; max-width: 100%; text-align: center; height: 100%; display: flex; flex-direction: column; }
.header-cell { flex: 1 1 0; padding: 0 20px; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.header-cell:first-child { border-bottom: 2px solid rgba(255,255,255,.4); }
.header-label { font-size: 13px; font-weight: 600; opacity: .6; }
.header-label::after { content: ":"; }
.header-value { font-size: 19px; font-weight: 700; }
.header-right { padding: 9px 10px; border-left: 1px solid rgba(255, 255, 255, .35); text-align: right; display: flex; flex-direction: column; justify-content: space-between; }
.header-date { font-size: 13px; font-weight: 700; }
.header-user { font-size: 12px; font-weight: 400; opacity: .85; }
.header-top { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding-bottom: 6px; border-bottom: 1px solid rgba(255, 255, 255, .25); margin-bottom: 6px; }
.btn-logout { padding: 3px 8px; font: 11px Arial, Helvetica, sans-serif; border: 1px solid rgba(255,255,255,.5); border-radius: 2px; background: transparent; color: #fff; cursor: pointer; min-width: 120px; text-align: center; }
.btn-logout:hover { background: rgba(255,255,255,.15); }
.header-group { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.header-group-row { display: flex; gap: 5px; align-items: center; }
.header-group-row .btn { white-space: nowrap; text-align: center; justify-content: center; }
.header-group-row.csv-row .btn { min-width: 170px; }
.header-group-row.action-row { min-width: calc(170px * 2 + 5px); }
.header-group-row.action-row .btn { flex: 1 1 0; min-width: 0; }
.header-group-row.toggle-row { width: calc(170px * 2 + 5px); }
.header-group-row.toggle-row .toggle-group { flex: 0 0 auto; }
.header-group-row .btn-auth-enable { white-space: normal; flex: 1 1 auto; min-width: 0; width: auto; }

.toggle-group { display: flex; border: 1px solid rgba(255,255,255,.45); border-radius: 2px; overflow: hidden; }
.toggle-btn {
  padding: 5px 8px;
  font: 11px Arial, Helvetica, sans-serif;
  background: transparent;
  color: #fff;
  border: none;
  cursor: pointer;
}
.toggle-btn:not(:last-child) { border-right: 1px solid rgba(255,255,255,.45); }
.toggle-btn.active { background: #fff; color: var(--navy); font-weight: 700; }
.toggle-btn:hover:not(.active) { background: rgba(255,255,255,.15); }

.section { padding: 0; overflow-x: auto; }
.section:first-of-type { margin-top: 18px; }
.params-table, .service-table { width: 100%; table-layout: fixed; border-collapse: collapse; border: 1px solid var(--border); background: var(--page); }
.params-table { font-size: 14px; }
.params-table th, .params-table td { padding: 7px 12px; border: 1px solid var(--border); text-align: center; vertical-align: middle; overflow-wrap: anywhere; word-break: break-word; max-width: 0; }
.params-table th { background: var(--navy); color: #fff; font-weight: 700; }
.params-table th:first-child, .params-table td:first-child { width: 45%; }
.params-table td:first-child { font-weight: 600; }

.service-table { font-size: 12px; }
.table-wrap { overflow-x: auto; }
.service-table th {
  background: var(--navy);
  color: #fff;
  padding: 7px 5px;
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  font-weight: 700;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  min-height: 2.3em;
  position: relative;
}
.service-table td {
  padding: 6px 5px;
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  line-height: 1.15;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 0;
}
.service-table tr:hover td { background: var(--row-hover); }
.service-table .link { color: #0563c1; font-weight: 600; text-decoration: underline; text-align: center; overflow-wrap: anywhere; word-break: break-word; }
.service-table .center { text-align: center; }
.password-cell { white-space: normal; }
.password-cell .pass-text { display: inline-block; overflow-wrap: anywhere; word-break: break-word; vertical-align: middle; }
.btn-icon {
  margin-left: 2px;
  padding: 1px 3px;
  border: 1px solid #718096;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.btn-icon:hover { background: var(--row-hover); }
.copy-password {
  margin-left: 4px;
  padding: 1px 4px;
  border: 1px solid #718096;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.copy-password:hover { background: var(--row-hover); }
.resize-handle {
  position: absolute;
  top: 0; right: -2px; bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 10;
}
.resize-handle:hover, .resize-handle.active { background: rgba(255,255,255,0.3); }
.col-select { width: 28px; }
.col-passicons { width: 58px; }
.pass-icons-cell { white-space: nowrap; }
.col-name { width: 10%; }
.col-function { width: 10%; }
.col-user { width: 13%; }
.col-password { width: 16%; white-space: nowrap; }
.col-port-in, .col-port-out { width: 6%; }
.col-access { width: 24%; }
.col-note { width: 8%; }
.col-edit { width: 80px; text-align: center; }
.service-table th:first-child, .service-table td:first-child {
  position: sticky; left: 0; z-index: 2;
  background: var(--bg);
}
.service-table th:last-child, .service-table td:last-child {
  position: sticky; right: 0; z-index: 2;
  background: var(--bg);
}
.service-table thead th:first-child { z-index: 3; background: var(--navy); }
.service-table thead th:last-child { z-index: 3; background: var(--navy); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 2px;
  background: #fff;
  color: #172a38;
  font: 11px Arial, Helvetica, sans-serif;
  cursor: pointer;
}
.btn:hover { opacity: .9; }
.btn-primary { background: #fff; color: #172a38; border-color: #fff; font-weight: 700; }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: 4px 8px; font-size: 11px; }
.checkbox { width: 14px; height: 14px; cursor: pointer; accent-color: var(--navy); display: block; margin: 0 auto; }

.edit-input { width: 100%; padding: 6px 10px; border: 1px solid #9aa4ac; border-radius: 2px; color: var(--text); background: var(--canvas); font: 12px Arial, Helvetica, sans-serif; }
.edit-input:focus { outline: none; border-color: var(--navy); }
.edit-input::placeholder { color: #718096; }

.modal-overlay { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; background: rgba(0,0,0,.5); }
.modal-overlay.active { display: flex; }
.modal-box { min-width: 400px; max-width: 600px; border: 2px solid var(--navy); border-radius: 4px; background: var(--page); box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--border); background: var(--navy); }
.modal-title { color: #fff; font-size: 14px; font-weight: 700; }
.modal-close { padding: 4px 8px; border: none; background: none; color: #fff; font-size: 20px; cursor: pointer; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 15px 20px; border-top: 1px solid #cbd5e0; background: #f8fafb; }
.modal-footer .btn { border-color: #718096; }
.modal-footer .btn-primary { color: #fff; background: var(--navy); border-color: var(--navy); }
.modal-footer .btn-danger { border-color: var(--red); }
.form-row { display: flex; align-items: center; margin-bottom: 12px; }
.form-row:last-child { margin-bottom: 0; }
.form-label { width: 130px; flex-shrink: 0; font-size: 12px; font-weight: 700; }
.form-field { flex: 1; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 2000; display: none; padding: 12px 20px; border-radius: 3px; background: var(--navy); color: #fff; font-size: 12px; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.toast.error { background: var(--red); }
.toast.show { display: block; }
.confirm-text { font-size: 13px; line-height: 1.6; }

@media (max-width: 768px) {
  body { padding: 0; }
  .header { width: 100%; grid-template-columns: 1fr; }
  .header-right { border-top: 1px solid rgba(255, 255, 255, .35); border-left: 0; }
  .header-title { font-size: 17px; }
  .section:first-of-type { margin-top: 0; }
  .service-table { display: block; overflow-x: auto; }
  .modal-box { width: calc(100% - 32px); min-width: auto; margin: 16px; }
}

/* Nyomtatáskor a teljes adatlap egy A4-es fekvő oldal méretére van szabva. */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  html, body { width: 297mm; height: 210mm; box-sizing: border-box; }
  html[data-theme] { --page: #fff; --canvas: #fff; --navy: #355269; --border: #000; --text: #000; }
  body { margin: 0; padding: 10mm 0 0; background: #fff !important; color: #000 !important; font-family: Arial, Helvetica, sans-serif; font-size: 7pt; display: flex; flex-direction: column; align-items: center; }
  .header, .section { width: 287mm; }
  .header { min-height: 8mm; grid-template-columns: 1fr 44mm; page-break-inside: avoid; }
  .header-main { padding: 1mm 3mm; }
  .header-title { font-size: 11pt; }
  .header-right { padding: 1.2mm 2mm; border-left-width: .2mm; }
  .header-date { font-size: 7pt; }
  .header-group, .toggle-group, .btn-logout, .btn-icon, .header-user, .no-print, .resize-handle { display: none !important; }
  .section:first-of-type { margin-top: 1.5mm; }
  .params-table { font-size: 6.6pt; }
  .params-table th, .params-table td { height: 4.4mm; padding: .6mm 1.5mm; }
  .params-table td, .service-table td { color: #000 !important; background: #fff !important; }
  .service-table { font-size: 5.9pt; }
  .service-table th, .service-table td { height: 4.55mm; padding: .45mm 1mm; overflow: hidden; }
  .service-table td { white-space: nowrap; overflow-wrap: normal; text-overflow: ellipsis; }
  .service-table th { white-space: normal; }
  .service-table .link { color: #000 !important; text-decoration: none; }
  .copy-password { display: none; }
  .checkbox, .service-table th:first-child, .service-table td:first-child { display: none; }
  .col-select { display: none; width: 0; }
  .col-passicons { display: none; width: 0; }
  .pass-icons-cell, .service-table thead th.pass-icons-th { display: none; }
  .col-edit { display: none; width: 0; }
  .edit-cell, .edit-th { display: none; }
  .col-name { width: 11%; }
  .col-function { width: 11%; }
  .col-user { width: 13%; }
  .col-password { width: 14%; white-space: nowrap; }
  .col-port-in, .col-port-out { width: 6%; }
  .col-access { width: 27%; }
  .col-note { width: 12%; }
  .service-table tr { page-break-inside: avoid; }
  @page { size: A4 landscape; margin: 0; }
}
