/* TabletApp — czysty, medyczny, tablet-first */
:root {
    --blue: #1a5cb0; --blue-dark: #0f3d78; --blue-light: #e8f0fa;
    --red: #a82020; --green: #1b6b3a;
    --bg: #f4f5f7; --white: #fff;
    --text: #1a1a2e; --text2: #6b7280; --border: #d1d5db;
    --r: 10px;
    --touch: 56px;
}

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

html {
    font-size: 20px;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Header */
.app-header {
    background: var(--blue-dark);
    color: var(--white);
    padding: 10px 28px;
    display: flex; align-items: center; justify-content: space-between;
}
.app-header h1 { font-size: 1.1rem; font-weight: 600; letter-spacing: .5px; }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { height: 32px; width: auto; }
.datetime { font-size: .75rem; opacity: .85; }
.user-info { display: flex; align-items: center; gap: 12px; font-size: .75rem; }
.role-badge { background: rgba(255,255,255,.15); padding: 3px 10px; border-radius: 4px; font-size: .7rem; }
.btn-logout { color: var(--white); border: 1px solid rgba(255,255,255,.3); background: transparent; padding: 5px 14px; border-radius: 4px; font-size: .7rem; cursor: pointer; }

/* Content */
.app-content { padding: 24px; max-width: 1280px; margin: 0 auto; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: var(--touch); min-width: var(--touch);
    padding: 14px 28px; border: none; border-radius: var(--r);
    font-size: .95rem; font-weight: 600; cursor: pointer;
    text-decoration: none; gap: 6px; touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--blue-dark); color: var(--white); }
.btn-submit { background: var(--blue); color: var(--white); }
.btn-cancel { background: var(--white); border: 2px solid var(--border); color: var(--text2); font-weight: 500; }
.btn-cancel:hover { border-color: #9ca3af; color: var(--text); }
.btn-outline { background: var(--white); border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: #9ca3af; }
.btn-lg { min-height: 64px; padding: 16px 32px; font-size: 1rem; width: 100%; font-weight: 600; }

/* Tiles */
.tile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 24px 0; }
.tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--white); border-radius: var(--r); padding: 40px 20px;
    text-decoration: none; color: var(--text); min-height: 180px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.tile:active { background: var(--blue-light); border-color: var(--blue); }
.tile-icon { font-size: 2.2rem; margin-bottom: 10px; opacity: .7; }
.tile-label { font-size: 1rem; font-weight: 600; }
.tile-sublabel { font-size: .7rem; color: var(--text2); margin-top: 2px; }

/* Visit list */
.visit-list { display: flex; flex-direction: column; gap: 8px; }
.visit-item {
    display: flex; align-items: center; gap: 16px;
    background: var(--white); border-radius: var(--r); padding: 16px 24px;
    cursor: pointer; border-left: 4px solid var(--blue);
    box-shadow: 0 1px 2px rgba(0,0,0,.04); min-height: 60px;
}
.visit-item:active { background: var(--blue-light); }
.visit-time { font-size: 1.1rem; font-weight: 700; color: var(--blue); min-width: 65px; }
.visit-patient { font-size: .95rem; font-weight: 600; flex: 1; }
.visit-doctor { font-size: .75rem; color: var(--text2); }
.visit-arrow { font-size: 1.1rem; color: var(--text2); }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .75rem; font-weight: 600; color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .3px; }
.form-input {
    width: 100%; min-height: var(--touch);
    padding: 12px 16px; border: 1.5px solid var(--border); border-radius: 6px;
    font-size: .95rem; background: var(--white); -webkit-appearance: none;
}
.form-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-light); }

/* Questionnaire */
.question-section h2 {
    font-size: 1.1rem; font-weight: 600; color: var(--blue-dark);
    padding-bottom: 8px; border-bottom: 2px solid var(--blue-light); margin-bottom: 20px;
}
.question-item {
    background: var(--white); border-radius: var(--r); padding: 18px 24px; margin-bottom: 10px;
    border: 1px solid var(--border);
}
.question-text { font-size: .9rem; font-weight: 500; margin-bottom: 12px; line-height: 1.3; }
.yes-no-toggle { display: flex; gap: 12px; }
.yes-no-btn {
    flex: 1; min-height: var(--touch); border: 2px solid var(--border);
    border-radius: var(--r); background: var(--white);
    font-size: .9rem; font-weight: 600; cursor: pointer;
    transition: all .15s;
}
.yes-no-btn:hover { background: #f0f4f8; }
.yes-no-btn.selected-yes { background: #e6f7ee; color: var(--green); border-color: var(--green); font-weight: 700; }
.yes-no-btn.selected-no  { background: #fde8e8; color: var(--red); border-color: var(--red); font-weight: 700; }

/* GDPR */
.gdpr-section { background: #fefdf5; border: 2px solid #e5d9a0; border-radius: var(--r); padding: 20px; margin-bottom: 20px; }
.gdpr-text { font-size: .75rem; line-height: 1.5; margin-bottom: 12px; color: #6b5e3e; }
.gdpr-check { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 600; }
.gdpr-check input[type="checkbox"] { width: 28px; height: 28px; cursor: pointer; }

/* Signature */
.signature-pad { border: 2px dashed var(--border); border-radius: var(--r); background: var(--white); cursor: crosshair; touch-action: none; width: 100%; height: 140px; }
.signature-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Archive */
.archive-filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.archive-filters .form-group { flex: 1; min-width: 160px; margin-bottom: 0; }
.archive-table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--r); overflow: hidden; }
.archive-table th, .archive-table td { padding: 14px; text-align: left; font-size: .8rem; border-bottom: 1px solid var(--border); }
.archive-table th { background: var(--blue-light); font-weight: 600; color: var(--text2); text-transform: uppercase; font-size: .7rem; letter-spacing: .3px; }
.archive-table tr:active { background: var(--blue-light); }

/* Utilities */
.card { background: var(--white); border-radius: var(--r); padding: 22px; margin-bottom: 14px; border: 1px solid var(--border); }
.loading-spinner { display: flex; justify-content: center; padding: 40px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { padding: 14px 20px; border-radius: var(--r); font-size: .85rem; margin-bottom: 12px; }
.alert-error { background: #ffebee; color: var(--red); }
.alert-success { background: #e8f5e9; color: var(--green); }
.empty-state { text-align: center; padding: 56px 24px; color: var(--text2); }
.empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: .5; }
.empty-state h3 { font-size: 1rem; margin-bottom: 4px; }

@media print { .app-header, .btn, .signature-actions { display: none !important; } }
