:root {
    --dayes-blue: #17417e;
    --dayes-blue-dark: #0d2d5d;
    --dayes-blue-soft: #eaf1fb;
    --dayes-green: #78b843;
    --dayes-sky: #8cc6e8;
    --ink: #17314f;
    --muted: #65758a;
    --line: #dbe5f0;
    --bg: #f6f9fd;
    --panel: #ffffff;
    --danger: #b42318;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--bg);
}
header {
    background: white;
    color: var(--dayes-blue);
    padding: 20px 28px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(23, 65, 126, .08);
}
.brand { display: flex; align-items: center; gap: 18px; }
.brand-logo {
    position: relative;
    width: 132px;
    height: 48px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}
.brand-logo span {
    color: var(--dayes-blue);
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
}
.brand-mark {
    position: absolute;
    inset: 0;
    width: 132px;
    height: 48px;
    background: white;
    object-fit: contain;
}
.brand-copy { border-left: 1px solid var(--line); padding-left: 18px; }
header h1 { margin: 0; font-size: 24px; letter-spacing: 0; color: var(--dayes-blue); }
header p { margin: 6px 0 0; color: var(--muted); }
.header-date {
    color: var(--dayes-blue);
    background: var(--dayes-blue-soft);
    border-radius: 999px;
    padding: 9px 14px;
    white-space: nowrap;
}
.topnav {
    display: flex;
    gap: 8px;
    padding: 12px 24px 0;
    max-width: 1500px;
    margin: 0 auto;
}
.topnav a {
    color: var(--dayes-blue);
    text-decoration: none;
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 999px;
}
.topnav a.active, .topnav a:hover {
    background: var(--dayes-blue);
    color: white;
}
.nav-user {
    margin-left: auto;
    color: var(--muted);
    padding: 10px 8px;
    font-size: 13px;
}
main { padding: 24px; max-width: 1500px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 18px; align-items: start; }
.two { grid-template-columns: repeat(2, minmax(300px, 1fr)); }
.wide { grid-column: 1 / -1; }
.tabbar {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    padding: 4px 0;
}
.tabbar button {
    background: white;
    color: var(--dayes-blue);
    border: 1px solid #c8d7e8;
    min-height: 36px;
    padding: 8px 12px;
}
.tabbar button.active,
.tabbar button:hover {
    background: var(--dayes-blue);
    color: white;
    transform: none;
}
[data-tab-panel] {
    display: none;
}
[data-tab-panel].tab-panel-active {
    display: block;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(240px, 1fr));
    gap: 14px;
}
.metric-card {
    background: #f8fbff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}
.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.metric-card strong {
    display: block;
    margin-top: 8px;
    color: var(--dayes-blue);
    font-size: 26px;
}
section, .report {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(23, 65, 126, .07);
}
h2 { margin: 0 0 14px; font-size: 18px; color: var(--dayes-blue); }
h3 { margin: 18px 0 8px; font-size: 15px; color: var(--dayes-blue-dark); }
.subheading {
    margin-left: 12px;
    padding-left: 10px;
    border-left: 3px solid var(--dayes-sky);
}
form { display: grid; gap: 10px; }
.compact-form {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.compact-form input,
.compact-form select {
    min-width: 120px;
    padding: 6px 8px;
}
.compact-form button {
    padding: 7px 10px;
    white-space: nowrap;
    min-height: 32px;
}
.stack-form {
    align-items: stretch;
    flex-wrap: wrap;
}
.stack-form input {
    min-width: 105px;
}
.edit-form {
    display: none;
    margin-top: 8px;
}
.edit-form.open {
    display: flex;
}
.edit-row {
    display: none !important;
}
.edit-row.open {
    display: table-row !important;
}
.edit-row td {
    background: #f8fbff;
}
.table-actions {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.table-actions form {
    display: inline-flex;
    gap: 0;
    margin: 0;
}
.table-actions button {
    white-space: nowrap;
    min-height: 32px;
    padding: 6px 10px;
    line-height: 1.1;
}
.cell-summary {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
}
.cell-summary span {
    min-width: 0;
}
.link-button {
    background: transparent;
    color: var(--dayes-blue);
    border: 1px solid #c8d7e8;
    padding: 6px 9px;
    min-height: 32px;
    line-height: 1.1;
}
.link-button:hover {
    background: var(--dayes-blue-soft);
    color: var(--dayes-blue);
    transform: none;
}
.accounts-table th,
.accounts-table td {
    vertical-align: middle;
}
.accounts-table td:last-child {
    width: 130px;
}
.manage-actions-table td:last-child {
    width: 190px;
}
.manage-actions-table .table-actions {
    align-items: center;
}
.manage-actions-table .table-actions form {
    align-items: center;
}
#entities_table th:last-child,
#entities_table td:last-child,
#users_table th:last-child,
#users_table td:last-child {
    width: 170px;
}
label { display: grid; gap: 5px; font-size: 13px; color: #29496e; font-weight: 700; }
.checkbox-line {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
}
.checkbox-line input {
    width: auto;
}
.hidden-field {
    display: none;
}
input, select, textarea, button {
    font: inherit;
    border-radius: 6px;
    border: 1px solid #c8d7e8;
    padding: 9px 10px;
    background: white;
    min-width: 0;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(140, 198, 232, .35);
    border-color: var(--dayes-blue);
}
textarea { resize: vertical; min-height: 72px; }
button, .button {
    border: 0;
    background: var(--dayes-blue);
    color: white;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .15s ease, transform .15s ease;
}
button:hover, .button:hover { background: var(--dayes-blue-dark); transform: translateY(-1px); }
.button.secondary, button.secondary { background: var(--dayes-green); color: #10233d; }
.button.secondary:hover, button.secondary:hover { background: #68a338; }
.delete button {
    background: transparent;
    color: var(--danger);
    border: 1px solid #f1b7b2;
    padding: 6px 10px;
    font-weight: 700;
    min-height: 32px;
    line-height: 1.1;
}
.delete button:hover { background: #fff5f4; transform: none; }
td > form.delete {
    display: inline-flex;
    margin: 0;
}
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.inline > * { flex: 1 1 170px; }
.search-row { display: flex; gap: 10px; align-items: end; margin-bottom: 10px; flex-wrap: wrap; }
.search-row label { flex: 1 1 240px; }
.result-count { color: var(--muted); font-size: 13px; padding-bottom: 10px; white-space: nowrap; }
.autocomplete {
    position: relative;
}
.autocomplete-results {
    display: none;
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    max-height: 260px;
    overflow: auto;
    background: white;
    border: 1px solid #c8d7e8;
    border-radius: 6px;
    box-shadow: 0 14px 34px rgba(23, 65, 126, .16);
}
.autocomplete-results.open {
    display: block;
}
.autocomplete-results button {
    width: 100%;
    display: block;
    text-align: left;
    color: var(--ink);
    background: white;
    border: 0;
    border-radius: 0;
    padding: 10px 12px;
    font-weight: 700;
}
.autocomplete-results button:hover,
.autocomplete-results button:focus {
    background: var(--dayes-blue-soft);
    color: var(--dayes-blue);
    transform: none;
}
.autocomplete-results .muted-option {
    color: var(--muted);
    font-weight: 400;
    padding: 10px 12px;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}
.table-scroll {
    max-height: 430px;
    overflow: auto;
}
.table-scroll table {
    min-width: 980px;
}
#invoice_checks_table {
    min-width: 1720px;
    table-layout: auto;
}
#invoice_checks_table th,
#invoice_checks_table td {
    white-space: nowrap;
}
#invoice_checks_table th:nth-child(5),
#invoice_checks_table td:nth-child(5) {
    min-width: 160px;
}
#invoice_checks_table th:nth-child(8),
#invoice_checks_table th:nth-child(9),
#invoice_checks_table th:nth-child(10),
#invoice_checks_table td:nth-child(8),
#invoice_checks_table td:nth-child(9),
#invoice_checks_table td:nth-child(10) {
    min-width: 130px;
}
#licenses_table {
    min-width: 1120px;
    table-layout: auto;
}
#licenses_table th,
#licenses_table td {
    white-space: normal;
}
#licenses_table th:first-child,
#licenses_table td:first-child {
    min-width: 280px;
}
.licenses-table td:nth-child(2),
.licenses-table td:nth-child(6) {
    width: 120px;
}
.licenses-table td:nth-child(5) {
    width: 180px;
}
.metric-inline {
    display: inline-grid;
    gap: 2px;
}
.metric-inline strong {
    color: var(--dayes-blue);
    font-size: 20px;
}
.metric-inline span,
.license-limits span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.license-limits {
    display: grid;
    grid-template-columns: repeat(2, minmax(90px, 1fr));
    gap: 8px;
}
.license-limits span {
    display: grid;
    gap: 2px;
}
.license-limits strong {
    color: var(--ink);
    font-size: 17px;
}
.usage-bar {
    width: min(220px, 100%);
    height: 9px;
    margin-top: 8px;
    overflow: hidden;
    background: #e8eef6;
    border-radius: 999px;
}
.usage-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
}
.usage-bar-ok span {
    background: #78b843;
}
.usage-bar-warning span {
    background: #d98c16;
}
.usage-bar-danger span {
    background: var(--danger);
}
.status-pill {
    margin-bottom: 4px;
}
.status-pill-ok {
    background: #e8f5e2;
    color: #246b19;
}
.status-pill-warning {
    background: #fff1d6;
    color: #7c4700;
}
.status-pill-danger {
    background: #fff0ee;
    color: var(--danger);
}
.license-edit-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 12px;
    padding: 12px;
    background: #f8fbff;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.license-edit-panel h3 {
    grid-column: 1 / -1;
    margin: 0;
}
.license-edit-panel textarea {
    min-height: 92px;
}
.license-critical {
    align-self: end;
    padding: 9px 0;
}
.license-notes,
.license-edit-panel .form-actions {
    grid-column: 1 / -1;
}
.license-edit-panel .form-actions {
    display: flex;
    justify-content: flex-start;
}
section.report table {
    table-layout: auto;
}
.table-scroll thead {
    position: sticky;
    top: 0;
    z-index: 2;
}
section.report table thead {
    position: static;
}
th, td { border-bottom: 1px solid #e4eaf1; padding: 9px 8px; text-align: left; vertical-align: top; }
td {
    overflow-wrap: anywhere;
}
th { color: var(--dayes-blue); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #f8fbff; }
.muted { color: var(--muted); }
.conditional-note {
    display: none;
    margin: 0;
}
.conditional-note.open {
    display: block;
}
.pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--dayes-blue-soft);
    color: var(--dayes-blue);
    font-size: 12px;
    font-weight: 700;
}
.total {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 16px;
    margin: 14px 0;
    background: linear-gradient(135deg, var(--dayes-blue), var(--dayes-blue-dark));
    color: white;
    border: 1px solid var(--dayes-blue-dark);
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
}
.report { border-top: 5px solid var(--dayes-blue); }
.report-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 14px;
}
.report-head h2 { font-size: 24px; }
.report-brand { text-align: right; color: var(--dayes-blue); }
.empty {
    padding: 20px;
    color: var(--muted);
    background: #f8fbff;
    border: 1px dashed #c8d7e8;
    border-radius: 8px;
}
.notice {
    padding: 12px;
    border-radius: 6px;
    background: var(--dayes-blue-soft);
    border: 1px solid #c8d7e8;
    margin: 10px 0;
}
.notice.error {
    background: #fff5f4;
    border-color: #f1b7b2;
    color: var(--danger);
}
.notice.success {
    background: #f1faec;
    border-color: #bfe3a9;
    color: #285c16;
}
.notice-hide {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .25s ease, transform .25s ease;
}
.status-ok { color: #246b19; font-weight: 700; }
.status-warning { color: #9a5b00; font-weight: 700; }
.status-danger { color: var(--danger); font-weight: 700; }
.variance-positive { color: #246b19; font-weight: 700; }
.variance-negative { color: var(--danger); font-weight: 700; }
.variance-neutral { color: var(--muted); font-weight: 700; }
.row-ok td { background: #fbfef8; border-bottom-color: #d8ebcf; }
.row-positive td { background: #f1faec; border-bottom-color: #cfe8c5; }
.row-warning td { background: #fffaf0; border-bottom-color: #f4d7a1; }
.row-danger td { background: #fff7f6; border-bottom-color: #f2c4bf; }
.row-ok td:first-child,
.row-positive td:first-child { border-left: 4px solid #246b19; }
.row-warning td:first-child { border-left: 4px solid #9a5b00; }
.row-danger td:first-child { border-left: 4px solid var(--danger); }
.site-footer {
    width: 100%;
    margin: 0;
    padding: 10px 24px 24px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}
.login-main {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-page {
    background:
        linear-gradient(rgba(246, 249, 253, .78), rgba(246, 249, 253, .9)),
        url("background.png") center / cover no-repeat fixed;
}
.login-card {
    width: min(420px, calc(100vw - 32px));
    backdrop-filter: blur(2px);
}
@media (max-width: 980px) {
    .grid, .two { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    header { display: block; }
    .brand { align-items: flex-start; }
    .brand-copy { border-left: 0; padding-left: 0; }
    .header-date { display: inline-block; margin-top: 14px; }
}
@media print {
    body { background: white; }
    header, .topnav, .no-print, section:not(.report) { display: none !important; }
    main { padding: 0; max-width: none; }
    .report { border: 0; border-top: 5px solid var(--dayes-blue); box-shadow: none; padding: 0; }
    .report table {
        display: table;
        max-height: none;
        overflow: visible;
    }
    .report table thead { display: table-header-group; position: static; }
    .report table tbody { display: table-row-group; }
    .report table tr { display: table-row; width: auto; table-layout: auto; }
    .total { background: white; color: var(--dayes-blue); border: 2px solid var(--dayes-blue); }
    table { page-break-inside: auto; }
    tr { page-break-inside: avoid; page-break-after: auto; }
}
