:root
{
    --banner-background: #232323;
    --banner-border: #afd134;
    --button-background: #afd134;
    --button-deny-background: #232323;
    --button-text: #ffffff;
    --surface: #ffffff;
    --surface-soft: #f7f7f7;
    --border: #d9d9d9;
    --text: #232323;
    --text-soft: #666666;
    --danger: #b42318;
    --success: #027a48;
}

*
{
    box-sizing: border-box;
}

body
{
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f5f5;
    color: var(--text);
    padding-bottom: 88px;
}

.hidden
{
    display: none;
}

/* Login */

.login-wrapper
{
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #232323 0%, #3a3a3a 100%);
}

.login-card
{
    width: 100%;
    max-width: 980px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--banner-background);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.brand-panel
{
    background: var(--banner-background);
    color: #ffffff;
    padding: 48px;
    border-right: 5px solid var(--banner-border);
    border-top-left-radius: 18px;
    border-bottom-left-radius: 18px;
}

.form-panel
{
    background: var(--surface-soft);
    padding: 48px;
    border-top-right-radius: 18px;
    border-bottom-right-radius: 18px;
}

.brand-logo
{
    width: 160px;
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 20px;
}

.brand-title,
.panel-heading,
.page-title,
.panel-title
{
    margin: 0 0 12px 0;
}

.brand-text
{
    color: #d9d9d9;
    margin: 0 0 18px 0;
}

.panel-subheading,
.page-intro
{
    color: var(--text-soft);
    margin: 0 0 18px 0;
}

.demo-credentials
{
    margin-top: 18px;
    font-size: 13px;
    color: var(--text-soft);
}

.form-feedback
{
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
}

.form-feedback.error
{
    background: #fef3f2;
    color: var(--danger);
}

.form-feedback.success
{
    background: #ecfdf3;
    color: var(--success);
}

/* App layout */

.app-shell
{
    min-height: 100vh;
    display: flex;
}

.app-sidebar
{
    width: 260px;
    background: var(--banner-background);
    color: #ffffff;
    padding: 24px 0;
}

.sidebar-brand
{
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.sidebar-logo
{
    width: 150px;
    max-width: 100%;
    height: auto;
    display: block;
}

.sidebar-brand-text
{
    font-size: 20px;
    font-weight: bold;
    color: #ffffff;
}

.sidebar-menu
{
    padding: 20px 0;
}

.nav-link
{
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: #ffffff;
    text-decoration: none;
}

.nav-link:hover,
.nav-link.active
{
    background: #afd134;
    color: #232323;
}

.nav-icon
{
    width: 18px;
    text-align: center;
}

.app-content
{
    flex: 1;
    padding: 32px;
}

.page-header
{
    margin-bottom: 24px;
}

.page-title
{
    margin: 0 0 8px 0;
}

.page-intro
{
    margin: 0;
    color: var(--text-soft);
}

/* Dashboard */

.welcome-panel
{
    background: var(--banner-background);
    color: #ffffff;
    margin-bottom: 24px;
}

.welcome-logo
{
    width: 180px;
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 16px;
}

.dashboard-stats
{
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-card,
.panel
{
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    padding: 20px;
}

.dashboard-card-label
{
    font-size: 13px;
    color: var(--text-soft);
    margin-bottom: 10px;
}

.dashboard-card-value
{
    font-size: 30px;
    font-weight: bold;
}

/* Forms */

.app-form
{
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.form-group
{
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label
{
    font-weight: bold;
    font-size: 14px;
}

.form-control,
select.form-control,
textarea.form-control
{
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font-size: 14px;
    -webkit-appearance: none;
    appearance: none;
}

select.form-control
{
    padding-right: 38px;
    background-image: linear-gradient(45deg, transparent 50%, #555555 50%), linear-gradient(135deg, #555555 50%, transparent 50%);
    background-position: calc(100% - 18px) 18px, calc(100% - 12px) 18px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

select.form-control[multiple]
{
    background-image: none;
    padding-right: 12px;
}

textarea.form-control
{
    min-height: 120px;
    padding: 12px;
    resize: vertical;
}

.select2-container
{
    width: 100% !important;
}

.select2-container--default .select2-selection--single
{
    min-height: 42px;
    height: auto;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    background: #ffffff;
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered
{
    color: #333333;
    line-height: 40px;
    padding-left: 12px;
    padding-right: 34px;
    font-size: 14px;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder
{
    color: #9a9a9a;
}

.select2-container--default .select2-selection--single .select2-selection__arrow
{
    height: 40px;
    right: 8px;
}

.select2-container--default .select2-selection--single .select2-selection__clear
{
    height: 40px;
    line-height: 40px;
    margin-right: 24px;
    color: #222222;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single
{
    border-color: #afd134;
    box-shadow: 0 0 0 2px rgba(175, 209, 52, 0.18);
}

.select2-dropdown
{
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    overflow: hidden;
}

.select2-container--default .select2-search--dropdown .select2-search__field
{
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    padding: 8px 10px;
    outline: none;
}

.select2-container--default .select2-results__option
{
    padding: 8px 12px;
    font-size: 14px;
}

.form-actions,
.button-row,
.toolbar
{
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar
{
    margin-bottom: 20px;
    justify-content: space-between;
}

.button
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 11px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: #e9e9e9;
    color: #232323;
    text-decoration: none;
    cursor: pointer;
    font-weight: bold;
    line-height: 1.2;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

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

.button-secondary
{
    background: #ffffff;
    border-color: var(--border);
    color: var(--text);
}

.button-danger
{
    background: #232323;
    color: #ffffff;
}

.sub-panel
{
    margin-top: 20px;
}

.permission-block
{
    margin-bottom: 18px;
}

.permission-title
{
    font-weight: bold;
    margin-bottom: 10px;
}

.permission-row
{
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.permission-item
{
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tables */

.app-table
{
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

.app-table th,
.app-table td
{
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid #e5e5e5;
    vertical-align: top;
}

.table-link
{
    color: #21759b;
    text-decoration: none;
}

/* Line items */

.line-items-panel
{
    margin-top: 24px;
    margin-bottom: 24px;
}

.line-items-container
{
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.quote-line-item-row
{
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
    padding: 14px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    background: #fafafa;
}

.invoice-line-item-row
{
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    align-items: end;
    padding: 14px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    background: #fafafa;
}

.quote-line-item-row .form-group,
.invoice-line-item-row .form-group
{
    min-width: 0;
}

.invoice-line-item-row .line-item-description
{
    grid-column: span 5;
}

.invoice-line-item-row .line-item-quantity,
.invoice-line-item-row .line-item-unit,
.invoice-line-item-row .line-item-unit-price,
.invoice-line-item-row .line-item-amount
{
    grid-column: span 1;
}

.invoice-line-item-row .line-item-remove
{
    grid-column: span 2;
}

.invoice-line-item-row .line-item-remove .button
{
    width: 100%;
}

.line-item-product
{
    grid-column: span 8;
}

.line-item-description,
.line-item-quantity,
.line-item-guarantee,
.line-item-colour,
.line-item-price,
.line-item-total
{
    grid-column: span 2;
}

.line-item-unit
{
    grid-column: span 4;
}

.line-item-approved,
.line-item-optional
{
    grid-column: span 1;
}

.line-item-heading,
.line-item-heading-duration
{
    grid-column: span 3;
}

.line-item-remove
{
    grid-column: 1 / -1;
}

.line-item-remove .button
{
    width: 100%;
}

.line-item-description,
.line-item-amount,
.line-item-remove
{
    min-width: 0;
}

/* Drawing */

.drawing-toolbar
{
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
}

.drawing-tool-button.active
{
    background: #afd134;
    color: #232323;
}

.drawing-color-picker
{
    width: 52px;
    height: 42px;
    padding: 0;
    border: 1px solid #cccccc;
    border-radius: 8px;
    background: #ffffff;
}

.drawing-size-select
{
    width: 110px;
}

.worksheet-canvas {
    width: 100%;
    max-width: 1000px;
    height: auto;
    display: block;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    background-color: #ffffff;
    background-image:
        linear-gradient(#eeeeee 1px, transparent 1px),
        linear-gradient(90deg, #eeeeee 1px, transparent 1px);
    background-size: 20px 20px;
    cursor: crosshair;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.table-actions .table-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 8px 11px;
    border-radius: 7px;
    background: #f1f1f1;
    color: #1f5f8b;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.table-actions .table-link:hover {
    background: #dfefff;
    color: #0f3d63;
    text-decoration: none;
}

.table-actions .table-action-delete {
    color: #a60000;
}

.table-actions .table-action-delete:hover {
    background: #ffe4e4;
    color: #750000;
}

.permission-matrix {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
}

.permission-matrix-row {
    display: flex;
    min-width: max-content;
    border-bottom: 1px solid #e5e5e5;
}

.permission-matrix-row:last-child {
    border-bottom: 0;
}

.permission-matrix-header {
    font-weight: 700;
    background: #f6f6f6;
    position: sticky;
    top: 0;
    z-index: 1;
}

.permission-matrix-resource {
    width: 220px;
    min-width: 220px;
    padding: 10px;
    border-right: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    background: #ffffff;
}

.permission-matrix-header .permission-matrix-resource {
    background: #f6f6f6;
}

.permission-matrix-cell {
    width: 110px;
    min-width: 110px;
    padding: 10px;
    border-right: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.permission-matrix-cell:last-child {
    border-right: 0;
}

.permission-checkbox {
    width: 18px;
    height: 18px;
}


.form-actions-sticky
{
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin: 24px -20px -20px -20px;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid #e5e5e5;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(4px);
}

.form-actions-sticky .button-primary
{
    min-width: 150px;
}

.unsaved-changes-notice
{
    display: none;
    color: #8a4b00;
    font-size: 13px;
    font-weight: 700;
    margin-left: auto;
}

form.is-dirty .unsaved-changes-notice
{
    display: inline-flex;
}

.checkbox-group,
.checkbox-label,
.permission-item
{
    min-height: 36px;
}

.checkbox-label
{
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type='checkbox'],
.checkbox-label input[type='radio'],
.form-checkbox,
.permission-checkbox
{
    width: 18px;
    height: 18px;
    margin-top: 1px;
    flex: 0 0 auto;
}

.quote-summary-category
{
    margin-top: 18px;
}

.summary-category-title
{
    margin: 0 0 10px 0;
}

.quote-summary-checkbox-label
{
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    background: #fafafa;
    margin-bottom: 8px;
}

.quote-summary-checkbox-label:hover
{
    background: #f2f8df;
    border-color: #d6e99a;
}

/* Responsive */

@media(max-width: 900px)
{
    .login-card
    {
        grid-template-columns: 1fr;
    }

    .brand-panel,
    .form-panel
    {
        padding: 20px;
        border-radius: 0;
    }

    .app-shell
    {
        flex-direction: column;
    }

    .app-sidebar
    {
        width: 100%;
        padding: 20px 0;
    }

    .app-content
    {
        padding: 20px;
    }

    .form-row
    {
        grid-template-columns: 1fr;
    }

    .dashboard-stats
    {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quote-line-item-row,
    .invoice-line-item-row
    {
        grid-template-columns: 1fr;
    }

    .quote-line-item-row .form-group,
    .invoice-line-item-row .form-group
    {
        grid-column: 1 / -1;
    }
}
.quote-heading-summary-panel
{
    margin-top: 18px;
}

.quote-heading-summary-rows
{
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quote-heading-summary-row
{
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 160px minmax(180px, 260px);
    gap: 12px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #ffffff;
}

.quote-heading-summary-name
{
    font-size: 0.95rem;
}

.quote-heading-summary-total
{
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.heading-summary-badge
{
    display: inline-block;
    margin-left: 8px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: #f1f1f1;
    color: #555555;
}

.quote-summary-item
{
    margin-bottom: 10px;
}

.quote-summary-override
{
    margin: 8px 0 12px 28px;
}

.quote-summary-override.hidden
{
    display: none;
}

.quote-summary-override-text
{
    min-height: 130px;
}

.line-item-approved,
.line-item-heading-duration
{
    min-width: 135px;
}

@media(max-width: 900px)
{
    .quote-heading-summary-row
    {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .quote-heading-summary-total
    {
        text-align: left;
    }
}
