@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    --color-bg: #F5F8FA;
    --color-surface: #FFFFFF;
    --color-border: #E8EBF2;
    --color-text: #202B46;
    --color-muted: #5E7A91;
    --color-primary: #185CC1;
    --color-primary-hover: #144EA4;
    --color-success: #42A65D;
    --color-warning: #FDA900;
    --color-danger: #D1453B;
    --shadow-soft: 0 16px 32px rgba(24, 92, 193, 0.08);
}

html {
    font-size: 15px;
}


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

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.55;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    color: var(--color-primary-hover);
}

button,
.button,
[type='button'],
[type='submit'],
[type='reset'] {
    font-family: inherit;
    color: #ffffff;
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.92rem;
    padding: 0.55rem 1rem;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

button:hover,
.button:hover,
[type='button']:hover,
[type='submit']:hover,
[type='reset']:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
}

button:disabled,
.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

a.secondary,
button.secondary,
.secondary,
.button-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: #ffffff;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 0.9rem;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

a.secondary:hover,
button.secondary:hover,
.secondary:hover,
.button-secondary:hover {
    background: #EDF3FF;
    border-color: #CBD6F1;
    color: var(--color-primary-hover);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: #ffffff;
    color: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(24, 92, 193, 0.12);
}

label {
    font-size: 0.85rem;
    color: var(--color-muted);
    font-weight: 500;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

p {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--color-muted);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.quick-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    background: var(--color-bg);
}

.app-sidebar {
    background: #202B46;
    color: #E3EBF1;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.app-sidebar__menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.app-sidebar__menu a {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    color: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-sidebar__menu a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.app-sidebar__menu a.is-active {
    background: var(--color-primary);
    color: #ffffff;
}

.app-content {
    background: var(--color-bg);
    padding: 2rem;
}

.app-content__inner {
    max-width: 1200px;
    margin: 0 auto;
}

.form-section,
.widget-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-soft);
}

.basic-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.25rem;
}

.basic-info-grid .grid-span-2 {
    grid-column: span 2;
}

.filter-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: var(--shadow-soft);
}

.table-actions {
    display: flex;
    gap: 0.65rem;
    align-items: center;
}

.table-actions form {
    margin: 0;
}

.filters-chart {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.chip {
    display: flex;
    align-items: center;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: #E3EBF1;
    color: var(--color-text);
    font-size: 0.8rem;
    border: 1px solid var(--color-border);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

table thead {
    background: #EDF3FF;
    color: var(--color-text);
}

table th,
table td {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    font-size: 0.92rem;
}

table tbody tr:hover {
    background: #F7F9FB;
}

table tbody tr:last-child td {
    border-bottom: none;
}

.badge {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge--status {
    color: #ffffff;
}

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

.badge--draft {
    background: #94A7B7;
}

.items-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.items-card {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface);
    padding: 0.75rem;
    box-shadow: var(--shadow-soft);
}

.items-card__table {
    overflow-x: auto;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table thead th {
    background: #EDF3FF;
    color: var(--color-muted);
}

.items-table__number {
    width: 3rem;
    text-align: center;
}

.items-table__number-cell {
    text-align: center;
    font-weight: 600;
}

.items-table__label {
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    color: var(--color-muted);
    white-space: nowrap;
}

.items-table__label--stack span {
    display: block;
    line-height: 1.1;
}

.items-table__value {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.items-remove {
    text-align: center;
}

.items-remove button {
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
    background: #ffffff;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
}

.items-remove button:hover {
    background: #FFE5E8;
}

.items-hint {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.items-summary {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.items-summary div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 120px;
}

.items-summary span {
    font-size: 0.75rem;
    color: var(--color-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.items-summary strong {
    font-size: 1.05rem;
    color: var(--color-text);
}

.definition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem 1.5rem;
}

.definition-grid dt {
    font-size: 0.82rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.definition-grid dd {
    margin: 0;
    font-weight: 500;
    color: var(--color-text);
}

.invoice-preview-frame {
    width: 100%;
    min-height: 600px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: #ffffff;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--color-muted);
}

.text-danger {
    color: var(--color-danger);
    font-size: 0.8rem;
}

@media (max-width: 960px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        display: none;
    }

    .app-content {
        padding: 1.5rem;
    }
}

@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-toolbar {
        grid-template-columns: 1fr;
    }
}

.items-price-mode {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.items-price-mode__option {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.items-price-mode__option input {
    accent-color: var(--color-primary);
}

.items-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.items-actions__button {
    flex: 1 1 200px;
    justify-content: center;
}

.secondary.is-active,
.button-secondary.is-active {
    background: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
}

.repository-filters {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    margin-bottom: 1.5rem;
}

.repository-filters__group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.8rem;
}

.repository-filters__group > span {
    font-weight: 600;
    color: var(--color-text);
}

.repository-filters__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.repository-filters__button {
    min-width: 110px;
    justify-content: center;
    text-align: center;
}

@media (max-width: 640px) {
    .repository-filters__button {
        min-width: 0;
        flex: 1 1 120px;
    }
}

.summary-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-totals__item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.75rem 1.1rem;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 160px;
}

.summary-totals__item span {
    font-size: 0.78rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.summary-totals__item strong {
    font-size: 1.15rem;
    color: var(--color-text);
}

.danger-zone {
    border: 1px solid rgba(209, 69, 59, 0.3);
    background: #fff5f5;
    box-shadow: none;
}

.danger-zone h2 {
    color: var(--color-danger);
}

.danger-zone button {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #ffffff;
}

.danger-zone button:hover {
    background: #b53a2f;
    border-color: #b53a2f;
}

.form-section form {
    width: 100%;
}

.basic-info-grid label,
.payment-grid label {
    width: 100%;
}

.product-picker {
    border: none;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    width: min(540px, 90vw);
    background: var(--color-surface);
}

.product-picker::backdrop {
    background: rgba(32, 43, 70, 0.45);
}

.product-picker.is-open {
    display: block;
    position: fixed;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    z-index: 1200;
}

.product-picker header {
    margin-bottom: 1rem;
}

.product-picker input[type='search'] {
    margin-bottom: 1rem;
}

.product-picker__list {
    margin: 0;
    padding: 0.5rem 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
}

.product-picker__item {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    cursor: pointer;
    color: inherit;
    transition: background 0.2s ease;
}

.product-picker__item:hover,
.product-picker__item:focus-visible {
    background: #edf3ff;
    outline: none;
}

.product-picker__name {
    font-weight: 600;
}

.product-picker__meta {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.product-picker__empty {
    margin: 1rem;
    color: var(--color-muted);
    text-align: center;
}

.is-selected-from-catalog td {
    background: #edf3ff;
    transition: background 0.6s ease;
}


.field-error {
    border-color: var(--color-danger) !important;
    box-shadow: 0 0 0 2px rgba(209, 69, 59, 0.18);
}

.field-error--flash {
    animation: fieldFlash 0.9s ease-in-out;
}

@keyframes fieldFlash {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.status-panel {
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: 10px;
    background: #ffffff;
    padding: 1.25rem;
    margin: 1rem 0;
    box-shadow: var(--shadow-soft);
}

.status-panel--success {
    border-left-color: var(--color-success);
}

.status-panel h2 {
    margin-top: 0;
}

.status-panel__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.status-panel__list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.status-panel__list li {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.status-panel__list a {
    font-weight: 600;
    color: var(--color-primary);
}

.status-panel__list small {
    color: var(--color-muted);
    font-size: 0.8rem;
}

.status-panel__empty {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.status-panel__hint {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--color-muted);
}

.payment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.app-sidebar__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}

.app-sidebar__logo-image {
    display: block;
    max-width: 160px;
    width: 100%;
    height: auto;
}

.app-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #ffffff;
    padding: 6px;
    object-fit: contain;
    box-shadow: var(--shadow-soft);
}

.auth-body {
    background: var(--color-bg);
}

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 2.25rem 2rem;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
}

.auth-card__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.auth-card__logo {
    display: block;
    max-width: 200px;
    width: 100%;
    height: auto;
}

.auth-card--inverted {
    background: #121b34;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f3f6fc;
    box-shadow: 0 24px 48px rgba(10, 25, 58, 0.45);
}

.auth-card--inverted h1,
.auth-card--inverted p {
    color: inherit;
}

.auth-card--inverted label,
.auth-card--inverted .auth-form__remember span {
    color: rgba(227, 235, 241, 0.85);
}

.auth-card--inverted input:not([type="checkbox"]) {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.auth-card--inverted input:not([type="checkbox"]):focus {
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

.auth-card--inverted .auth-links a {
    color: #9ec5ff;
}

.auth-card--inverted .auth-card__header p {
    color: rgba(227, 235, 241, 0.75);
}

.auth-card--inverted .auth-errors {
    background: rgba(209, 69, 59, 0.12);
    border-color: rgba(209, 69, 59, 0.45);
    color: #ffb8ae;
}

.auth-card--inverted .auth-links a:hover {
    color: #cde0ff;
}

.auth-card__header h1 {
    font-size: 1.4rem;
}

.auth-card__header p {
    color: var(--color-muted);
    margin: 0;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form button {
    width: 100%;
}

.auth-form__remember {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    text-align: left;
}

.auth-form__remember input {
    width: auto;
}

.auth-errors {
    background: #fff5f5;
    border: 1px solid rgba(209, 69, 59, 0.25);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--color-danger);
    text-align: left;
}

.auth-errors ul {
    margin: 0;
    padding-left: 1.1rem;
}

.auth-links {
    margin: 0;
    font-size: 0.85rem;
}

.auth-links a {
    color: var(--color-primary);
}

@media (max-width: 640px) {
    .auth-card {
        padding: 2rem 1.5rem;
    }
}

.basic-info-grid .grid-span-2 {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .basic-info-grid .grid-span-2 {
        grid-column: span 1;
    }
}

.payment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.basic-info-grid label,
.payment-grid label {
    width: 100%;
}
