:root {
    --bg: #f4f7fb;
    --bg-soft: #ffffff;
    --bg-muted: #eef3f9;
    --line: #d6e0ea;
    --line-strong: #c4d1de;
    --text: #1d2938;
    --text-muted: #63748a;
    --brand: #0b6bcb;
    --brand-dark: #0b4e93;
    --ok: #198754;
    --danger: #c83f4d;
    --radius: 10px;
    --shadow: 0 8px 28px rgba(30, 58, 93, 0.08);
}

html,
body {
    background: radial-gradient(circle at top right, #ecf5ff 0%, var(--bg) 45%) fixed;
    color: var(--text);
    font-family: "IBM Plex Sans", "Segoe UI", Tahoma, sans-serif;
}

h1,
.h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

h2,
.h2 {
    font-size: 1.1rem;
}

main > .container {
    padding: 64px 12px 14px;
}

.app-shell {
    max-width: 1320px;
}

.navbar {
    background: linear-gradient(120deg, #0f2239 0%, #132f4e 100%) !important;
    box-shadow: 0 3px 16px rgba(12, 24, 42, 0.25);
    min-height: 54px;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.navbar-dark .navbar-brand {
    color: #f6fbff;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.navbar-dark .navbar-nav .nav-link,
.navbar-dark .navbar-nav .dropdown-item {
    font-size: 0.88rem;
}

.dropdown-menu {
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(20, 41, 67, 0.12);
    padding: 0.25rem;
}

.dropdown-item {
    border-radius: 6px;
    padding: 0.28rem 0.55rem;
}

.breadcrumb {
    margin-bottom: 0.7rem;
    padding: 0.38rem 0.58rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbff;
}

.card,
.grid-view,
.estimate-search,
.resource-search,
.login-box .card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background-color: var(--bg-soft);
}

.grid-view,
.estimate-search,
.resource-search {
    padding: 0.85rem;
    margin-bottom: 1rem;
}

.estimate-index > p,
.resource-index > p {
    margin-bottom: 0.6rem;
}

.nav-tabs {
    border-bottom: 1px solid var(--line-strong);
    gap: 0.35rem;
}

.nav-tabs .nav-link {
    border: 1px solid var(--line);
    background-color: #f8fbff;
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 600;
    border-radius: 8px 8px 0 0;
    padding: 0.35rem 0.7rem;
}

.nav-tabs .nav-link.active {
    background-color: #ffffff;
    color: var(--text);
    border-color: var(--line-strong);
    border-bottom-color: #ffffff;
}

.tab-content {
    border: 1px solid var(--line-strong);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 0.55rem;
    background-color: #fff;
}

table td {
    font-size: 13px;
}

.table {
    margin-bottom: 0;
}

.table th,
.table td {
    padding: 0.42rem 0.5rem;
    vertical-align: middle;
}

.table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background-color: #f2f7fd;
    border-bottom-width: 1px;
}

.table-bordered,
.table-bordered td,
.table-bordered th {
    border-color: var(--line);
}

.table-hover tbody tr:hover {
    background-color: #f7fbff;
}

tfoot tr td:first-child {
    text-align: center;
    vertical-align: middle;
}

.table-bordered thead td a,
.table-bordered thead th,
.table-bordered thead td {
    font-size: 11px;
    color: var(--text-muted);
}

input.quantity_input,
input.price_input,
input.margin_input {
    border: 1px solid transparent;
    background: transparent;
    text-align: right;
    border-radius: 6px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

input.quantity_input {
    width: 58px;
}

input.price_input {
    width: 72px;
}

input.margin_input {
    width: 38px;
}

input.quantity_input:focus,
input.price_input:focus,
input.margin_input:focus,
input.estimate-section-name:focus {
    background-color: #f4f9ff;
    border-color: #87b9ed;
    outline: none;
}

input.estimate-section-name {
    border: 1px solid transparent;
    width: 100%;
    font-size: 1.12rem;
    font-weight: 700;
    color: #153a61;
    border-radius: 8px;
    padding: 0.1rem 0.3rem;
}

.twitter-typeahead .tt-input {
    height: calc(2.05rem + 2px);
    padding: 0.28rem 0.5rem;
    font-size: 14px;
    border-radius: 7px;
    border: 1px solid var(--line);
}

.form-group {
    margin-bottom: 0.65rem;
}

.form-control {
    height: calc(2.05rem + 2px);
    padding: 0.28rem 0.5rem;
    font-size: 14px;
    border-color: var(--line-strong);
    border-radius: 7px;
}

select.form-control,
.custom-select {
    height: calc(2.05rem + 2px);
    border-radius: 7px;
}

.form-control:focus {
    border-color: #7fb6ea;
    box-shadow: 0 0 0 0.12rem rgba(11, 107, 203, 0.12);
}

.select2-container {
    font-size: 14px;
}

.select2-container .select2-selection--single {
    height: calc(2.05rem + 2px);
    border: 1px solid var(--line-strong);
    border-radius: 7px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: calc(2.05rem);
    padding-left: 0.5rem;
    padding-right: 1.9rem;
    color: var(--text);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: calc(2.05rem + 2px);
    right: 5px;
}

.select2-container .select2-selection--multiple {
    min-height: calc(2.05rem + 2px);
    border: 1px solid var(--line-strong);
    border-radius: 7px;
}

.select2-dropdown {
    border: 1px solid var(--line-strong);
    border-radius: 7px;
}

.control-label {
    margin-bottom: 0.2rem;
    font-size: 12px;
    color: var(--text-muted);
}

.btn {
    border-radius: 7px;
    padding: 0.32rem 0.78rem;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.18rem;
    margin-bottom: 0.18rem;
}

.btn-primary {
    background-color: var(--brand);
    border-color: var(--brand);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
}

.btn-success {
    background-color: var(--ok);
    border-color: var(--ok);
}

.alert {
    border-radius: 8px;
    margin-bottom: 0.8rem;
    padding: 0.48rem 0.68rem;
}

.footer {
    background-color: #edf3f9;
    border-top: 1px solid var(--line);
    font-size: 0.8rem;
    height: 48px;
}

.footer > .container {
    padding-right: 12px;
    padding-left: 12px;
}

.not-set {
    color: #c55;
    font-style: italic;
}

/* add sorting icons to gridview sort links */
a.asc:after,
a.desc:after {
    content: '';
    left: 3px;
    display: inline-block;
    width: 0;
    height: 0;
    border: solid 5px transparent;
    margin: 4px 4px 2px 4px;
    background: transparent;
}

a.asc:after {
    border-bottom: solid 7px #3b526d;
    border-top-width: 0;
}

a.desc:after {
    border-top: solid 7px #3b526d;
    border-bottom-width: 0;
}

.grid-view th {
    white-space: nowrap;
}

.hint-block {
    display: block;
    margin-top: 5px;
    color: #999;
}

.error-summary {
    color: #7d2930;
    background: #fff4f5;
    border: 1px solid #f3c8ce;
    border-left: 3px solid #d6848d;
    border-radius: 8px;
    padding: 8px 14px;
    margin: 0 0 12px 0;
}

/* align the logout "link" (button in form) of the navbar */
.nav li > form > button.logout {
    padding-top: 7px;
    color: rgba(255, 255, 255, 0.7);
    border: 0;
    background: none;
    font-size: 0.88rem;
}

table.estimate-total-data {
    float: right;
    margin: 12px 0;
}

#estimate-total-data {
    background-color: #eef6ff;
    border: 1px solid #cde1f6;
    border-radius: 8px;
    display: inline-flex;
    padding: 0.1rem 0.35rem;
    margin-top: 10px;
}

table.estimate-total-data thead,
table.estimate-total-data tfoot {
    border-color: #d2deea;
}

table.estimate-total-data thead tr,
table.estimate-total-data tbody tr,
table.estimate-total-data tfoot tr {
    height: 26px;
}

table.estimate-total-data thead th {
    width: 98px;
    text-align: center;
    font-size: 12px;
}

table.estimate-total-data thead th:first-child {
    width: 126px;
}

table.estimate-total-data tbody td,
table.estimate-total-data tfoot td {
    text-align: right;
    font-size: 12px;
}

table.estimate-total-data tbody td:first-child,
table.estimate-total-data tfoot td:first-child {
    text-align: left;
}

table.estimate-total-data tfoot td {
    font-weight: 700;
}

.register-box,
.login-box {
    width: 400px;
    margin: 42px auto;
}

.login-box .card {
    border-top: 3px solid #2f79c4;
}

.total_summ {
    font-size: 12px;
    text-align: right;
    color: #325373;
}

.delete-section {
    vertical-align: baseline;
    color: #7f91a7;
    transition: color 0.15s ease;
}

.delete-section:hover {
    color: var(--danger);
}

.search-form .form-group {
    margin-bottom: 0;
}

.search-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    min-height: calc(2.05rem + 2px);
}

.estimate-form-layout {
    padding: 0.85rem;
}

.estimate-side-controls {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.estimate-status-field {
    max-width: 240px;
}

.estimate-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.resource-form-grid .field-resource-price .form-control,
.resource-form-grid .field-resource-margin .form-control,
.resource-form-grid .field-estimateresource-price .form-control,
.resource-form-grid .field-estimateresource-margin .form-control {
    max-width: 160px;
}

.resource-form-grid .field-resource-unit_id .form-control,
.resource-form-grid .field-estimateresource-unit_id .form-control,
.resource-form-grid .field-resource-resource_type_id .form-control,
.resource-form-grid .field-estimateresource-resource_type_id .form-control {
    max-width: 220px;
}

.resource-form-grid .field-resource-unit_id .select2-container,
.resource-form-grid .field-estimateresource-unit_id .select2-container,
.resource-form-grid .field-resource-resource_type_id .select2-container,
.resource-form-grid .field-estimateresource-resource_type_id .select2-container {
    max-width: 220px;
}

.resource-form .js-type-group {
    display: none;
}

.estimate-customer-page {
    --ec-font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --ec-text: #243446;
    --ec-text-muted: #5f7187;
    --ec-text-strong: #1d2f43;
    --ec-title: 34px;
    --ec-f1-size: 18px;
    --ec-f1-color: #3b5573;
    --ec-f2-size: 12px;
    --ec-f2-color: #6a7e94;
    --ec-f3-size: 16px;
    --ec-f3-color: #2f4358;
    --ec-f4-size: 14px;
    --ec-f4-color: #35495f;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 8px;
    background: #fff;
    font-family: var(--ec-font-family);
    color: var(--ec-text);
    font-size: var(--ec-f3-size);
    line-height: 1.35;
}

.estimate-customer-actions {
    display: flex;
    justify-content: flex-end;
}

.estimate-customer-pdf-btn {
    font-size: 14px;
    font-weight: 600;
    padding: 6px 14px;
}

.estimate-customer-brand-row {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 16px;
}

@media print {
    .estimate-customer-actions,
    .navbar,
    .breadcrumb,
    .footer {
        display: none !important;
    }

    main > .container {
        padding-top: 0 !important;
    }

    .estimate-customer-page {
        margin: 0;
        padding: 0;
    }
}

.estimate-customer-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 14px;
}

.estimate-customer-info-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
}

.estimate-customer-brand-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.estimate-customer-logo {
    width: auto;
    height: 56px;
    max-width: 200px;
    object-fit: contain;
    border-radius: 0;
    background: transparent;
    border: none;
    padding: 0;
}

.estimate-customer-phone {
    font-size: var(--ec-f2-size);
    color: var(--ec-text-muted);
    font-weight: 600;
}

.estimate-customer-title {
    margin: 0 0 14px;
    font-size: var(--ec-title);
    font-weight: 700;
    line-height: 1.15;
    color: var(--ec-text-strong);
}

.estimate-customer-info-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.estimate-customer-info-row {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    border-top: 1px solid #edf2f7;
    padding-top: 10px;
}

.estimate-customer-meta-label {
    color: var(--ec-f2-color);
    font-size: var(--ec-f2-size);
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.estimate-customer-meta-value {
    color: var(--ec-f3-color);
    font-size: var(--ec-f3-size);
    font-weight: 600;
    line-height: 1.2;
}

.estimate-customer-thumb-wrap {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    display: flex;
    align-items: stretch;
    justify-content: center;
    min-height: 220px;
    overflow: hidden;
}

.estimate-customer-total-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.estimate-customer-total-title {
    font-size: var(--ec-f1-size);
    font-weight: 700;
    color: var(--ec-f1-color);
    margin-bottom: 10px;
    line-height: 1.1;
}

.estimate-customer-total-card .estimate-total-data {
    margin-bottom: 0;
}

.estimate-customer-total-card .estimate-total-data td {
    padding: 7px 0;
    font-size: var(--ec-f4-size);
    color: var(--ec-f4-color);
    font-weight: 500;
}

.estimate-customer-total-card .estimate-total-data td:last-child {
    text-align: right;
    white-space: nowrap;
}

.estimate-customer-total-card .estimate-total-data tfoot td {
    border-top: 1px solid var(--line);
    padding-top: 10px;
    font-size: var(--ec-f1-size);
    font-weight: 700;
    color: var(--ec-f1-color);
    line-height: 1.1;
}

.estimate-customer-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.estimate-customer-sections {
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin-top: 24px;
}

.estimate-customer-section {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 7px rgba(26, 57, 91, 0.06);
}

.estimate-customer-section .grid-view {
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    border-radius: 0;
}

.estimate-customer-section .section-header {
    background: #f8fbff;
    border-bottom: 1px solid var(--line);
    margin: 0;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.estimate-customer-section .estimate-section-name {
    font-size: var(--ec-f1-size);
    font-weight: 700;
    color: var(--ec-f1-color);
    line-height: 1.1;
}

.estimate-customer-section .total_summ {
    font-size: var(--ec-f2-size);
    text-align: right;
    color: var(--ec-f2-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.estimate-customer-section .total_summ b {
    font-size: var(--ec-f1-size);
    color: var(--ec-f1-color);
    font-weight: 700;
    line-height: 1.1;
    text-transform: none;
    letter-spacing: normal;
    display: inline-block;
    margin-left: 14px;
}

.estimate-customer-table thead th {
    background: #f6faff;
    color: var(--ec-f2-color);
    font-size: var(--ec-f2-size);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.estimate-customer-table td,
.estimate-customer-table th {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    vertical-align: middle;
}

.estimate-customer-section .estimate-customer-table {
    border: none;
    border-collapse: separate;
    border-spacing: 0;
}

.estimate-customer-section .estimate-customer-table thead th {
    border-top: none;
}

.estimate-customer-section .estimate-customer-table.table-bordered th,
.estimate-customer-section .estimate-customer-table.table-bordered td {
    border: none;
}

.estimate-customer-section .estimate-customer-table thead th {
    border-bottom: 1px solid var(--line);
}

.estimate-customer-section .estimate-customer-table thead th + th,
.estimate-customer-section .estimate-customer-table tbody td + td {
    border-left: 1px solid var(--line);
}

.estimate-customer-section .estimate-customer-table tbody tr + tr td {
    border-top: 1px solid var(--line);
}

.estimate-customer-table td {
    color: var(--ec-f4-color);
    font-size: var(--ec-f4-size);
    line-height: 1.35;
}

.estimate-customer-table td.text-right {
    color: var(--ec-f4-color);
    font-weight: 500;
}

.estimate-customer-table tr:nth-child(even) td {
    background: #fcfdff;
}

@media (max-width: 767px) {
    main > .container {
        padding: 60px 8px 10px;
    }

    .grid-view,
    .estimate-search,
    .resource-search {
        padding: 0.6rem;
    }

    .table th,
    .table td {
        padding: 0.32rem 0.36rem;
        font-size: 12px;
    }

    .search-actions {
        margin-top: 0.2rem;
    }

    .register-box,
    .login-box {
        width: 100%;
        margin: 18px auto;
    }

    .nav li > form > button.logout {
        display: block;
        text-align: left;
        width: 100%;
        padding: 10px 0;
    }

    .estimate-customer-top {
        grid-template-columns: 1fr;
    }

    .estimate-customer-info-row {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .estimate-customer-total-card {
        padding: 12px;
    }

    .estimate-customer-title {
        font-size: 24px;
    }

    .estimate-customer-thumb-wrap {
        min-height: 120px;
    }
}

.nav > li > form > button.logout:focus,
.nav > li > form > button.logout:hover {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.92);
}

.nav > li > form > button.logout:focus {
    outline: none;
}
