:root {
    --ink: #1c2320;
    --muted: #65716b;
    --line: #dfe6e1;
    --paper: #fbfaf7;
    --panel: #ffffff;
    --brand: #146c5f;
    --brand-dark: #0d4d44;
    --accent: #b66a2c;
    --danger: #a52828;
    --success: #1f7a47;
    font-family: Arial, "Noto Nastaliq Urdu", "Noto Naskh Arabic", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--paper);
}

a {
    color: inherit;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px clamp(16px, 5vw, 56px);
    color: #fff;
    background: linear-gradient(90deg, var(--brand-dark), var(--brand));
    direction: ltr;
}

.site-header h1,
.site-header p {
    margin: 0;
}

.site-header h1 {
    font-size: clamp(28px, 5vw, 48px);
    line-height: 1.1;
}

.eyebrow {
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0;
}

.admin-link,
button {
    border: 0;
    border-radius: 6px;
    padding: 11px 16px;
    color: #fff;
    background: var(--accent);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.admin-link:hover {
    filter: brightness(0.95);
}

.secondary {
    color: var(--brand);
    background: #eaf3f0;
}

.lock-screen {
    display: grid;
    min-height: calc(100vh - 104px);
    place-items: center;
    padding: 24px;
}

.inline-lock {
    min-height: 420px;
}

.panel,
.entry,
.total-bar,
.empty,
.alert,
.success {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 10px 30px rgba(20, 42, 35, 0.06);
}

.login-panel {
    width: min(420px, 100%);
    padding: 28px;
    direction: ltr;
    text-align: left;
}

.login-panel h2,
.data-form h3,
.section-head h2,
.admin-top h2 {
    margin: 0 0 10px;
}

.login-panel p,
.section-head p {
    margin: 0 0 20px;
    color: var(--muted);
}

label {
    display: block;
    margin: 14px 0 7px;
    color: var(--ink);
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 13px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

textarea {
    resize: vertical;
}

.login-panel button,
.data-form button {
    width: 100%;
    margin-top: 18px;
}

.tabs {
    display: flex;
    gap: 8px;
    padding: 18px clamp(16px, 5vw, 56px) 0;
    direction: ltr;
}

.tabs a {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 16px;
    color: var(--muted);
    background: #fff;
    text-decoration: none;
    font-weight: 700;
}

.tabs a.active {
    color: #fff;
    border-color: var(--brand);
    background: var(--brand);
}

.content {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
    direction: ltr;
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
}

.timeline {
    display: grid;
    gap: 22px;
}

.entry {
    padding: clamp(16px, 3vw, 24px);
    overflow: hidden;
}

.entry-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.entry-title time {
    flex: 0 0 auto;
    border: 1px solid #f0d2b7;
    border-radius: 999px;
    padding: 7px 11px;
    color: var(--accent);
    background: #fff7ef;
    font-weight: 800;
    font-size: 14px;
}

.entry-title h3 {
    margin: 0;
    font-size: clamp(20px, 3vw, 28px);
    line-height: 1.2;
}

.notes,
.muted {
    color: var(--muted);
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 12px;
    margin-top: 16px;
    min-width: 0;
}

.media-tile {
    position: relative;
    display: block;
    overflow: hidden;
    width: 100%;
    max-width: 170px;
    min-width: 0;
    aspect-ratio: 1;
    border-radius: 8px;
    background: #eef1ed;
}

.receipts-grid .media-tile {
    width: 100%;
    max-width: 170px;
    aspect-ratio: 1;
}

.image-grid img,
.image-grid video {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-placeholder {
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(20, 108, 95, 0.9), rgba(182, 106, 44, 0.88)),
        #146c5f;
}

.play-symbol {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 999px;
    color: var(--brand);
    background: rgba(255, 255, 255, 0.92);
    font-size: 20px;
    line-height: 1;
}

.image-grid img {
    transition: transform 160ms ease;
}

.media-tile:hover img {
    transform: scale(1.03);
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 999px;
    line-height: 1;
}

.view-full {
    position: absolute;
    right: 6px;
    bottom: 6px;
    margin: 0;
    background: rgba(13, 77, 68, 0.92);
    font-size: 17px;
}

.media-badge {
    position: absolute;
    top: 7px;
    left: 7px;
    border-radius: 999px;
    padding: 4px 7px;
    color: #fff;
    background: rgba(0, 0, 0, 0.62);
    font-size: 11px;
    font-weight: 700;
}

.viewer[hidden] {
    display: none;
}

.viewer {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 58px 14px 18px;
    background: rgba(10, 16, 14, 0.92);
}

.viewer-body {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
}

.viewer-body img,
.viewer-body video {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    background: #000;
}

.viewer-close {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 51;
    width: auto;
    background: #fff;
    color: var(--ink);
}

.viewer-open {
    overflow: hidden;
}

.total-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    padding: 18px 22px;
}

.total-bar span {
    color: var(--muted);
    font-weight: 700;
}

.total-bar strong {
    color: var(--brand);
    font-size: clamp(26px, 4vw, 40px);
}

.empty,
.alert,
.success {
    padding: 14px 16px;
}

.empty {
    color: var(--muted);
}

.alert {
    margin-bottom: 14px;
    color: var(--danger);
    background: #fff4f4;
}

.success {
    margin-bottom: 14px;
    color: var(--success);
    background: #effaf3;
}

.admin-content {
    direction: ltr;
}

.admin-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.data-form {
    padding: 22px;
}

.manage-section {
    margin-top: 28px;
}

.manage-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.manage-card {
    margin-top: 14px;
    padding: 18px;
}

.edit-form,
.add-media-form {
    display: grid;
    gap: 8px;
}

.button-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}

.button-row button,
.add-media-form button {
    width: auto;
    margin-top: 0;
}

.admin-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.admin-media-tile {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    aspect-ratio: 1;
    background: #eef1ed;
}

.admin-media-tile img,
.admin-media-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-media-tile .play-symbol {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    font-size: 15px;
}

.danger-button {
    background: var(--danger);
}

.danger-icon {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 26px;
    height: 26px;
    background: rgba(165, 40, 40, 0.94);
    font-size: 15px;
}

.upload-modal[hidden] {
    display: none;
}

.upload-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(10, 16, 14, 0.62);
}

.upload-dialog {
    width: min(440px, 100%);
    border-radius: 8px;
    padding: 24px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.upload-dialog h2 {
    margin: 0 0 8px;
}

.upload-dialog p {
    margin: 0 0 16px;
    color: var(--muted);
}

.upload-stats {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    color: var(--ink);
    font-weight: 700;
}

.progress-label {
    margin: 12px 0 6px;
    color: var(--muted);
    font-size: 13px;
}

.progress-track {
    overflow: hidden;
    height: 12px;
    border-radius: 999px;
    background: #e8eeea;
}

.progress-track div {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
    transition: width 160ms ease;
}

@media (max-width: 760px) {
    .site-header {
        align-items: center;
        flex-direction: column;
        text-align: center;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .manage-columns {
        grid-template-columns: 1fr;
    }

    .section-head,
    .entry-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .total-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .media-tile {
        max-width: none;
    }
}

@media (max-width: 520px) {
    .image-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .media-tile {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .button-row {
        display: grid;
    }

    .button-row button,
    .add-media-form button {
        width: 100%;
    }
}
