:root {
    --bg: #fff1f6;
    --bg-alt: #ffe8f1;
    --surface: #ffffff;
    --surface-alt: #fff5f8;
    --text: #3b1126;
    --muted: #8b4a69;
    --primary: #c2185b;
    --primary-strong: #8f0f42;
    --accent: #f06292;
    --accent-strong: #d54678;
    --danger: #b71c3a;
    --border: #f0bdd1;
    --border-strong: #e48bad;
    --ok: #1b8752;
    --shadow: 0 16px 38px rgba(145, 27, 75, 0.14);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: 'Manrope', 'Noto Sans', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 4% 0%, #ffe0ec 0%, rgba(255, 224, 236, 0) 32%),
        radial-gradient(circle at 95% 5%, #ffd7e7 0%, rgba(255, 215, 231, 0) 34%),
        linear-gradient(160deg, var(--bg) 0%, var(--bg-alt) 100%);
}

a {
    color: inherit;
}

.app-shell {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 12px;
}

.header {
    background: linear-gradient(140deg, #cc175d, #971247 62%, #7d153d 100%);
    border-radius: var(--radius);
    color: #fff;
    box-shadow: var(--shadow);
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.header > div:first-child {
    min-width: 0;
}

.header h1 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 0.2px;
}

.header .meta {
    font-size: 12px;
    opacity: 0.94;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.tab-nav {
    margin-top: 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    box-shadow: 0 10px 24px rgba(180, 24, 93, 0.08);
}

.tab-btn {
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: #8b3056;
    font-weight: 800;
    font-size: 13px;
    padding: 10px 12px;
    cursor: pointer;
}

.tab-btn.is-active {
    background: linear-gradient(145deg, #f9d6e5, #ffdfee);
    border-color: #f0a8c5;
    color: #6d0d34;
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.card {
    margin-top: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
}

.card h2,
.card h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.install-prompt {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 10px 24px rgba(180, 24, 93, 0.08);
}

.install-prompt.compact {
    box-shadow: none;
}

.install-prompt strong {
    display: block;
    font-size: 14px;
}

.install-prompt p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.wizard-step {
    border: 1px solid #f3c8d7;
    border-radius: 14px;
    background: #fff9fc;
    padding: 12px;
    margin-bottom: 10px;
}

.wizard-step.step-focus {
    min-height: min(50vh, 360px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

.wizard-step.step-focus label,
.wizard-step.step-focus input,
.wizard-step.step-focus .pill-row {
    width: min(540px, 100%);
}

label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 700;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
input[type="password"],
select,
textarea {
    width: 100%;
    border: 1px solid #ebb6cb;
    border-radius: 11px;
    padding: 10px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
}

textarea {
    resize: vertical;
    min-height: 96px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(221, 61, 129, 0.22);
    border-color: #da5f95;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.pill-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.centered {
    justify-content: center;
}

.pill {
    border: 1px solid #efbfd3;
    color: #7d1842;
    background: #fff0f7;
    border-radius: 999px;
    padding: 7px 11px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.pill:hover {
    border-color: #e07ba6;
    background: #ffe5f1;
}

.segmented {
    display: flex;
    border: 1px solid #ebbbce;
    border-radius: 11px;
    overflow: hidden;
    margin-top: 4px;
    background: #fff7fb;
}

.segmented label {
    margin: 0;
    flex: 1;
}

.segmented input {
    display: none;
}

.segmented span {
    display: block;
    text-align: center;
    padding: 10px;
    font-size: 13px;
    color: #7e3758;
    font-weight: 700;
}

.segmented input:checked + span {
    background: linear-gradient(140deg, #ffd7e7, #ffc4db);
    color: #651234;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.actions.vertical {
    flex-direction: column;
}

button {
    border: none;
    border-radius: 11px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-strong);
}

.btn-accent {
    background: var(--accent);
    color: #4c1230;
}

.btn-accent:hover:not(:disabled) {
    background: var(--accent-strong);
    color: #fff;
}

.btn-ghost {
    background: #fff6fb;
    border: 1px solid #efbfd3;
    color: #7e2d52;
}

.btn-ghost:hover:not(:disabled) {
    background: #ffe7f1;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.history-controls {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 1fr auto;
    gap: 8px;
    align-items: center;
}

.expense-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.expense-item {
    border: 1px solid #f0cad9;
    border-radius: 13px;
    padding: 10px;
    background: #fffafd;
}

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

.expense-description {
    font-size: 14px;
    font-weight: 800;
    margin: 0;
}

.expense-meta {
    color: #8e4d6c;
    font-size: 12px;
}

.badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.badge {
    font-size: 11px;
    border-radius: 999px;
    padding: 3px 8px;
    font-weight: 800;
    border: 1px solid transparent;
}

.badge.company {
    background: #ffe0ec;
    border-color: #f0a8c5;
    color: #8a103f;
}

.badge.private {
    background: #ffe8ef;
    border-color: #e9b8c9;
    color: #8b3454;
}

.badge.deleted {
    background: #ffe1e6;
    border-color: #eba6b6;
    color: #8c1e32;
}

.photo-slots {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.photo-slot {
    position: relative;
    min-height: 96px;
    border: 2px dashed #eeaac5;
    border-radius: 12px;
    background: #fff7fb;
    display: grid;
    place-items: center;
    overflow: hidden;
    cursor: pointer;
    font-size: 28px;
    color: #d34e88;
}

.photo-slot.is-filled {
    border-style: solid;
    border-color: #df77a4;
}

.photo-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-slot small {
    position: absolute;
    bottom: 4px;
    right: 6px;
    background: rgba(96, 15, 47, 0.72);
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
}

.tree-picker-wrap {
    position: relative;
}

.tree-picker-dropdown {
    position: absolute;
    z-index: 12;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 280px;
    overflow: auto;
    border: 1px solid #e9aac5;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 16px 26px rgba(180, 24, 93, 0.16);
    padding: 6px;
}

.tree-option {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #4e1430;
    text-align: left;
    padding: 8px;
    margin: 1px 0;
    font-size: 13px;
    font-weight: 700;
}

.tree-option:hover {
    background: #fff2f8;
    border-color: #f1bfd4;
}

.tree-option small {
    color: #a75479;
    font-size: 11px;
    margin-left: 4px;
}

.tree-empty {
    font-size: 12px;
    color: var(--muted);
    padding: 8px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid #efbfd3;
    border-radius: 11px;
}

.user-create-panel {
    border: 1px solid #f0cad9;
    border-radius: 12px;
    background: #fffafd;
    padding: 10px;
}

.user-create-panel h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
}

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

.user-card-list {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}

.user-card {
    border: 1px solid #efbfd3;
    border-radius: 12px;
    background: #fffafd;
    padding: 10px;
}

.user-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.user-card-name {
    font-size: 15px;
    font-weight: 800;
    margin: 0;
    word-break: break-word;
}

.user-card-id {
    font-size: 11px;
    color: var(--muted);
}

.user-card-row {
    margin-top: 8px;
}

.user-card-row label {
    margin-bottom: 4px;
}

.user-card-actions {
    margin-top: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
}

th,
td {
    border-bottom: 1px solid #f6d9e5;
    padding: 8px;
    text-align: left;
}

th {
    background: #fff2f8;
    color: #7a2f52;
    position: sticky;
    top: 0;
    z-index: 1;
}

.panel {
    margin-top: 10px;
    background: #fff8fc;
    border: 1px solid #efbfd3;
    border-radius: 11px;
    padding: 10px;
}

.list-checkboxes {
    max-height: 260px;
    overflow: auto;
    border: 1px solid #efbfd3;
    border-radius: 10px;
    padding: 8px;
    background: #fff;
}

.list-checkboxes label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px 0;
    font-size: 13px;
    color: #5c2340;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(77, 14, 40, 0.46);
    display: grid;
    place-items: center;
    padding: 12px;
    z-index: 50;
}

.modal-card {
    width: min(880px, 100%);
    max-height: calc(100vh - 24px);
    overflow: auto;
    border-radius: 16px;
    border: 1px solid #efbfd3;
    background: #fff;
    box-shadow: 0 20px 45px rgba(71, 15, 42, 0.32);
    padding: 12px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.modal-header h3 {
    margin: 0;
}

.detail-modal {
    width: min(900px, 100%);
}

.photo-choice-modal {
    width: min(360px, 100%);
}

.photo-choice-modal h3 {
    margin: 0 0 10px 0;
}

.empty {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    padding: 12px;
}

.error {
    margin-top: 8px;
    font-size: 12px;
    color: var(--danger);
    font-weight: 700;
}

.success {
    margin-top: 8px;
    font-size: 12px;
    color: var(--ok);
    font-weight: 700;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 12px;
}

.auth-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 16px;
    padding: 16px;
}

.auth-card h1 {
    margin: 0 0 10px 0;
}

.hidden {
    display: none !important;
}

@media (max-width: 860px) {
    .history-controls {
        grid-template-columns: 1fr;
    }

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

    .tab-nav {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .header {
        padding: 10px 12px;
    }

    .header h1 {
        font-size: 18px;
    }

    .header .meta {
        max-width: 210px;
        font-size: 11px;
    }

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