/*
 * Dark navy theme for the Django admin.
 * Overrides the admin's CSS variables for every theme value (auto/light/dark),
 * so the app always renders dark regardless of the OS setting.
 */

html:root,
html[data-theme] {
    --primary: #3b82f6;
    --secondary: #1d4ed8;
    --accent: #60a5fa;
    --primary-fg: #f8fafc;

    --body-fg: #e2e8f5;
    --body-bg: #0b1426;
    --body-quiet-color: #8fa1c4;
    --body-medium-color: #c3cee4;
    --body-loud-color: #ffffff;

    --header-color: #e2e8f5;
    --header-branding-color: #ffffff;
    --header-bg: #0a1222;
    --header-link-color: #c3cee4;

    --breadcrumbs-fg: #8fa1c4;
    --breadcrumbs-link-fg: #c3cee4;
    --breadcrumbs-bg: #0e1930;

    --link-fg: #7cb5ff;
    --link-hover-color: #b3d3ff;
    --link-selected-fg: #93c5fd;

    --hairline-color: #1c2b4b;
    --border-color: #2a3c63;

    --error-fg: #f87171;
    --message-success-bg: #0f3d2e;
    --message-warning-bg: #4a3a0e;
    --message-error-bg: #4c1620;

    --darkened-bg: #111d36;
    --selected-bg: #1a2a4d;
    --selected-row: #17284a;

    --button-fg: #ffffff;
    --button-bg: #2563eb;
    --button-hover-bg: #1d4ed8;
    --default-button-bg: #3b82f6;
    --default-button-hover-bg: #2563eb;
    --close-button-bg: #2a3c63;
    --close-button-hover-bg: #3a5080;
    --delete-button-bg: #dc2626;
    --delete-button-hover-bg: #b91c1c;

    --object-tools-fg: #ffffff;
    --object-tools-bg: #2563eb;
    --object-tools-hover-bg: #1d4ed8;

    --card-bg: #111d36;
    --radius: 10px;

    --font-family-primary: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;

    color-scheme: dark;
}

body {
    background: radial-gradient(1200px 600px at 100% -10%, #13254a 0%, transparent 60%), var(--body-bg);
    background-attachment: fixed;
    font-size: 0.9rem;
}

.theme-toggle { display: none; }

/* Header */
#header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--hairline-color);
    padding: 14px 32px;
}

#site-name a:link,
#site-name a:visited {
    color: var(--header-branding-color);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
}

#user-tools a { border-bottom: none; }
#user-tools a:hover { color: #fff; text-decoration: none; }

div.breadcrumbs {
    background: transparent;
    border-bottom: 1px solid var(--hairline-color);
    padding: 12px 32px;
}

/* Cards */
.module,
#changelist .changelist-form-container,
fieldset.module,
.inline-group {
    background: var(--card-bg);
    border: 1px solid var(--hairline-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.module h2,
.module caption,
.inline-group h2 {
    background: transparent;
    color: var(--body-quiet-color);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    padding: 12px 16px;
    border-bottom: 1px solid var(--hairline-color);
}

.module caption a.section,
.module h2 a.section { color: var(--body-medium-color); }

#content { padding: 24px 32px; }

#content h1 {
    font-weight: 600;
    color: var(--body-loud-color);
}

/* Sidebar */
#nav-sidebar {
    background: var(--header-bg);
    border-right: 1px solid var(--hairline-color);
}

#nav-sidebar .module { border: none; border-radius: 0; background: transparent; }
#nav-sidebar .current-app .section:link,
#nav-sidebar .current-app .section:visited { color: var(--accent); }
#nav-sidebar .current-model { background: var(--selected-row); }

.toggle-nav-sidebar {
    background: var(--header-bg);
    border-color: var(--hairline-color);
    color: var(--body-quiet-color);
}

/* Tables */
thead th,
tfoot td {
    background: var(--darkened-bg);
    color: var(--body-quiet-color);
    border-bottom: 1px solid var(--hairline-color);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
}

td, th { border-bottom-color: var(--hairline-color); }
#result_list tbody tr:hover { background: var(--selected-bg); }

/* Forms */
input[type=text], input[type=password], input[type=email], input[type=url],
input[type=number], input[type=tel], input[type=search], textarea, select,
.vTextField {
    background: #0b1426;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 7px 10px;
    color: var(--body-fg);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
    outline: none;
}

/*
 * One field height (34px) for text inputs, selects and autocomplete selects.
 * Django's admin pins <select> to 30px; with our 7px padding that left no room
 * for the text and clipped the bottom of the selected value.
 */
input[type=text], input[type=password], input[type=email], input[type=url],
input[type=number], input[type=tel], input[type=search], .vTextField {
    line-height: 1.4;
    min-height: 34px;
    box-sizing: border-box;
}

select {
    height: auto;
    min-height: 34px;
    line-height: 1.4;
    padding: 6px 8px;
    box-sizing: border-box;
}

select[multiple] { min-height: 150px; }

/* "html body" because the admin's autocomplete.css loads after this file. */
html body .select2-container--admin-autocomplete .select2-selection--single {
    height: 34px;
    background: #0b1426;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

html body .select2-container--admin-autocomplete .select2-selection--single .select2-selection__rendered {
    line-height: 32px;
    color: var(--body-fg);
    padding-left: 10px;
}

html body .select2-container--admin-autocomplete .select2-selection--single .select2-selection__arrow { height: 32px; }

html body .select2-container--admin-autocomplete.select2-container--focus .select2-selection,
html body .select2-container--admin-autocomplete.select2-container--open .select2-selection {
    border-color: var(--primary);
}

/* Date inputs: "Ma | calendar" sit inside the field on its right (static/js/date_fields.js wraps them). */
.date-field { position: relative; display: inline-block; width: 13em; max-width: 100%; vertical-align: middle; }
.date-field input.vDateField { width: 100%; min-width: 0; padding-right: 76px; box-sizing: border-box; }
.date-field .datetimeshortcuts {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--body-quiet-color);
}
.date-field .datetimeshortcuts a { color: var(--link-fg); }

/* Buttons */
.button, input[type=submit], input[type=button], .submit-row input, a.button {
    border-radius: 8px;
    padding: 9px 16px;
    font-weight: 600;
    transition: background 0.15s;
}

.submit-row {
    background: var(--card-bg);
    border: 1px solid var(--hairline-color);
    border-radius: var(--radius);
}

.object-tools a:link, .object-tools a:visited { border-radius: 999px; padding: 6px 14px; }

/* Changelist filter + search */
#changelist-filter {
    background: var(--card-bg);
    border: 1px solid var(--hairline-color);
    border-radius: var(--radius);
}

#changelist #toolbar {
    background: transparent;
    border-bottom: 1px solid var(--hairline-color);
}

/* "Új … hozzáadása" next to the search button (templates/admin/search_form.html), styled like the object-tools pills. */
#changelist-search a.toolbar-addlink:link,
#changelist-search a.toolbar-addlink:visited {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--object-tools-bg);
    color: var(--object-tools-fg);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
    text-decoration: none;
}
#changelist-search a.toolbar-addlink::before { content: '+'; font-size: 1rem; line-height: 1; }
#changelist-search a.toolbar-addlink:hover { background: var(--object-tools-hover-bg); }

#changelist .actions { background: var(--darkened-bg); border-bottom-color: var(--hairline-color); }

/* Customer shipping addresses: fixed column widths so the inline fits a Full HD screen. */
#shipping_addresses-group table {
    width: 100%;
    table-layout: fixed;
}

#shipping_addresses-group th,
#shipping_addresses-group td {
    padding: 8px 6px;
    vertical-align: middle;
    white-space: normal;
}

#shipping_addresses-group td input[type=text] {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

#shipping_addresses-group .original { width: 0; padding: 0; }
#shipping_addresses-group .column-label { width: 16%; }
#shipping_addresses-group .column-postcode { width: 7%; }
#shipping_addresses-group .column-city { width: 12%; }
#shipping_addresses-group .column-address { width: 21%; }
#shipping_addresses-group .column-country { width: 5%; }
#shipping_addresses-group .column-contact_name { width: 13%; }
#shipping_addresses-group .column-contact_phone { width: 10%; }
#shipping_addresses-group .column-is_default { width: 10%; text-align: center; }
#shipping_addresses-group thead th:last-child { width: 6%; text-align: center; }
#shipping_addresses-group td.field-is_default,
#shipping_addresses-group td.delete { text-align: center; }

/* Saved rows already show their values in the inputs, so drop the summary line above each tabular inline row. */
.inline-group .tabular td.original p { display: none; }
.inline-group .tabular tr.has_original td { padding-top: 8px; }

/* Stock document: the "save and post" row under the normal save buttons. */
.submit-row.post-row {
    margin-top: 10px;
    align-items: center;
    border-color: rgba(59, 130, 246, 0.45);
}

.submit-row.post-row p.help { margin: 0 0 0 12px; color: var(--body-quiet-color); }
.submit-row.issue-row label { color: var(--body-medium-color); font-weight: 600; margin-right: 4px; }
.submit-row.issue-row select { margin-right: 8px; }

/* Reversal (sztornó): red link on posted documents and the confirmation page. */
.object-tools a.reverse-link:link,
.object-tools a.reverse-link:visited { background: var(--delete-button-bg); }
.object-tools a.reverse-link:hover { background: var(--delete-button-hover-bg); }

.reverse-summary { margin-bottom: 16px; }
.reverse-summary h2 { text-transform: none; font-size: 0.9rem; color: var(--body-loud-color); letter-spacing: 0; }
.reverse-reason { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.reverse-reason textarea { max-width: 640px; }
.submit-row input.reverse-confirm { background: var(--delete-button-bg); }
.submit-row input.reverse-confirm:hover { background: var(--delete-button-hover-bg); }
.submit-row a.cancel-link { background: var(--close-button-bg); color: #fff; padding: 9px 16px; }

/* Scrap lines: product, quantity, serial / batch, reason */
#lines-group th.column-notes { width: 30%; }
#lines-group td.field-notes input { width: 100%; box-sizing: border-box; }
#lines-group td.field-tracking_code select { min-width: 220px; }

/*
 * Wide master-data forms (product, partner): body.wide-form is set by their change_form.html.
 * Fieldsets sit three in a row, inline tables two in a row (product) or full width, so the form
 * fills a Full HD screen instead of one long narrow column.
 */
body.wide-form #content-main form > div {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}
body.wide-form #content-main form > div > * { grid-column: 1 / -1; margin: 0; }
body.wide-form #content-main form > div > fieldset.module { grid-column: span 2; align-self: stretch; }
body.wide-form.model-product #content-main form > div > .inline-group { grid-column: span 3; }
/* Alone (no batch table), the partner codes table takes the full width. */
body.wide-form.model-product #content-main form > div:not(:has(#batches-group)) > #partner_codes-group { grid-column: 1 / -1; }
body.wide-form fieldset.module .form-row { padding: 8px 12px; }
body.wide-form .aligned label { width: 140px; min-width: 140px; }
body.wide-form .aligned .vTextField,
body.wide-form .aligned input[type=text],
body.wide-form .aligned input[type=email],
body.wide-form .aligned input[type=number] { width: 100%; max-width: 260px; }
body.wide-form .aligned .help, body.wide-form .aligned p.help { margin-left: 0; padding-left: 0; }
body.wide-form .aligned .flex-container > .help,
body.wide-form fieldset .help { font-size: 0.72rem; }
body.wide-form fieldset textarea.compact-notes { max-width: none; }

/* Project page: two sections per row (Projekt | Ütemezés és keret, Leírás | Áttekintés); the task list,
   a lone section (.full, e.g. Leírás on a new project) and the tables below take the full width. */
body.wide-form.model-project #content-main form > div > fieldset.module { grid-column: span 3; }
body.wide-form.model-project #content-main form > div > fieldset.module.full,
body.wide-form.model-project #content-main form > div > fieldset.project-tasks { grid-column: 1 / -1; }
body.wide-form.model-project .aligned .vTextField,
body.wide-form.model-project .aligned input[type=text] { max-width: 420px; }
body.wide-form.model-project fieldset textarea { width: 100%; box-sizing: border-box; }
@media (max-width: 1024px) {
    body.wide-form.model-project #content-main form > div > fieldset.module { grid-column: 1 / -1; }
}

/*
 * Employee page ("Dolgozók"): full-width sections one below the other
 * (Felhasználói adatok, Személyes adatok, Munkaügyi adatok, Címek), each a grid of fields with the label above
 * the input so many fit on a row. The small tables (children, languages…) sit two per row, documents full width.
 */
body.wide-form.model-employee #content-main form > div > fieldset.module,
body.wide-form.model-employee #content-main form > div > #profile-group,
body.wide-form.model-employee #content-main form > div > #documents-group { grid-column: 1 / -1; }
body.wide-form.model-employee #content-main form > div > .inline-group { grid-column: span 3; }
body.wide-form.model-employee #profile-group { background: transparent; border: none; }
body.wide-form.model-employee #profile-group > fieldset > h2,
body.wide-form.model-employee #profile-group .inline-related > h3 { display: none; }  /* the sections have their own titles */
body.wide-form.model-employee #profile-group .inline-related { border: none; }
body.wide-form.model-employee #profile-group .inline-related > fieldset.module { margin: 0 0 16px; }

body.wide-form.model-employee fieldset.user-data,
body.wide-form.model-employee fieldset.personal-data,
body.wide-form.model-employee fieldset.employment-data,
body.wide-form.model-employee fieldset.addresses {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 0;
    padding-bottom: 8px;
}
body.wide-form.model-employee fieldset.addresses { grid-template-columns: repeat(7, minmax(0, 1fr)); }
body.wide-form.model-employee fieldset.module > h2,
body.wide-form.model-employee fieldset.module > h4.fieldset-heading { grid-column: 1 / -1; }
/* Inline (profile) sections title themselves with h4; style them like the other section headers. */
body.wide-form.model-employee fieldset.module > h4.fieldset-heading {
    margin: 0 0 4px;
    padding: 12px 16px;
    background: transparent;
    border-bottom: 1px solid var(--hairline-color);
    color: var(--body-quiet-color);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}
body.wide-form.model-employee fieldset.module > .description { grid-column: 1 / -1; }

/* Each field: label above its input, filling its cell. */
body.wide-form.model-employee fieldset.module .form-row { border-bottom: none; padding: 8px 4px; }
body.wide-form.model-employee fieldset.module .form-row > div > .flex-container { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
body.wide-form.model-employee fieldset.module .form-row label { width: auto; min-width: 0; padding: 0; float: none; font-size: 0.75rem; color: var(--body-quiet-color); }
body.wide-form.model-employee fieldset.module .form-row input[type=text],
body.wide-form.model-employee fieldset.module .form-row input[type=email],
body.wide-form.model-employee fieldset.module .form-row input[type=number],
body.wide-form.model-employee fieldset.module .form-row input[type=tel],
body.wide-form.model-employee fieldset.module .form-row select { width: 100%; max-width: none; box-sizing: border-box; }
body.wide-form.model-employee fieldset.module .form-row .date-field { width: 100%; }
body.wide-form.model-employee fieldset.module .form-row .help { margin: 2px 0 0; padding: 0; font-size: 0.68rem; }
body.wide-form.model-employee fieldset.module .form-row .related-widget-wrapper { display: flex; align-items: center; gap: 4px; }
body.wide-form.model-employee fieldset.module .form-row .related-widget-wrapper select { flex: 1; }
/* Checkboxes: label and box on one line. */
body.wide-form.model-employee fieldset.module .form-row .checkbox-row,
body.wide-form.model-employee fieldset.module .form-row.field-is_active .flex-container { flex-direction: row; align-items: center; }
body.wide-form.model-employee fieldset.module .form-row.field-is_active .help { display: none; }
body.wide-form.model-employee fieldset.module .form-row.field-username .help { display: none; }

/* Wider cell: the groups picker takes two columns. */
/* Felhasználói adatok on one row: five text fields, a wider groups picker, then the \"Aktív\" checkbox. */
body.wide-form.model-employee fieldset.user-data { grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.6fr) auto; }
body.wide-form.model-employee fieldset.user-data .form-row.field-groups .help { display: none; }
body.wide-form.model-employee fieldset.user-data .form-row.field-is_active { align-self: end; padding-bottom: 14px; }
body.wide-form.model-employee fieldset.user-data .form-row.field-groups .related-widget-wrapper .select2-container { flex: 1; width: auto !important; }

/* Címek: lakcím on the first row, ideiglenes lakcím on the second, each with a sub-heading. */
body.wide-form.model-employee fieldset.addresses .form-row.field-temp_postcode { grid-column-start: 1; }
body.wide-form.model-employee fieldset.addresses .form-row.field-postcode::before,
body.wide-form.model-employee fieldset.addresses .form-row.field-temp_postcode::before {
    display: block;
    margin-bottom: 6px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}
body.wide-form.model-employee fieldset.addresses .form-row.field-postcode::before { content: 'Lakcím'; }
body.wide-form.model-employee fieldset.addresses .form-row.field-temp_postcode::before { content: 'Ideiglenes lakcím'; }
body.wide-form.model-employee fieldset.addresses .form-row:not(.field-postcode):not(.field-temp_postcode) { padding-top: 26px; }

body.wide-form.model-employee .inline-group .tabular table { width: 100%; }
body.wide-form.model-employee .inline-group .tabular td input[type=text] { width: 100%; box-sizing: border-box; }

@media (max-width: 1400px) {
    body.wide-form.model-employee fieldset.user-data,
    body.wide-form.model-employee fieldset.personal-data,
    body.wide-form.model-employee fieldset.employment-data { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    body.wide-form.model-employee fieldset.addresses { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    body.wide-form.model-employee #content-main form > div > .inline-group { grid-column: 1 / -1; }
}
/* Half-width inline tables on the product page: fixed columns so every column fits. */
body.wide-form.model-product .inline-group table { width: 100%; table-layout: fixed; }
body.wide-form.model-product .inline-group td,
body.wide-form.model-product .inline-group th { padding: 8px 6px; white-space: normal; }
body.wide-form.model-product .inline-group td input[type=text],
body.wide-form.model-product .inline-group td .select2-container { width: 100% !important; max-width: 100%; box-sizing: border-box; }
body.wide-form.model-product .inline-group td.original { width: 0; padding: 0; }
body.wide-form.model-product .inline-group th:last-child { width: 48px; text-align: center; }
body.wide-form.model-product .inline-group td.delete { text-align: center; }
body.wide-form.model-product .inline-group td .date-field { width: 100%; }
body.wide-form.model-product #batches-group .column-number { width: 22%; }
body.wide-form.model-product #batches-group .column-production_date,
body.wide-form.model-product #batches-group .column-expiry_date { width: 24%; }
body.wide-form.model-product #batches-group .column-created_at { width: 14%; }
body.wide-form.model-product #partner_codes-group .column-customer { width: 40%; }
body.wide-form.model-product #partner_codes-group td.field-customer .related-widget-wrapper { display: flex; align-items: center; gap: 4px; }

@media (max-width: 1400px) {
    body.wide-form #content-main form > div > fieldset.module { grid-column: span 3; }
    body.wide-form.model-product #content-main form > div > .inline-group { grid-column: 1 / -1; }
}

@media (max-width: 1024px) {
    body.wide-form #content-main form > div > fieldset.module { grid-column: 1 / -1; }
}

/* Two-unit quantity inputs on document lines (static/js/line_quantities.js) */
.qty-unit { display: block; margin-top: 3px; font-size: 0.72rem; color: var(--body-quiet-color); white-space: nowrap; }
input[data-line-qty] { width: 110px; }
input[data-line-qty]:disabled { opacity: 0.45; }

/* Stocktaking: counted vs expected difference */
.diff-plus { color: #6ee7b7; font-weight: 600; }
.diff-minus { color: #fca5a5; font-weight: 600; }
.diff-zero { color: var(--body-quiet-color); }
#lines-group td.field-expected_quantity p,
#lines-group td.field-difference_display p { margin: 0; }

/* Stock list page */
.stock-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.stock-filter label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--body-quiet-color);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stock-filter input[type=search] { width: 340px; }

.stock-table { width: 100%; }
.stock-table th.num, .stock-table td.num { text-align: right; white-space: nowrap; }

/* Stock list: one summary row per product, breakdown rows open underneath. */
.stock-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--hairline-color);
    color: var(--body-quiet-color);
}
.stock-toolbar span { margin-right: auto; }
.stock-toolbar .button { padding: 6px 12px; font-size: 0.78rem; background: var(--close-button-bg); }
.stock-toolbar .button:hover { background: var(--close-button-hover-bg); }

.stock-table .toggle-col { width: 36px; padding-right: 0; }
.stock-table tbody.stock-group { border-bottom: 1px solid var(--hairline-color); }
.stock-table tbody.stock-group.expandable .stock-summary { cursor: default; }
.stock-table tbody:not(.open) tr.stock-detail { display: none; }

.stock-toggle {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--darkened-bg);
    color: var(--accent);
    cursor: pointer;
    padding: 0;
}
.stock-toggle:hover { border-color: var(--primary); }
.stock-toggle .chevron { transition: transform 0.15s; font-size: 0.8rem; line-height: 1; }
.stock-group.open .stock-toggle .chevron { transform: rotate(90deg); }
.stock-group.open tr.stock-summary td { background: var(--selected-row); }

.stock-table tr.stock-detail td {
    background: var(--darkened-bg);
    color: var(--body-medium-color);
    font-size: 0.85em;
    padding-top: 6px;
    padding-bottom: 6px;
}
.stock-table td.detail-indent { color: var(--body-quiet-color); padding-left: 24px; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75em;
    font-weight: 600;
    white-space: nowrap;
}
.tag-serial { background: rgba(99, 102, 241, 0.18); color: #a5b4fc; }
.tag-batch { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; }
.tag-out { background: rgba(248, 113, 113, 0.16); color: #fca5a5; }
/* Task status / priority tags (tasks/admin.py). */
.tag-open { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; }
.tag-progress { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.tag-review { background: rgba(56, 189, 248, 0.16); color: #7dd3fc; }
.overdue { color: #fca5a5; font-weight: 600; }

/* Task page: comments read like a timeline (time, author, text), the newest at the bottom. */
#comments-group td.field-created_at, #comments-group td.field-author { white-space: nowrap; color: var(--body-quiet-color); width: 1%; }
#comments-group td.field-text p { white-space: pre-wrap; margin: 0; }
#comments-group td.field-text textarea { width: 100%; box-sizing: border-box; }
.delegate-page select, .delegate-page textarea { min-width: 320px; }

/* Project progress bar (projects/admin.py) and the task list on the project page. */
.progress { display: inline-block; width: 90px; height: 8px; border-radius: 999px; background: var(--hairline-color); vertical-align: middle; overflow: hidden; }
.progress-bar { display: block; height: 100%; background: #34d399; }
.project-tasks .stock-table { margin: 8px 12px; width: calc(100% - 24px); }
.project-tasks p { margin: 8px 12px; }

/* "Ütemezés" Gantt chart (templates/admin/projects/schedule.html). Label column + a timeline positioned in percent. */
.gantt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.gantt-legend { display: inline-flex; gap: 16px; margin-left: auto; color: var(--body-quiet-color); font-size: 0.8rem; }
.gantt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.gantt-legend .ms { position: static; transform: rotate(45deg); }
.today-key { display: inline-block; width: 2px; height: 14px; background: #f472b6; }
.gantt-empty { color: var(--body-quiet-color); }
.gantt { border: 1px solid var(--hairline-color); border-radius: var(--radius); background: var(--card-bg); overflow: hidden; }
.gantt-head, .gantt-row { display: grid; grid-template-columns: 380px 1fr; }
.gantt-head { position: sticky; top: 0; z-index: 3; background: var(--darkened-bg); border-bottom: 1px solid var(--hairline-color); }
.gantt-head .gantt-label { padding: 8px 12px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--body-quiet-color); }
.gantt-label { padding: 6px 12px; border-right: 1px solid var(--hairline-color); min-width: 0; }
.gantt-label a, .gantt-label .ms-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-sub { display: block; font-size: 0.72rem; color: var(--body-quiet-color); margin-top: 2px; }
.gantt-timeline { position: relative; min-height: 38px; }
.gantt-head .gantt-timeline { min-height: 32px; }
.gantt-month { position: absolute; top: 0; bottom: 0; padding: 8px 6px; font-size: 0.72rem; color: var(--body-quiet-color);
               border-left: 1px solid var(--hairline-color); white-space: nowrap; overflow: hidden; box-sizing: border-box; }
.gantt-grid { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--hairline-color); opacity: 0.5; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #f472b6; z-index: 1; }
.gantt-row { border-top: 1px solid var(--hairline-color); }
.gantt-project { background: rgba(255, 255, 255, 0.02); }
.gantt-project .gantt-timeline { min-height: 46px; }
.gantt-milestone .gantt-label { padding-left: 28px; font-size: 0.85rem; }
.gantt-bar { position: absolute; top: 14px; height: 18px; border-radius: 6px; background: #3b82f6; opacity: 0.85; z-index: 1; }
.gantt-bar.status-planning { background: #64748b; }
.gantt-bar.status-on_hold { background: #0ea5e9; }
.gantt-bar.status-closed { background: #10b981; }
.gantt-bar.status-cancelled { background: #7f1d1d; }
.gantt-bar.overdue-bar { box-shadow: inset -4px 0 0 #f87171; }
.gantt-bar.open-ended { background-image: repeating-linear-gradient(90deg, transparent 0 8px, rgba(0, 0, 0, 0.25) 8px 12px); }
/* Milestone diamonds: green = done, blue = planned, red = late. */
.ms { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; transform: rotate(45deg); border-radius: 2px;
      z-index: 2; display: inline-block; border: 2px solid var(--card-bg); }
.ms-on-bar { width: 10px; height: 10px; margin: -5px 0 0 -5px; }
.ms-done { background: #34d399; }
.ms-planned { background: #60a5fa; }
.ms-late { background: #f87171; }
.ms-date { position: absolute; top: 50%; margin: -8px 0 0 12px; font-size: 0.7rem; color: var(--body-quiet-color); white-space: nowrap; z-index: 2; }
.ms-undated { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 0.72rem; color: var(--body-quiet-color); font-style: italic; }
.ms-state { font-weight: 600; }

/* Pénzügy: account cards above the movements list, account statement, invoice sections side by side. */
.account-balances { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 12px; }
.balance-card { display: flex; flex-direction: column; gap: 2px; min-width: 200px; padding: 10px 14px; border-radius: var(--radius);
                background: var(--card-bg); border: 1px solid var(--hairline-color); }
.balance-card:hover { border-color: var(--object-tools-bg); }
.balance-kind { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--body-quiet-color); }
.balance-name { font-size: 0.85rem; }
.balance-card strong { font-size: 1.15rem; }
.movement-totals { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 0.85rem; color: var(--body-quiet-color); }
body.wide-form.app-finance #content-main form > div > fieldset.module { grid-column: span 2; }
body.wide-form.app-finance #content-main form > div > fieldset.account-statement { grid-column: 1 / -1; }
.account-statement .stock-table { margin: 8px 12px; width: calc(100% - 24px); }
.account-statement p { margin: 8px 12px; }
.statement-opening td { color: var(--body-quiet-color); font-style: italic; }
@media (max-width: 1400px) { body.wide-form.app-finance #content-main form > div > fieldset.module { grid-column: span 3; } }
@media (max-width: 1024px) { body.wide-form.app-finance #content-main form > div > fieldset.module { grid-column: 1 / -1; } }

/* Tax number lookup (static/js/taxpayer_lookup.js): button and status after the tax number field. */
.taxpayer-button { margin-left: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--object-tools-bg);
                   background: transparent; color: var(--link-fg); cursor: pointer; font-size: 0.75rem; }
.taxpayer-button:hover { background: var(--object-tools-bg); color: #fff; }
.taxpayer-status { display: block; margin-top: 4px; font-size: 0.72rem; color: var(--body-quiet-color); }
.taxpayer-status[data-kind="ok"] { color: #6ee7b7; }
.taxpayer-status[data-kind="warning"] { color: #fcd34d; }
.taxpayer-status[data-kind="error"] { color: #fca5a5; }

/* Törzsadatok → Saját cégek: logo thumbnail in the list, preview on the page. */
.company-logo-thumb { max-height: 28px; max-width: 90px; vertical-align: middle; background: #fff; border-radius: 4px; padding: 2px; }
.company-logo-preview { max-height: 120px; max-width: 320px; background: #fff; border-radius: 6px; padding: 8px; }
body.wide-form.app-masterdata #content-main form > div > fieldset.module .description { margin: 6px 12px; font-size: 0.75rem; }

/* Bejövő számlák: transfer file page and the "mark as paid" row. */
.transfer-page .form-row { padding: 8px 12px; }
.transfer-page .form-row > label:first-child, .transfer-page .form-row .label { display: inline-block; min-width: 230px; font-weight: 600; }
.transfer-page .stock-table { margin: 8px 12px; width: calc(100% - 24px); }
.transfer-page .skipped ul { margin: 8px 12px 12px; }
.transfer-page > #content-main > form > p.help { margin-top: 12px; }
.pay-row label { margin-right: 6px; }
.pay-row select, .pay-row input[type=date] { margin-right: 12px; }

/* "Ügyfél történetisége" page (templates/admin/customers/history.html): timeline on the left, new event form on the right. */
.history-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
.history-head p { margin: 8px 12px 12px; color: var(--body-quiet-color); }
.history-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.history-filter a { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--hairline-color); font-size: 0.8rem; }
.history-filter a.selected { background: var(--object-tools-bg); border-color: var(--object-tools-bg); color: #fff; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--hairline-color); margin-left: 70px; }
.timeline-item { position: relative; display: block; padding: 8px 0 8px 18px; }
.timeline-item::before { content: ''; position: absolute; left: -7px; top: 16px; width: 12px; height: 12px; border-radius: 50%;
                         background: var(--card-bg); border: 2px solid #60a5fa; }
.timeline-item.kind-event::before { border-color: #7dd3fc; background: #7dd3fc; }
.timeline-date { position: absolute; left: -84px; top: 10px; width: 70px; text-align: right; font-size: 0.75rem; color: var(--body-quiet-color); line-height: 1.3; }
.timeline-body { background: var(--card-bg); border: 1px solid var(--hairline-color); border-radius: var(--radius); padding: 8px 12px; }
.timeline-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.timeline-status { font-size: 0.75rem; color: var(--body-quiet-color); }
.timeline-amount { margin-left: auto; font-weight: 600; }
.timeline-text { margin: 6px 0 0; }
.timeline-details { margin: 4px 0 0; font-size: 0.75rem; color: var(--body-quiet-color); }
.history-empty { color: var(--body-quiet-color); }
.history-side .module { margin-bottom: 16px; }
.event-form .form-row { padding: 6px 12px; display: flex; flex-direction: column; gap: 4px; }
.event-form .form-row label { font-size: 0.75rem; color: var(--body-quiet-color); }
.event-form input[type=text], .event-form input[type=date], .event-form input[type=datetime-local],
.event-form select, .event-form textarea { width: 100%; box-sizing: border-box; }
.event-form .submit-row { margin: 8px 12px 12px; }
.follow-ups ul { margin: 8px 12px 12px; padding-left: 16px; }
@media (max-width: 1200px) { .history-layout { grid-template-columns: 1fr; } }

/* Sidebar: main menu groups open / close by clicking their title (static/js/nav_collapse.js). */
#nav-sidebar caption.nav-toggle { cursor: pointer; user-select: none; position: relative; padding-right: 28px; }
#nav-sidebar caption.nav-toggle a { pointer-events: none; }  /* the click toggles the group, it does not open the app page */
#nav-sidebar caption.nav-toggle::after {
    content: ''; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
    opacity: 0.7; transition: transform 0.15s;
}
#nav-sidebar .module.collapsed caption.nav-toggle::after { transform: rotate(-45deg); margin-top: -3px; }
#nav-sidebar .module.collapsed table tr { display: none; }
#nav-sidebar.nav-filtering .module.collapsed table tr { display: table-row; }
#nav-sidebar .module.collapsed { margin-bottom: 4px; }

/* Manufacturing pages (Gyártás): sections two per row; the material needs table full width. */
body.wide-form.app-manufacturing #content-main form > div > fieldset.module { grid-column: span 3; }
body.wide-form.app-manufacturing #content-main form > div > fieldset.material-needs { grid-column: 1 / -1; }
.material-needs .stock-table { margin: 8px 12px; width: calc(100% - 24px); }
.material-needs p { margin: 8px 12px; }
.finish-row label { margin-right: 6px; }
.finish-row input[type=text], .finish-row input[type=date] { margin-right: 12px; }
@media (max-width: 1024px) {
    body.wide-form.app-manufacturing #content-main form > div > fieldset.module { grid-column: 1 / -1; }
}

/* Milestones: "Számla kiállítása" button in the table; the invoice preview placeholder page. */
#milestones-group a.invoice-button { padding: 4px 10px; font-size: 0.72rem; white-space: nowrap; }
#milestones-group td.field-amount input { width: 120px; }
.invoice-preview-page .invoice-draft .stock-table { margin: 8px 12px; width: calc(100% - 24px); }
.invoice-preview-page .invoice-draft th { width: 160px; text-align: left; }
.invoice-preview-page .invoice-draft p, .invoice-preview-page .invoice-missing ul { margin: 8px 12px; }
.ms-state-done { color: #6ee7b7; }
.ms-state-planned { color: #93c5fd; }
.ms-state-late { color: #fca5a5; }
.ms-state-undated { color: var(--body-quiet-color); }

/* Notes on documents: a compact box instead of the admin's large textarea (rows set in the admin). */
textarea.compact-notes { width: 100%; max-width: 640px; min-height: 0; box-sizing: border-box; }
.stock-table .quiet { color: var(--body-quiet-color); }

/* Messages */
ul.messagelist li { border-radius: 8px; margin-bottom: 8px; color: var(--body-fg); }

/* Login page */
.login #container {
    background: var(--card-bg);
    border: 1px solid var(--hairline-color);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.login #header { padding: 20px 24px; }
.login #content { padding: 24px; }
.login .submit-row { background: transparent; border: none; padding: 1em 0 0; }
.login .submit-row input { width: 100%; }

@media (max-width: 767px) {
    #header, div.breadcrumbs { padding-left: 16px; padding-right: 16px; }
    #content { padding: 16px; }
}
