:root {
    --color-primary: #1f4e5f;
    --color-primary-dark: #163946;

    --color-secondary: #6c757d;
    --color-secondary-dark: #565e64;

    --color-success: #2e7d32;
    --color-success-dark: #1b5e20;

    --color-warning: #f0ad4e;
    --color-warning-dark: #d99632;

    --color-danger: #b00020;
    --color-danger-dark: #8a0019;

    --color-info: #0d6efd;
    --color-info-dark: #0a58ca;

    --color-light: #f7f7f7;
    --color-border: #dddddd;
    --color-text: #222222;
    --color-muted: #666666;
    --color-white: #ffffff;

    --page-max-width: 1200px;
    --border-radius: 5px;
}

/* Base page layout */

body {
    font-family: Arial, sans-serif;
    margin: 30px;
    color: var(--color-text);
    background: var(--color-white);
}

.page-wrap {
    max-width: var(--page-max-width);
    margin: 0 auto;
}

h1,
h2,
h3 {
    color: var(--color-text);
}

a {
    color: var(--color-info);
}

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

/* Logo / header */

.logo-header {
    width: 100%;
    text-align: center;
    margin: 0 auto 5px auto;
}

.logo-header img {
    display: block;
    margin: 0 auto;
    max-width: 220px;
    max-height: 140px;
    height: auto;
}

.logo-header .business-name {
    margin-top: 8px;
    font-size: 22px;
    font-weight: bold;
    text-align: center;
}

.page-heading {
    text-align: center;
}

/* Buttons */

.button,
button,
input[type="submit"] {
    display: inline-block;
    padding: 8px 12px;
    border: 0;
    border-radius: var(--border-radius);
    text-decoration: none;
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.2;
    background: var(--color-primary);
    color: var(--color-white);
    margin-right: 8px;
    margin-top: 8px;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
    background: var(--color-primary-dark);
}

.button.primary {
    background: var(--color-primary);
}

.button.primary:hover {
    background: var(--color-primary-dark);
}

.button.secondary {
    background: var(--color-secondary);
}

.button.secondary:hover {
    background: var(--color-secondary-dark);
}

.button.success {
    background: var(--color-success);
}

.button.success:hover {
    background: var(--color-success-dark);
}

.button.warning {
    background: var(--color-warning);
    color: #222;
}

.button.warning:hover {
    background: var(--color-warning-dark);
    color: #222;
}

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

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

.button.info {
    background: var(--color-info);
}

.button.info:hover {
    background: var(--color-info-dark);
}

/* Forms */

label {
    display: block;
    margin-top: 5px;
    font-weight: bold;
    margin-bottom: 5px;
}

input,
textarea,
select {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    margin-top: 5px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-family: Arial, sans-serif;
    font-size: 14px;
}

textarea {
    min-height: 60px;
}

/* Tables */

table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 20px;
}

th,
td {
    border-bottom: 1px solid var(--color-border);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

.num {
    text-align: right;
    white-space: nowrap;
}

th {
    background: #f3f3f3;
}

.num {
    text-align: right;
    white-space: nowrap;
}

.nowrap {
    white-space: nowrap;
}

/* Panels / alerts */

.panel {
    border: 1px solid var(--color-border);
    background: #fafafa;
    padding: 15px;
    margin-top: 20px;
    border-radius: var(--border-radius);
}

.errors {
    background: #ffe5e5;
    border: 1px solid #cc9999;
    padding: 10px;
    margin-top: 15px;
    border-radius: var(--border-radius);
}

.success-message {
    background: #e5ffe8;
    border: 1px solid #99cc99;
    padding: 10px;
    margin-top: 15px;
    border-radius: var(--border-radius);
}

.warning-message {
    background: #fff8df;
    border: 1px solid #e1c766;
    padding: 12px;
    margin-top: 15px;
    border-radius: var(--border-radius);
}

/* Summary cards */

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.summary-card {
    border: 1px solid var(--color-border);
    background: var(--color-white);
    padding: 12px;
    border-radius: var(--border-radius);
    text-align: center;
}

.summary-card .label {
    color: var(--color-muted);
    font-size: 13px;
    text-align: center;
}

.summary-card .value {
    font-size: 20px;
    font-weight: bold;
    margin-top: 5px;
    text-align: center;
}

.summary-card .muted {
    text-align: center;
}

.summary-card.total {
    background: #eef8ee;
    border-color: #b7d8b7;
}

.heading-value {
    color: var(--color-info);
}

.page-title-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 20px;
    width: 100%;
}

.title-left {
    text-align: left;
}

.title-center {
    text-align: center;
}

.title-center h1 {
    margin: 0;
}

.title-right {
    text-align: right;
}

.app-title-row {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 20px;
    position: relative;
}

.app-title-left {
    width: 200px;
    text-align: left;
}

.app-title-main {
    flex: 1;
    text-align: center;
}

.app-title-main h1 {
    margin: 0;
}

.app-title-right {
    width: 200px;
}

.summary {
    width: 360px;
    margin-left: auto;
    margin-top: 25px;
    border: 1px solid #ddd;
    background: #fafafa;
    padding: 15px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
}

.summary-row.total {
    border-top: 2px solid #333;
    margin-top: 8px;
    padding-top: 10px;
    font-weight: bold;
    font-size: 1.1em;
}


.ai-loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.ai-loading-overlay.active {
    display: flex;
}

.ai-loading-box {
    width: min(420px, 90%);
    padding: 28px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.ai-loading-box h2 {
    margin-top: 15px;
    margin-bottom: 8px;
}

.ai-loading-box p {
    margin: 8px 0;
}

.ai-spinner {
    width: 46px;
    height: 46px;
    margin: 0 auto;
    border: 5px solid #dddddd;
    border-top-color: var(--color-info);
    border-radius: 50%;
    animation: ai-spin 0.9s linear infinite;
}

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

.logo-header-home {
    text-align: center;
    margin-bottom: 15px;
}

.logo-header-home a {
    display: inline-block;
}

.logo-header-home img {
    max-width: 420px;
    max-height: 340px;
    height: auto;
    cursor: pointer;
}


.shared-page-title h1 {
    margin: 0;
}

.shared-action-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: 100%;
    margin-bottom: 18px;
}

.shared-action-left,
.shared-action-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.shared-action-right {
    margin-left: auto;
    justify-content: right;
}

.shared-action-row .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    margin-top: 0;
    margin-bottom: 0;
    white-space: nowrap;
}

.signed-in-user {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    line-height: 1.2;
}

@media (max-width: 850px) {
    .shared-action-row {
        flex-wrap: wrap;
    }

    .shared-action-left,
    .shared-action-right {
        width: 100%;
    }

    .shared-action-left {
        justify-content: flex-start;
    }

    .shared-action-right {
        justify-content: flex-end;
        margin-left: 0;
    }
}



.shared-page-title {
    text-align: center;
    margin-bottom: 1px;
}

.shared-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--color-border);
    padding: 0 0 16px 0;
}