:root {
    --bg: #f3f4f6;
    --bg-accent: #ffffff;
    --surface: rgba(255, 255, 255, 0.96);
    --surface-strong: #fffdf9;
    --text: #19324a;
    --muted: #66788a;
    --line: rgba(25, 50, 74, 0.1);
    --brand: #0f766e;
    --brand-dark: #0b5a54;
    --brand-soft: #d7f2ee;
    --amber: #c27b2d;
    --rose: #b6543b;
    --danger: #b42318;
    --success: #127a66;
    --shadow: 0 10px 24px rgba(25, 50, 74, 0.08);
    --radius: 20px;
    --radius-small: 14px;
    --transition: 180ms ease;
}

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

html {
    background: #f3f4f6;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 15px;
    color: var(--text);
    background: #f3f4f6;
}

a,
button,
input,
select,
textarea {
    font: inherit;
}

.card-surface {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.page-shell {
    min-height: 100vh;
    padding: 1rem;
}

.reset-body {
    min-height: 100vh;
}

.narrow-shell {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    align-items: center;
}

.auth-screen {
    display: grid;
    place-items: center;
    padding: 1rem;
}

.auth-card {
    width: min(100%, 500px);
    padding: 1.25rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 244, 235, 0.96)),
        var(--surface);
}

.auth-panel,
.reset-panel {
    width: min(100%, 640px);
    padding: 1.5rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 244, 235, 0.96)),
        var(--surface);
}

.auth-brand-row {
    display: grid;
    justify-items: center;
    gap: 0.9rem;
    margin-bottom: 1rem;
    text-align: center;
}

.auth-logo-button {
    width: 100%;
    min-height: 160px;
    display: grid;
    place-items: center;
    padding: 0.25rem 0;
    border: none;
    cursor: pointer;
    background: transparent;
    border-radius: var(--radius);
}

.auth-logo-button:focus-visible {
    outline: 3px solid rgba(15, 118, 110, 0.24);
    outline-offset: 4px;
}

.auth-logo-image {
    display: block;
    width: min(100%, 320px);
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.auth-title {
    margin: 0;
    font-size: clamp(1.3rem, 4vw, 1.7rem);
    text-align: center;
    font-weight: 700;
}

.panel-title {
    margin: 0.5rem 0 0.9rem;
    font-size: clamp(1.7rem, 4vw, 2rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.panel-copy {
    margin: 0 0 1.1rem;
    color: var(--muted);
    line-height: 1.55;
}

.auth-copy {
    margin: 0 0 1.25rem;
    color: var(--muted);
    line-height: 1.55;
    text-align: center;
    font-size: 0.92rem;
}

.auth-footnote {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(25, 50, 74, 0.08);
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.55;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.66rem;
    font-weight: 800;
    color: var(--brand);
}

.auth-hero h1,
.auth-panel h2,
.app-bar h1 {
    margin: 0.5rem 0 0;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    letter-spacing: -0.02em;
}

.auth-hero p,
.app-bar p,
.soft-copy,
.empty-state-inline {
    color: var(--muted);
    line-height: 1.6;
}

.feature-chips,
.mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.feature-chips span,
.mode-button,
.pill-tag,
.balance,
.bottom-nav-item,
.ghost-button,
.primary-button,
.text-button {
    border-radius: 999px;
}

.feature-chips span {
    padding: 0.75rem 0.9rem;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(25, 50, 74, 0.08);
    text-align: center;
    font-weight: 700;
}

.stack-form {
    display: grid;
    gap: 0.85rem;
}

.form-grid {
    display: grid;
    gap: 0.8rem;
}

.field {
    display: grid;
    gap: 0.45rem;
}

.field span {
    font-size: 0.82rem;
    font-weight: 700;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid rgba(25, 50, 74, 0.12);
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    padding: 0.82rem 0.9rem;
    font-size: 0.92rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.field select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 2.8rem;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 3px),
        calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.field textarea {
    resize: vertical;
    min-height: 100px;
}

#ledger-entity-type {
    min-height: 48px;
    font-weight: 700;
    line-height: 1.2;
}

.amount-field input {
    text-align: right;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

.amount-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid rgba(25, 50, 74, 0.12);
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.92);
    padding: 0 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.amount-prefix {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}

.amount-field .amount-input-wrap input {
    border: none;
    background: transparent;
    box-shadow: none;
    padding-left: 0;
    padding-right: 0;
}

.amount-field .amount-input-wrap input:focus {
    box-shadow: none;
}

.amount-field .amount-input-wrap:focus-within {
    border-color: rgba(15, 118, 110, 0.72);
    box-shadow: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: rgba(15, 118, 110, 0.72);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.field-wide {
    grid-column: 1 / -1;
}

.inline-actions,
.form-actions,
.section-head,
.modal-head,
.activity-item,
.app-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
}

.form-actions {
    flex-wrap: wrap;
}

.form-actions .primary-button,
.form-actions .ghost-button {
    flex: 1 1 240px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.primary-button,
.ghost-button,
.text-button,
.mode-button,
.icon-button {
    border: none;
    cursor: pointer;
    transition: transform var(--transition), opacity var(--transition), background var(--transition), box-shadow var(--transition);
}

.primary-button {
    background: linear-gradient(135deg, var(--brand), #169688);
    color: #fff;
    padding: 0.85rem 1rem;
    font-weight: 800;
    box-shadow: 0 10px 20px rgba(15, 118, 110, 0.16);
}

.ghost-button {
    background: rgba(255, 255, 255, 0.7);
    padding: 0.8rem 0.95rem;
    color: var(--text);
    border: 1px solid rgba(25, 50, 74, 0.08);
}

.text-button {
    background: transparent;
    color: var(--brand);
    font-weight: 800;
    padding: 0;
}

.icon-button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(25, 50, 74, 0.08);
    color: var(--text);
}

.primary-button:hover,
.ghost-button:hover,
.text-button:hover,
.mode-button:hover,
.icon-button:hover {
    transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled {
    opacity: 0.7;
    cursor: wait;
    transform: none;
}

.message-banner {
    padding: 0.9rem 1rem;
    border-radius: var(--radius-small);
    font-weight: 700;
}

.message-error {
    background: rgba(180, 35, 24, 0.1);
    color: var(--danger);
    border: 1px solid rgba(180, 35, 24, 0.16);
}

.message-warning {
    background: rgba(194, 123, 45, 0.14);
    color: #8a5313;
    border: 1px solid rgba(194, 123, 45, 0.22);
}

.message-success {
    background: rgba(18, 122, 102, 0.12);
    color: var(--success);
    border: 1px solid rgba(18, 122, 102, 0.18);
}

.mobile-app-shell {
    min-height: 100vh;
    position: relative;
}

.app-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 34;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid rgba(25, 50, 74, 0.08);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
}

.app-topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: calc(0.7rem + env(safe-area-inset-top, 0)) 1rem 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.app-topbar-copy {
    flex: 1;
    min-width: 0;
}

.app-topbar-copy h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.app-topbar-copy p {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.35;
}

.app-topbar-eyebrow {
    margin-bottom: 0.18rem;
}

.header-icon-button {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    border: 1px solid rgba(25, 50, 74, 0.08);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}

.header-icon-button svg {
    width: 20px;
    height: 20px;
    display: block;
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 800;
    flex-shrink: 0;
}

.profile-avatar-image {
    background: #ffffff;
    border: 1px solid rgba(25, 50, 74, 0.1);
    padding: 2px;
    overflow: hidden;
}

.profile-avatar-image img,
.drawer-user-avatar-image img,
.owner-admin-logo,
.owner-logo-preview img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.profile-avatar svg {
    width: 18px;
    height: 18px;
    display: block;
}

.side-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 0.95rem;
    padding: calc(1rem + env(safe-area-inset-top, 0)) 1rem calc(1rem + env(safe-area-inset-bottom, 0));
    background: #fff;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.18);
    transform: translateX(-100%);
    transition: transform var(--transition);
    z-index: 38;
}

.side-drawer.is-open {
    transform: translateX(0);
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
    z-index: 37;
}

.drawer-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.drawer-head,
.drawer-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
}

.drawer-brand-copy h3 {
    margin: 0.2rem 0 0;
    font-size: 1.05rem;
}

.drawer-user-card {
    justify-content: flex-start;
    padding: 0.85rem;
    border-radius: var(--radius-small);
    background: #f8fafc;
    border: 1px solid rgba(25, 50, 74, 0.08);
}

.drawer-user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
    font-weight: 800;
    flex-shrink: 0;
    overflow: hidden;
}

.drawer-user-avatar-image {
    padding: 2px;
    background: #ffffff;
    border: 1px solid rgba(25, 50, 74, 0.1);
}

.drawer-user-card strong,
.drawer-user-card span {
    display: block;
}

.drawer-user-card span {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.drawer-nav {
    display: grid;
    gap: 0.35rem;
    align-content: start;
}

.drawer-nav-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 0.9rem;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}

.drawer-nav-link.active {
    background: rgba(15, 118, 110, 0.1);
    color: var(--brand-dark);
}

.drawer-nav-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(25, 50, 74, 0.08);
    font-size: 0.65rem;
    font-weight: 900;
}

.drawer-logout-button {
    width: 100%;
}

.app-license-banner {
    margin: 0;
}

.superadmin-shell {
    padding-bottom: 1rem;
}

.app-content {
    display: grid;
    gap: 0.85rem;
    max-width: 1080px;
    margin: 0 auto;
    padding: calc(4.75rem + env(safe-area-inset-top, 0)) 1rem calc(5.95rem + env(safe-area-inset-bottom, 0));
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.metric-card,
.section-card {
    padding: 0.95rem;
}

.dashboard-view {
    --mode-color: #15803d;
    --mode-soft: rgba(220, 252, 231, 0.92);
    --mode-surface: #f0fdf4;
    --mode-line: rgba(21, 128, 61, 0.2);
    --mode-text: #166534;
}

.dashboard-view.mode-sale {
    --mode-color: #15803d;
    --mode-soft: rgba(220, 252, 231, 0.92);
    --mode-surface: #f0fdf4;
    --mode-line: rgba(21, 128, 61, 0.2);
    --mode-text: #166534;
}

.dashboard-view.mode-purchase {
    --mode-color: #b45309;
    --mode-soft: rgba(254, 243, 199, 0.92);
    --mode-surface: #fffbeb;
    --mode-line: rgba(180, 83, 9, 0.2);
    --mode-text: #92400e;
}

.dashboard-view.mode-receipt {
    --mode-color: #2563eb;
    --mode-soft: rgba(219, 234, 254, 0.92);
    --mode-surface: #eff6ff;
    --mode-line: rgba(37, 99, 235, 0.2);
    --mode-text: #1d4ed8;
}

.dashboard-view.mode-payment {
    --mode-color: #be123c;
    --mode-soft: rgba(255, 228, 230, 0.92);
    --mode-surface: #fff1f2;
    --mode-line: rgba(190, 18, 60, 0.18);
    --mode-text: #9f1239;
}

.metric-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(249, 244, 236, 0.92));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metric-card span,
.metric-card small {
    display: block;
}

.metric-card span {
    color: var(--muted);
    font-size: 0.76rem;
}

.metric-card strong {
    display: block;
    margin: 0.35rem 0;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.metric-card small {
    color: var(--muted);
    line-height: 1.5;
}

.section-head h3 {
    margin: 0.35rem 0 0;
    font-size: 1.02rem;
}

.mode-button {
    background: rgba(255, 255, 255, 0.72);
    padding: 0.8rem 0.85rem;
    font-weight: 800;
    border: 1px solid rgba(25, 50, 74, 0.1);
    font-size: 0.86rem;
}

.dashboard-view .mode-button.active {
    background: var(--mode-color);
    color: #fff;
    box-shadow: 0 10px 20px rgba(25, 50, 74, 0.12);
}

.pill-tag {
    padding: 0.48rem 0.8rem;
    font-size: 0.74rem;
    font-weight: 800;
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.dashboard-view .pill-tag {
    background: var(--mode-soft);
    color: var(--mode-text);
}

.dashboard-view .entry-form-card {
    background: var(--mode-surface);
    border-color: var(--mode-line);
}

.dashboard-view .entry-form-card .field input,
.dashboard-view .entry-form-card .field textarea,
.dashboard-view .entry-form-card .field select {
    border-color: var(--mode-line);
    background: rgba(255, 255, 255, 0.96);
}

.dashboard-view .entry-form-card .field input:focus,
.dashboard-view .entry-form-card .field textarea:focus,
.dashboard-view .entry-form-card .field select:focus {
    border-color: var(--mode-color);
    box-shadow: 0 0 0 4px var(--mode-soft);
}

.dashboard-view .entry-form-card .amount-input-wrap {
    border-color: var(--mode-line);
}

.dashboard-view .entry-form-card .amount-input-wrap:focus-within {
    border-color: var(--mode-color);
    box-shadow: none;
}

.dashboard-view .entry-form-card .amount-field input:focus {
    box-shadow: none;
}

.dashboard-view .lookup-panel {
    border-color: var(--mode-line);
}

.lookup-panel {
    display: grid;
    gap: 0.65rem;
    margin-top: -0.25rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(25, 50, 74, 0.1);
}

.lookup-field .lookup-panel {
    gap: 0.38rem;
    margin-top: 0.1rem;
    padding: 0.38rem;
    max-height: 170px;
    overflow-y: auto;
    border-radius: 14px;
}

.lookup-panel.is-hidden {
    display: none;
}

.lookup-item {
    width: 100%;
    text-align: left;
    padding: 0.85rem 0.95rem;
    border-radius: var(--radius-small);
    background: rgba(239, 231, 220, 0.72);
    border: 1px solid transparent;
}

.lookup-item strong,
.lookup-item span {
    display: block;
}

.lookup-item span {
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.76rem;
}

.lookup-item:hover {
    border-color: rgba(15, 118, 110, 0.2);
    background: var(--brand-soft);
}

.dashboard-view .lookup-item:hover {
    border-color: var(--mode-line);
    background: var(--mode-soft);
}

.lookup-field .lookup-item {
    padding: 0.56rem 0.68rem;
    border-radius: 12px;
}

.lookup-field .lookup-item strong {
    font-size: 0.8rem;
    line-height: 1.3;
}

.lookup-field .lookup-item span {
    margin-top: 0.14rem;
    font-size: 0.68rem;
    line-height: 1.25;
}

.activity-list {
    display: grid;
    gap: 0.8rem;
}

.owner-admin-list {
    display: grid;
    gap: 0.9rem;
}

.owner-admin-card {
    padding: 1rem;
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(25, 50, 74, 0.08);
    display: grid;
    gap: 0.75rem;
}

.owner-admin-top,
.owner-admin-actions,
.owner-admin-meta,
.owner-admin-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.owner-admin-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: min(100%, 280px);
}

.owner-admin-logo {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 16px;
    border: 1px solid rgba(25, 50, 74, 0.1);
    background: #ffffff;
    overflow: hidden;
}

.owner-admin-logo-fallback {
    display: grid;
    place-items: center;
    background: rgba(15, 118, 110, 0.12);
    color: var(--brand-dark);
    font-weight: 800;
}

.owner-admin-top strong,
.owner-admin-top span,
.owner-admin-meta span,
.owner-admin-foot span {
    display: block;
}

.owner-admin-top span,
.owner-admin-meta span,
.owner-admin-foot span,
.owner-admin-address,
.owner-license-copy {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.45;
}

.owner-admin-address {
    margin: 0;
}

.owner-logo-field input[type="file"] {
    padding: 0.72rem;
}

.owner-logo-hint,
.owner-logo-remove {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.owner-logo-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid rgba(25, 50, 74, 0.08);
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.72);
}

.owner-logo-preview img {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    border: 1px solid rgba(25, 50, 74, 0.1);
    flex-shrink: 0;
}

.owner-logo-remove {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
}

.owner-logo-remove input {
    width: auto;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.78rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
}

.status-good {
    background: rgba(15, 118, 110, 0.12);
    color: var(--brand-dark);
}

.status-warn {
    background: rgba(194, 123, 45, 0.14);
    color: #8a5313;
}

.status-danger {
    background: rgba(180, 35, 24, 0.12);
    color: var(--danger);
}

.status-muted {
    background: rgba(25, 50, 74, 0.08);
    color: var(--muted);
}

.activity-item {
    display: block;
    width: 100%;
    padding: 0.85rem 0.9rem;
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(25, 50, 74, 0.08);
}

.activity-item span {
    color: var(--muted);
    font-size: 0.76rem;
}

.activity-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
    width: 100%;
}

.activity-left {
    min-width: 0;
    flex: 1;
    display: grid;
    gap: 0.36rem;
}

.activity-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    white-space: nowrap;
    justify-self: end;
}

.activity-meta-line,
.entry-action-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.activity-meta-line {
    min-width: 0;
    flex: 1;
    flex-wrap: wrap;
}

.activity-entity-name,
.activity-amount {
    display: block;
}

.activity-entity-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-amount {
    white-space: nowrap;
    font-size: 0.94rem;
}

.activity-ref-no,
.activity-date {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    white-space: nowrap;
}

.activity-kind {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.24rem 0.55rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
}

.activity-kind-sale {
    background: rgba(21, 128, 61, 0.14);
    color: #166534;
}

.activity-kind-purchase {
    background: rgba(180, 83, 9, 0.16);
    color: #92400e;
}

.activity-kind-receipt {
    background: rgba(37, 99, 235, 0.14);
    color: #1d4ed8;
}

.activity-kind-payment {
    background: rgba(190, 18, 60, 0.14);
    color: #9f1239;
}

.activity-settlement {
    display: inline-flex;
    align-items: center;
    max-width: 220px;
    padding: 0.2rem 0.48rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-settlement.is-paid {
    background: rgba(21, 128, 61, 0.14);
    color: #166534;
}

.activity-settlement.is-partial {
    background: rgba(180, 83, 9, 0.16);
    color: #92400e;
}

.activity-settlement.is-open {
    background: rgba(190, 18, 60, 0.12);
    color: #9f1239;
}

.activity-settlement.is-info {
    background: rgba(37, 99, 235, 0.14);
    color: #1d4ed8;
}

.activity-settlement.is-advance {
    background: rgba(8, 145, 178, 0.14);
    color: #0f766e;
}

.transaction-save-button {
    background: var(--brand);
}

.dashboard-view .transaction-save-button {
    background: var(--mode-color);
    box-shadow: none;
}

.inline-balance-panel {
    padding: 0;
}

.inline-balance-box {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0.7rem 0.85rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--mode-line);
    white-space: nowrap;
    scrollbar-width: thin;
}

.inline-balance-box strong {
    font-size: 0.82rem;
    flex: 0 0 auto;
}

.inline-balance-box span {
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.4;
}

.inline-balance-text {
    flex: 0 0 auto;
}

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

.table-entry-actions {
    justify-content: flex-end;
}

.entry-icon-row {
    flex-wrap: nowrap;
}

.entry-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(25, 50, 74, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.entry-icon-button:hover {
    transform: translateY(-1px);
    border-color: rgba(25, 50, 74, 0.18);
    background: #ffffff;
}

.entry-icon-button svg {
    width: 16px;
    height: 16px;
}

.entry-print-button {
    color: var(--brand-dark);
}

.due-register-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.balance {
    display: inline-flex;
    padding: 0.38rem 0.62rem;
    font-size: 0.72rem;
    font-weight: 800;
}

.balance.positive {
    background: rgba(15, 118, 110, 0.12);
    color: var(--brand-dark);
}

.balance.negative {
    background: rgba(182, 84, 59, 0.12);
    color: var(--rose);
}

.balance.neutral {
    background: rgba(25, 50, 74, 0.08);
    color: var(--muted);
}

.table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    touch-action: pan-x;
}

.data-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid rgba(25, 50, 74, 0.08);
    vertical-align: top;
    font-size: 0.84rem;
}

.data-table th {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
}

.ledger-number-cell {
    text-align: right !important;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ledger-note {
    margin-top: 0.35rem;
    color: var(--muted);
    line-height: 1.45;
}

.ledger-summary-row td {
    background: rgba(25, 50, 74, 0.04);
}

.table-scroll-caption {
    margin-bottom: 0.55rem;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.4;
}

.mobile-card-list {
    display: none;
}

.mobile-list-card {
    display: grid;
    gap: 0.7rem;
    padding: 0.9rem;
    border: 1px solid rgba(25, 50, 74, 0.08);
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.88);
}

.mobile-list-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.mobile-list-head strong,
.mobile-list-head span,
.mobile-list-meta small,
.mobile-list-meta span {
    display: block;
}

.mobile-list-head span {
    margin-top: 0.18rem;
    color: var(--muted);
    font-size: 0.8rem;
}

.mobile-list-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.mobile-list-meta small {
    color: var(--muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.mobile-list-meta span {
    margin-top: 0.18rem;
    color: var(--text);
    font-size: 0.82rem;
    line-height: 1.4;
    word-break: break-word;
}

.mobile-due-amount {
    color: var(--brand-dark);
    font-size: 0.92rem;
}

.empty-table,
.empty-state-card,
.empty-state-inline {
    color: var(--muted);
}

.empty-state-card {
    text-align: center;
}

.loading-card {
    display: grid;
    gap: 1rem;
    justify-items: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 4px solid rgba(15, 118, 110, 0.12);
    border-top-color: var(--brand);
    animation: spin 900ms linear infinite;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0.55rem 0.7rem calc(0.55rem + env(safe-area-inset-bottom, 0));
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid rgba(25, 50, 74, 0.08);
    box-shadow: 0 -10px 20px rgba(25, 50, 74, 0.08);
    z-index: 33;
}

.bottom-nav-single {
    grid-template-columns: minmax(0, 1fr);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
    padding: 0.52rem 0.35rem;
    text-align: center;
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
}

.bottom-nav-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: rgba(25, 50, 74, 0.08);
    font-size: 0.6rem;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.bottom-nav-label {
    line-height: 1;
    font-size: 0.7rem;
}

.bottom-nav-item.active {
    color: var(--brand-dark);
    background: rgba(15, 118, 110, 0.12);
    border-color: rgba(15, 118, 110, 0.12);
}

.bottom-nav-item.active .bottom-nav-icon {
    background: var(--brand);
    color: #fff;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(25, 50, 74, 0.4);
    z-index: 40;
}

.modal-card {
    width: min(100%, 460px);
    padding: 1.2rem;
    border-radius: var(--radius);
    background: var(--surface-strong);
    box-shadow: 0 26px 64px rgba(25, 50, 74, 0.22);
}

.toast-region {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 5.25rem;
    display: grid;
    gap: 0.7rem;
    z-index: 45;
}

.toast-item {
    padding: 0.9rem 1rem;
    border-radius: var(--radius-small);
    color: #fff;
    box-shadow: 0 18px 40px rgba(25, 50, 74, 0.2);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--transition), transform var(--transition);
}

.toast-success {
    background: linear-gradient(135deg, var(--success), var(--brand));
}

.toast-error {
    background: linear-gradient(135deg, var(--danger), #d92d20);
}

.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

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

    .mode-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .bottom-nav {
        max-width: 1080px;
        margin: 0 auto;
    }

    .activity-left {
        overflow: hidden;
    }

    .activity-meta-line {
        flex-wrap: nowrap;
    }

    .activity-right {
        min-width: max-content;
        gap: 0.65rem;
        margin-left: auto;
        justify-self: end;
    }

    .activity-right .entry-icon-row {
        justify-content: flex-end;
    }
}

@media (max-width: 640px) {
    .app-topbar-copy p {
        display: none;
    }

    .metric-grid {
        gap: 0.65rem;
    }

    .metric-card {
        padding: 0.72rem;
        border-radius: 18px;
    }

    .metric-card span {
        font-size: 0.7rem;
    }

    .metric-card strong {
        margin: 0.22rem 0;
        font-size: 0.94rem;
        line-height: 1.2;
    }

    .metric-card small {
        font-size: 0.72rem;
        line-height: 1.3;
    }

    .desktop-table-scroll {
        display: none;
    }

    .wide-table-scroll {
        display: block;
    }

    .mobile-card-list {
        display: grid;
        gap: 0.75rem;
    }

    .owner-admin-actions {
        width: 100%;
    }

    .owner-admin-actions .ghost-button {
        width: 100%;
    }

    .data-table {
        min-width: 560px;
    }

    .table-scroll {
        padding-bottom: 0.15rem;
    }

    .table-scroll-caption {
        font-size: 0.72rem;
    }

    .mobile-list-meta {
        grid-template-columns: 1fr;
    }

    .activity-main {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.55rem;
        align-items: flex-start;
    }

    .activity-left {
        gap: 0.4rem;
    }

    .activity-right {
        width: 100%;
        justify-content: space-between;
    }
}

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

    .toast-region {
        left: auto;
        right: 1.25rem;
        width: 360px;
    }
}
