:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --danger: #ef4444;
    --success: #16a34a;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #1e293b;
    --text-sec: #64748b;
    --border: #cbd5e1;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.10), 0 1px 2px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

a {
    color: inherit;
}

.app-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--primary);
    color: #ffffff;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.18);
}

.app-bar h2 {
    margin: 0;
    min-width: 0;
    font-size: 1.05rem;
    line-height: 1.2;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn,
.link-btn {
    min-height: 40px;
    min-width: 40px;
    border: 0;
    background: rgba(255,255,255,0.14);
    color: #ffffff;
    border-radius: 999px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.link-btn.back {
    padding: 8px 12px;
    border-radius: 10px;
}

.container {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 14px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

h1, h2, h3, p {
    overflow-wrap: anywhere;
}

h1, h2, h3 {
    margin-top: 0;
}

.text-muted {
    color: var(--text-sec);
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 16px;
}

label,
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-sec);
    margin-bottom: 6px;
}

.step-label {
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.78rem;
}

input,
select,
textarea {
    width: 100%;
    min-height: 46px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: #f8fafc;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

textarea {
    resize: vertical;
}

/* v30: keep all field values readable in black, including non-editable fields */
input,
select,
textarea,
input[readonly],
textarea[readonly],
select[readonly],
input:disabled,
textarea:disabled,
select:disabled {
    color: #111827 !important;
    -webkit-text-fill-color: #111827 !important;
    opacity: 1 !important;
}


input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

input[readonly],
textarea[readonly],
select[readonly],
input:disabled,
textarea:disabled,
select:disabled {
    color: #111827 !important;
    -webkit-text-fill-color: #111827 !important;
    opacity: 1 !important;
    border-style: dashed;
}

input[type="date"],
input[type="datetime-local"],
input[type="time"],
.date-value,
.entry-meta .entry-date,
.reminder-chip {
    color: #111827 !important;
    -webkit-text-fill-color: #111827 !important;
    opacity: 1 !important;
    font-weight: 800 !important;
}

input[type="date"][readonly],
input[type="datetime-local"][readonly],
input[type="time"][readonly] {
    color: #111827 !important;
    -webkit-text-fill-color: #111827 !important;
    opacity: 1 !important;
    font-weight: 800 !important;
    border-style: dashed;
}

.subject-uppercase {
    text-transform: uppercase;
}

.btn {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 10px;
    padding: 14px 16px;
    background: var(--primary);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.28);
    cursor: pointer;
}

.btn:hover,
.btn:focus-visible {
    background: var(--primary-dark);
}

.btn-danger {
    background: var(--danger);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.28);
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text);
    box-shadow: none;
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
    padding: 4px 0 16px;
    width: 100%;
}

.filter-bar::-webkit-scrollbar {
    display: none;
}

.chip {
    min-height: 40px;
    padding: 9px 8px;
    border-radius: 999px;
    background: #e2e8f0;
    color: var(--text-sec);
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
    white-space: normal;
    line-height: 1.15;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    min-width: 0;
}

.chip.active {
    background: var(--primary);
    color: #ffffff;
}

.fab {
    position: fixed;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 400;
    line-height: 1;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.35);
    z-index: 100;
}

.avatar {
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
}

.avatar-login {
    width: 104px;
    height: 104px;
    border: 3px solid var(--primary);
    margin: 0 auto 16px;
    box-shadow: 0 4px 8px rgba(15, 23, 42, 0.12);
}

.avatar-appbar {
    width: 34px;
    height: 34px;
    border: 2px solid #ffffff;
    flex-shrink: 0;
}

.avatar-fallback {
    background: rgba(255,255,255,0.28);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.login-page {
    padding-bottom: 0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    text-align: center;
}

.alert {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 0.92rem;
    font-weight: 600;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.entry-card {
    cursor: pointer;
}

.entry-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.entry-thumb {
    width: 58px;
    height: 58px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
    cursor: zoom-in;
}

.entry-main {
    min-width: 0;
    flex: 1;
}

.entry-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--text-sec);
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.entry-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    line-height: 1.25;
}

.entry-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    background: #e2e8f0;
    color: var(--text-sec);
}

.status-completed {
    background: #dcfce7;
    color: #166534;
}

.status-dropped {
    background: #fee2e2;
    color: #991b1b;
}

.status-non-completed {
    background: #fef3c7;
    color: #92400e;
}

.segmented {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.segmented label {
    margin: 0;
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--text);
    font-weight: 800;
}

.segmented input:checked + span {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.10);
    color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.10);
}

.image-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.image-preview img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: zoom-in;
}

.image-hint {
    display: block;
    width: 100%;
    color: var(--text-sec);
    font-size: 0.78rem;
    margin-top: -4px;
}

.remove-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 0.92rem;
}

.remove-check input {
    width: 20px;
    min-height: 20px;
    height: 20px;
    accent-color: var(--danger);
}

.site-footer {
    text-align: center;
    padding: 28px 12px;
    color: #94a3b8;
    font-size: 0.75rem;
}

.site-footer p {
    margin: 2px 0;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
    background: rgba(0,0,0,0.88);
}

.modal img {
    max-width: 100%;
    max-height: 88vh;
    margin: 4vh auto 0;
    display: block;
    border-radius: 12px;
}

@media (min-width: 480px) {
    .container {
        padding: 18px;
    }

    .segmented {
        grid-template-columns: repeat(3, 1fr);
    }

    .app-bar h2 {
        font-size: 1.2rem;
    }
}

@media (max-width: 360px) {
    .container {
        padding: 12px;
    }

    .app-bar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .icon-btn,
    .link-btn {
        min-width: 38px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .entry-thumb {
        width: 50px;
        height: 50px;
    }
}


/* Camera / gallery upload controls */
.upload-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

.upload-tile {
    width: 100%;
    min-height: 86px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    cursor: pointer;
    color: var(--text);
    padding: 12px 8px;
    font: inherit;
}

.upload-tile:active {
    transform: scale(0.98);
}

.upload-tile span:not(.upload-icon) {
    font-weight: 700;
    font-size: 0.95rem;
}

.upload-tile small {
    color: var(--text-sec);
    font-size: 0.76rem;
}

.upload-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.file-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 360px) {
    .upload-choice {
        grid-template-columns: 1fr;
    }
}


.camera-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.82);
    z-index: 10000;
}

.camera-modal.open {
    display: flex;
}

.camera-panel {
    width: min(100%, 520px);
    max-height: calc(100vh - 32px);
    overflow: auto;
    background: var(--surface);
    color: var(--text);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.camera-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.camera-close {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: #e2e8f0;
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}

.camera-video,
.camera-canvas {
    width: 100%;
    max-height: 62vh;
    background: #020617;
    border-radius: 14px;
    object-fit: contain;
}

.camera-video.hide {
    display: none;
}

.camera-canvas {
    display: none;
}

.camera-canvas.show {
    display: block;
}

.camera-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 12px;
}

.camera-actions .secondary {
    background: #64748b;
    box-shadow: none;
}

.camera-error {
    margin-top: 10px;
    color: #991b1b;
    font-weight: 700;
    font-size: 0.9rem;
}

.native-camera-fallback {
    margin-top: 12px;
    display: block;
    text-align: center;
    color: var(--primary);
    font-weight: 800;
    text-decoration: underline;
    cursor: pointer;
}

@media (min-width: 480px) {
    .camera-actions {
        grid-template-columns: repeat(3, 1fr);
    }
}

.thumb-error {
    background: #e2e8f0;
    object-fit: contain;
}

/* Reminder additions kept minimal so v9 layout stays unchanged */
.reminder-box {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 14px;
    background: #fff7ed;
}

.reminder-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
    max-width: 100%;
    margin: 0 0 8px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.78rem;
    font-weight: 800;
}

.reminder-chip.due {
    background: #fee2e2;
    color: #991b1b;
}

.notice-card {
    border-left: 4px solid var(--primary);
}

@media (max-width: 380px) {
    .reminder-chip {
        font-size: 0.72rem;
    }
}

.alert-info {
    background: #e0f2fe;
    color: #075985;
}

button:disabled,
.btn[disabled] {
    cursor: not-allowed;
}


.text-link {
    color: var(--primary);
    font-weight: 800;
    text-decoration: none;
}

.text-link:active,
.text-link:hover {
    text-decoration: underline;
}


/* v25 mobile-first index/view refinements */
@media (min-width: 430px) {
    .filter-bar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 720px) {
    .filter-bar {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.entry-card {
    border: 1px solid rgba(203, 213, 225, 0.78);
}

.entry-card:active {
    transform: scale(0.995);
}

@media (max-width: 380px) {
    .entry-row {
        gap: 10px;
    }
    .entry-title {
        font-size: 1rem;
    }
    .entry-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }
    .chip {
        font-size: 0.76rem;
        padding-left: 6px;
        padding-right: 6px;
    }
}


/* v26 settings / notification subpage refinements */
.settings-link-card .btn {
    margin-top: 6px;
}

#entry_date.readonly-normal[readonly],
input.entry-date-input.readonly-normal[readonly] {
    color: #111827 !important;
    -webkit-text-fill-color: #111827 !important;
    opacity: 1 !important;
    font-weight: 800 !important;
    background: #f8fafc;
    border-style: dashed;
}

.support-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 10px 0 12px;
}

.support-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #f8fafc;
}

.support-item strong {
    display: block;
    font-size: 0.92rem;
    margin-bottom: 4px;
}

.support-item span {
    display: block;
    color: var(--text-sec);
    font-size: 0.84rem;
    line-height: 1.35;
}

.support-ok { border-left: 4px solid var(--success); }
.support-warn { border-left: 4px solid var(--warning); }
.support-bad { border-left: 4px solid var(--danger); }

@media (min-width: 560px) {
    .support-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* v28 requested fixes */
.settings-link-card { margin-top: 16px; }
.status-table td { color: var(--text); }

/* v31: force true black text for all form fields, including readonly/disabled/date controls */
input,
select,
textarea,
input[readonly],
textarea[readonly],
select[readonly],
input:disabled,
textarea:disabled,
select:disabled,
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="date"][readonly],
input[type="datetime-local"][readonly],
input[type="time"][readonly],
input[type="date"]:disabled,
input[type="datetime-local"]:disabled,
input[type="time"]:disabled {
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
    opacity: 1 !important;
    -webkit-opacity: 1 !important;
    filter: none !important;
}

/* Make all visible date/time values pure black and bold across cards/forms */
.date-value,
.entry-date,
.entry-meta,
.entry-meta .entry-date,
.reminder-chip,
.reminder-date,
#entry_date,
#status_date,
#reminder_at,
.entry-date-input,
.readonly-normal {
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
    font-weight: 700 !important;
    opacity: 1 !important;
}

/* Some mobile browsers/WebViews dim read-only native date controls internally; this keeps the container from looking disabled. */
input[readonly].readonly-normal,
input[readonly].entry-date-input,
input[readonly][type="datetime-local"] {
    background-color: #f8fafc !important;
    border-color: var(--border) !important;
    cursor: default !important;
}
