*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue:        #255aa8;
    --blue-dark:   #1a4280;
    --blue-light:  #e6f0fb;
    --gray-dark:   #494949;
    --gray:        #5d5d5d;
    --gray-light:  #f5f5f5;
    --gray-border: #d2d2d2;
    --text:        #58595b;
    --black:       #313131;
    --white:       #ffffff;
    --danger:      #c0392b;
}

html { font-size: 16px; }

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--gray-light);
    color: var(--text);
    line-height: 1.65;
    -webkit-text-size-adjust: 100%;
}

/* ══════════════════════════════════════
   PUBLIC FORM
══════════════════════════════════════ */

.page-top {
    background: var(--white);
    border-bottom: 3px solid var(--blue);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* ── Language switcher (public form) ── */
.lang-switcher { display: flex; gap: .4rem; flex-shrink: 0; }

.lang-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .35rem .75rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
    border: 1.5px solid var(--gray-border);
    background: var(--white);
    transition: all .18s;
    cursor: pointer;
    white-space: nowrap;
}
.lang-btn:hover { border-color: var(--blue); color: var(--blue); }
.lang-btn.active { background: var(--blue); color: var(--white); border-color: var(--blue); }

/* ── Admin language tabs ── */
.lang-tabs-wrap { margin-bottom: .5rem; }

.lang-tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-border);
    margin-bottom: 1rem;
}

.lang-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: .5rem 1.1rem;
    font-size: .88rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--gray);
    font-family: inherit;
    transition: all .18s;
}
.lang-tab:hover { color: var(--blue); }
.lang-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.lang-tab-content { display: none; }
.lang-tab-content.active { display: block; }

.site-logo {
    max-height: 56px;
    max-width: 240px;
    object-fit: contain;
}

.title-bar {
    background: var(--blue);
    color: var(--white);
    text-align: center;
    padding: 1.25rem 1rem;
}

.title-bar h1 {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    font-weight: 700;
    letter-spacing: .02em;
    border: none; padding: 0; margin: 0;
    color: var(--white);
}

.title-bar h1 small {
    display: block;
    font-size: clamp(.8rem, 3vw, .95rem);
    font-weight: 400;
    opacity: .85;
    margin-top: .25rem;
}

.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 .75rem 3rem;
}

.form-card {
    background: var(--white);
    padding: clamp(1.25rem, 5vw, 2.5rem);
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

/* ── Section label ── */
.section-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--blue);
    border-bottom: 2px solid var(--blue-light);
    padding-bottom: .4rem;
    margin: 1.75rem 0 1.1rem;
}

.section-label:first-child { margin-top: 0; }

/* ── Form elements ── */
.form-group { margin-bottom: 1.1rem; }

label {
    display: block;
    font-weight: 600;
    font-size: .88rem;
    margin-bottom: .35rem;
    color: var(--black);
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: .65rem .9rem;
    border: 1px solid var(--gray-border);
    border-radius: 3px;
    font-size: .95rem;
    font-family: inherit;
    background: var(--white);
    color: var(--black);
    transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none;
    appearance: none;
}

textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,90,168,.12);
}

.required { color: var(--danger); }

small, .sig-hint {
    font-size: .8rem;
    color: var(--gray);
    margin-top: .3rem;
    display: block;
}

/* ── Declaration box ── */
.declaration-box {
    background: var(--blue-light);
    border-left: 4px solid var(--blue);
    padding: 1.1rem 1.25rem;
    margin: 1.25rem 0;
    font-size: .88rem;
    color: var(--black);
    line-height: 1.7;
    border-radius: 0 4px 4px 0;
}

.declaration-box p { margin-bottom: .85rem; }
.declaration-box p:last-child { margin-bottom: 0; }

/* ── Date row ── */
.date-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: 1.1rem 0;
    font-size: .95rem;
    color: var(--black);
    font-weight: 600;
}

/* ── Signature ── */
.sig-wrapper {
    border: 1px solid var(--gray-border);
    border-radius: 3px;
    background: var(--white);
    position: relative;
    overflow: hidden;
}

#signaturePad {
    display: block;
    width: 100%;
    height: clamp(140px, 30vw, 200px);
    cursor: crosshair;
    touch-action: none;
}

.btn-clear {
    position: absolute;
    top: .5rem;
    right: .5rem;
    background: var(--white);
    border: 1px solid var(--gray-border);
    border-radius: 3px;
    padding: .25rem .6rem;
    font-size: .78rem;
    cursor: pointer;
    color: var(--gray);
    transition: all .18s;
    min-height: 32px;
}

.btn-clear:hover { border-color: var(--blue); color: var(--blue); }

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .6rem 1.25rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: .9rem;
    font-family: inherit;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: .02em;
    transition: background .18s, opacity .18s;
    white-space: nowrap;
    min-height: 40px;
}

.btn:active { opacity: .85; }

.btn-primary   { background: var(--blue);     color: var(--white); }
.btn-primary:hover { background: var(--blue-dark); }

.btn-secondary { background: var(--gray-dark); color: var(--white); }
.btn-secondary:hover { background: #333; }

.btn-danger    { background: var(--danger);   color: var(--white); }
.btn-danger:hover { background: #a93226; }

.btn-ghost {
    background: transparent;
    color: var(--gray);
    border: 1px solid var(--gray-border);
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }

.btn-sm  { padding: .3rem .65rem; font-size: .8rem; min-height: 32px; }
.btn-full { width: 100%; padding: .9rem; font-size: 1rem; margin-top: .75rem; }

/* ══════════════════════════════════════
   ALERTS
══════════════════════════════════════ */

.alert {
    padding: .9rem 1.1rem;
    border-radius: 3px;
    margin-bottom: 1.25rem;
    font-size: .9rem;
    line-height: 1.5;
}

.alert-success { background: #eaf6ed; border: 1px solid #a9d8b4; color: #1e6631; }
.alert-error   { background: #fdf0ee; border: 1px solid #f0b8b0; color: #8b1a10; }

/* ══════════════════════════════════════
   ADMIN – NAV
══════════════════════════════════════ */

.admin-wrapper { min-height: 100vh; background: var(--gray-light); }

.admin-nav {
    background: var(--blue);
    color: var(--white);
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 56px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: .65rem;
    flex-shrink: 0;
}

.nav-logo {
    height: 28px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: .9;
}

.nav-brand {
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: .04em;
    white-space: nowrap;
}

/* Desktop nav links */
.nav-links {
    display: flex;
    align-items: center;
    gap: .1rem;
}

.nav-links a {
    color: rgba(255,255,255,.75);
    text-decoration: none;
    padding: .5rem .75rem;
    font-size: .85rem;
    font-weight: 600;
    border-radius: 3px;
    transition: all .18s;
    white-space: nowrap;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--white);
    background: rgba(255,255,255,.15);
}

/* Hamburger toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .4rem;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    justify-content: center;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--white);
    border-radius: 2px;
    transition: all .25s;
}

/* Mobile nav open state */
.admin-nav.nav-open .nav-links {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 56px;
    left: 0; right: 0;
    background: var(--blue-dark);
    padding: .5rem 0;
    gap: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

.admin-nav.nav-open .nav-links a {
    padding: .8rem 1.5rem;
    border-radius: 0;
}

/* ══════════════════════════════════════
   ADMIN – CONTENT
══════════════════════════════════════ */

.admin-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem;
}

h2 { font-size: 1.25rem; color: var(--black); font-weight: 700; }
h3 {
    font-size: .85rem;
    color: var(--black);
    margin-bottom: 1rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--blue-light);
}

/* ── Stats ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--white);
    border-radius: 4px;
    padding: 1.1rem 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
    border-top: 3px solid var(--gray-border);
    text-align: center;
}

.stat-card.stat-highlight { border-top-color: var(--blue); }

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--black);
    line-height: 1;
    margin-bottom: .3rem;
}

.stat-card.stat-highlight .stat-value { color: var(--blue); }

.stat-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--gray);
}

/* ── Toolbar ── */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.filter-form {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-form input[type="text"],
.filter-form input[type="date"] {
    padding: .48rem .8rem;
    border: 1px solid var(--gray-border);
    border-radius: 3px;
    font-size: .88rem;
    font-family: inherit;
    color: var(--black);
    background: var(--white);
    min-height: 38px;
    -webkit-appearance: none;
}

.filter-form input[type="text"] { min-width: 160px; max-width: 220px; }

.toolbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Table ── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
    font-size: .88rem;
    min-width: 600px;
}

.data-table th {
    background: var(--blue);
    color: var(--white);
    padding: .65rem .9rem;
    text-align: left;
    font-weight: 700;
    font-size: .75rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    padding: .65rem .9rem;
    border-bottom: 1px solid #eeeeee;
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--blue-light); }

.actions { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ── Badge ── */
.badge {
    background: var(--blue);
    color: var(--white);
    border-radius: 10px;
    padding: .1rem .5rem;
    font-size: .72rem;
    font-weight: 700;
    vertical-align: middle;
    margin-left: .3rem;
}

/* ── Empty / pagination ── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--white);
    color: var(--gray);
    font-size: .95rem;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
}

.pagination {
    display: flex;
    gap: .4rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.pagination a {
    padding: .4rem .8rem;
    background: var(--white);
    border: 1px solid var(--gray-border);
    border-radius: 3px;
    text-decoration: none;
    color: var(--text);
    font-size: .88rem;
    min-height: 36px;
    display: flex;
    align-items: center;
}

.pagination a.active { background: var(--blue); color: var(--white); border-color: var(--blue); }
.pagination a:hover:not(.active) { border-color: var(--blue); color: var(--blue); }

/* ── Declaration view ── */
.declaration-view {
    background: var(--white);
    padding: clamp(1.25rem, 5vw, 2rem);
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
    margin-top: 1rem;
}

.info-table { width: 100%; border-collapse: collapse; margin-bottom: 1.25rem; }

.info-table th {
    text-align: left;
    padding: .55rem .9rem;
    background: var(--gray-light);
    width: 200px;
    font-weight: 700;
    font-size: .82rem;
    color: var(--black);
    border-bottom: 1px solid #e8e8e8;
    white-space: nowrap;
}

.info-table td {
    padding: .55rem .9rem;
    border-bottom: 1px solid #e8e8e8;
    font-size: .9rem;
}

.signature-display { margin-top: 1.5rem; }
.signature-display img { max-width: 100%; height: auto; }

/* ── Settings grid ── */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.settings-full { grid-column: 1 / -1; }

/* ── Form row (2-col) ── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ── Checkbox ── */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--black);
    margin: .5rem 0;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--blue);
    flex-shrink: 0;
}

/* ── Login ── */
.login-card { max-width: 400px; margin: 3rem auto; }

/* ── Compliance badges ── */
.compliance-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .75rem;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 700;
    border: 1px solid transparent;
}
.badge-ok   { background: #eaf6ed; color: #1e6631; border-color: #a9d8b4; }
.badge-warn { background: #fdf0ee; color: #8b1a10; border-color: #f0b8b0; }
.badge-gray { background: var(--gray-light); color: var(--gray); border-color: var(--gray-border); }

/* ── GDPR block on form ── */
.gdpr-block {
    background: var(--gray-light);
    border: 1px solid var(--gray-border);
    border-radius: 4px;
    padding: 1rem 1.1rem;
    margin-bottom: 1.25rem;
}

.gdpr-toggle {
    background: none;
    border: none;
    color: var(--blue);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    font-family: inherit;
    margin-bottom: .6rem;
    display: block;
}

.gdpr-notice-text {
    background: var(--white);
    border: 1px solid var(--gray-border);
    border-radius: 3px;
    padding: .85rem 1rem;
    font-size: .83rem;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: .75rem;
    white-space: pre-wrap;
}

.gdpr-check {
    margin-top: .5rem;
    align-items: flex-start;
}

.gdpr-check input { margin-top: .15rem; }

/* ── Notification status block ── */
.notify-status {
    background: var(--gray-light);
    border: 1px solid var(--gray-border);
    border-radius: 4px;
    padding: .75rem 1rem;
    margin-bottom: .25rem;
}

.notify-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem 0;
    font-size: .88rem;
    flex-wrap: wrap;
}

.notify-row + .notify-row {
    border-top: 1px solid #e8e8e8;
}

.notify-label {
    font-weight: 700;
    color: var(--black);
    white-space: nowrap;
    min-width: 130px;
}

.notify-email {
    background: var(--blue-light);
    color: var(--blue);
    font-weight: 600;
    padding: .15rem .6rem;
    border-radius: 20px;
    font-size: .85rem;
}

.notify-none {
    color: var(--gray);
    font-style: italic;
    font-size: .85rem;
}

.btn-inline-del {
    background: none;
    border: 1px solid #f0b8b0;
    color: var(--danger);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: .75rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all .18s;
    flex-shrink: 0;
}

.btn-inline-del:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
    .settings-full { grid-column: 1; }
}

@media (max-width: 700px) {
    /* Nav */
    .nav-toggle { display: flex; }
    .nav-links  { display: none; }
    .admin-nav  { position: relative; flex-wrap: wrap; padding: 0 1rem; }

    /* Admin content */
    .admin-content { padding: 1rem .75rem; }

    /* Toolbar */
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-actions { justify-content: stretch; }
    .toolbar-actions .btn { flex: 1; text-align: center; justify-content: center; }
    .filter-form { flex-direction: column; }
    .filter-form input[type="text"],
    .filter-form input[type="date"] { max-width: 100%; width: 100%; }

    /* Stats */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
    .stat-value { font-size: 1.6rem; }

    /* Form row */
    .form-row { grid-template-columns: 1fr; gap: 0; }

    /* Info table */
    .info-table th { width: 120px; font-size: .78rem; }
    .info-table td { font-size: .85rem; }

    /* Actions in table */
    .actions { gap: .25rem; }
    .btn-sm  { padding: .28rem .5rem; font-size: .76rem; }

    /* Login */
    .login-card { margin: 1.5rem auto; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: .6rem; }
    .stat-card  { padding: .85rem .75rem; }
    .stat-value { font-size: 1.5rem; }

    .data-table { font-size: .82rem; }
    .data-table th, .data-table td { padding: .5rem .65rem; }

    .form-card { padding: 1.1rem .9rem; }

    /* Stack action buttons in table rows */
    .actions { flex-direction: column; gap: .2rem; }
    .actions .btn { width: 100%; justify-content: center; }
}

/* ══════════════════════════════════════
   PRINT
══════════════════════════════════════ */

@media print {
    .admin-nav, .no-print { display: none !important; }
    .admin-content { padding: 0; }
    body { background: white; }
    .declaration-view { box-shadow: none; }
}
