/* Dashboard: minimal light theme ------------------------------------------- */

:root {
    --bg: #f7f7f8;
    --surface: #ffffff;
    --border: #e5e5e7;
    --text: #1f2328;
    --text-muted: #6e7781;
    --accent: #1f6feb;
    --danger: #cf222e;
    --radius: 8px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

h1,
h2 {
    margin: 0;
    font-weight: 600;
}

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

/* Header ------------------------------------------------------------------- */

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
}

.brand {
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
}

.brand:hover {
    text-decoration: none;
}

.app-nav {
    display: flex;
    gap: 20px;
}

.app-nav__link {
    color: var(--text-muted);
    font-size: 14px;
}

.app-nav__link:hover,
.app-nav__link.is-active {
    color: var(--text);
    text-decoration: none;
}

/* Page --------------------------------------------------------------------- */

.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
}

.page-subtitle {
    margin: 2px 0 0;
    color: var(--text-muted);
}

.chip {
    color: var(--text-muted);
    font-size: 13px;
}

/* Stats -------------------------------------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.stat__label {
    display: block;
    color: var(--text-muted);
    font-size: 13px;
}

.stat__value {
    display: block;
    margin-top: 4px;
    font-size: 22px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stat__value--text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Card --------------------------------------------------------------------- */

.card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.card__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.card__title {
    font-size: 15px;
}

.card__meta {
    color: var(--text-muted);
    font-size: 13px;
}

.card__body {
    margin: 0;
    padding: 16px;
}

/* Table -------------------------------------------------------------------- */

.table-wrap {
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    max-width: 240px;
    padding: 10px 16px;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover td {
    background: var(--bg);
}

.data-table .col-index {
    width: 1%;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Empty / error state ------------------------------------------------------ */

.empty-state {
    padding: 40px 24px;
    text-align: center;
}

.empty-state h2 {
    margin-bottom: 4px;
    font-size: 16px;
}

.empty-state p {
    margin: 0;
    color: var(--text-muted);
}

/* Flash messages ----------------------------------------------------------- */

.message {
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}

.message.error {
    border-color: var(--danger);
    color: var(--danger);
}

.message.success {
    border-color: #1a7f37;
    color: #1a7f37;
}

/* Buttons, badges, forms --------------------------------------------------- */

.actions {
    display: flex;
    gap: 8px;
}

.button {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.button:hover {
    border-color: var(--text-muted);
    text-decoration: none;
}

.button--primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.button--primary:hover {
    border-color: var(--accent);
    opacity: .9;
}

.button:disabled {
    cursor: wait;
    opacity: .6;
}

.inline-form {
    display: inline;
}

.button--danger,
.link-danger {
    color: var(--danger);
}

.badge {
    white-space: nowrap;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 12px;
}

.breadcrumb {
    margin: 0 0 2px;
    color: var(--text-muted);
    font-size: 13px;
}

.notice {
    margin: 0 0 16px;
    padding: 10px 16px;
    border: 1px solid #d4a72c;
    border-radius: var(--radius);
    background: #fff8c5;
    font-size: 14px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.filters input,
.filters select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

.filters input {
    flex: 1 1 260px;
}

.data-table .col-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table .col-actions {
    width: 1%;
    text-align: right;
}

.data-table .col-actions a {
    margin-left: 12px;
}

/* Log entries -------------------------------------------------------------- */

.log-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.log-entry {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.log-entry:last-child {
    border-bottom: 0;
}

.log-entry__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.log-entry__body {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.log-entry__body summary {
    cursor: pointer;
}

.log-entry__body pre {
    margin: 8px 0 0;
    padding: 10px;
    overflow: auto;
    border-radius: 6px;
    background: var(--bg);
    font-size: 12px;
    white-space: pre;
}

.level {
    align-self: flex-start;
    padding: 0 6px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.level--emergency,
.level--alert,
.level--critical,
.level--error {
    background: #ffebe9;
    color: var(--danger);
}

.level--warning {
    background: #fff8c5;
    color: #9a6700;
}

.level--notice,
.level--info {
    background: #ddf4ff;
    color: #0969da;
}

.pager {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    font-size: 14px;
}

/* Synchronizations --------------------------------------------------------- */

.status {
    display: inline-block;
    padding: 0 6px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    vertical-align: middle;
}

.status--success,
.status--done {
    background: #dafbe1;
    color: #1a7f37;
}

.status--partial,
.status--skipped,
.status--not_applied {
    background: #fff8c5;
    color: #9a6700;
}

.status--failed {
    background: #ffebe9;
    color: var(--danger);
}

.status--dry_run,
.status--running {
    background: #ddf4ff;
    color: #0969da;
}

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

.stat--danger .stat__value {
    color: var(--danger);
}

.notice--danger {
    border-color: var(--danger);
    background: #ffebe9;
    color: var(--danger);
}

.stats--flush {
    margin: 0;
    padding: 16px;
}

.filters--links {
    margin: 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

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

.filters--links a.is-active {
    color: var(--text);
    font-weight: 600;
}

/* Sync page: calendar sidebar + day content */

.sync-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.sync-layout__calendar {
    position: sticky;
    top: 16px;
}

.day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.day-header__title {
    font-size: 18px;
}

/* Calendar */

.calendar {
    padding: 14px;
}

.calendar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.calendar__month {
    font-weight: 600;
}

.calendar__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    color: var(--text);
    font-size: 20px;
    line-height: 1;
}

.calendar__nav:hover {
    background: var(--bg);
    text-decoration: none;
}

.calendar__grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar__weekday {
    padding: 4px 0;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
}

.calendar__day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    aspect-ratio: 1;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.calendar__day.has-runs {
    color: var(--text);
    font-weight: 600;
}

a.calendar__day:hover {
    background: var(--bg);
    text-decoration: none;
}

.calendar__day.is-today {
    border-color: var(--border);
}

.calendar__day.is-selected {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

a.calendar__day.is-selected:hover {
    background: var(--accent);
}

.calendar__dots {
    display: flex;
    gap: 2px;
    height: 6px;
}

.calendar__footer {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 13px;
}

.calendar__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin: 10px 0 0;
    padding: 10px 0 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    list-style: none;
}

.calendar__legend li {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.dot--error {
    background: var(--danger);
}

.dot--warning {
    background: #d4a72c;
}

.dot--ok {
    background: #2da44e;
}

/* Keep the dots readable on the selected (blue) day. */
.is-selected .dot {
    box-shadow: 0 0 0 1px #fff;
}

.counter-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.counters {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 16px;
    margin: 0;
    padding: 12px 16px;
    font-size: 14px;
}

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

.counters dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: right;
}

.counters--meta {
    grid-template-columns: max-content 1fr;
}

.counters--meta dd {
    font-weight: 400;
    text-align: left;
    overflow-wrap: anywhere;
}

.app-main > .card + .card {
    margin-top: 24px;
}

.data-table--wrap td {
    max-width: none;
    white-space: normal;
}

del {
    color: var(--danger);
}

ins {
    color: #1a7f37;
    text-decoration: none;
}

/* Small screens ------------------------------------------------------------ */

@media (max-width: 900px) {
    .sync-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .sync-layout__calendar {
        position: static;
        max-width: 360px;
    }
}

@media (max-width: 640px) {
    .app-header__inner {
        flex-wrap: wrap;
        row-gap: 6px;
        padding: 12px 16px;
    }

    .app-nav {
        flex-wrap: wrap;
        gap: 4px 16px;
    }

    .sync-layout__calendar {
        max-width: none;
    }

    .app-main {
        padding: 20px 16px 48px;
    }

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

    .log-entry {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
    }

    .log-entry__meta {
        flex-direction: row;
        gap: 8px;
    }
}

/* Sync status ---------------------------------------------------------------- */

.status--starting {
    background: #ddf4ff;
    color: #0969da;
}

.steps {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.steps__item {
    flex: 1 1 140px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    counter-increment: step;
}

.steps__item::before {
    content: counter(step) ". ";
}

.steps__item.is-done {
    border-color: #2da44e;
    color: #1a7f37;
}

.steps__item.is-done::before {
    content: "✓ ";
}

.steps__item.is-current {
    border-color: var(--accent);
    background: #ddf4ff;
    color: var(--accent);
    font-weight: 600;
}

.progress {
    overflow: hidden;
    height: 10px;
    border-radius: 999px;
    background: var(--bg);
}

.progress__bar {
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width .4s ease;
}

.progress__text {
    margin: 6px 0 0;
    font-size: 13px;
}

.progress__message {
    margin: 16px 0 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    overflow-wrap: anywhere;
}

/* Guide search ---------------------------------------------------------------- */

.search {
    max-width: 640px;
    margin: 48px auto 0;
}

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 0;
}

.search-form input {
    flex: 1 1 260px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.search-form input:focus {
    border-color: var(--accent);
    outline: 2px solid #ddf4ff;
}

.search-form .button {
    padding: 10px 20px;
}

.guide {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
}

.guide__photo {
    width: 120px;
    height: 150px;
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--bg);
}

.guide__body {
    flex: 1 1 240px;
}

.guide__name {
    margin-bottom: 12px;
    font-size: 20px;
}

.guide .counters {
    padding: 0;
}

.guide-result + .guide-result {
    margin-top: 24px;
}

.guide-result .card__header {
    border-top: 1px solid var(--border);
}

.status--active {
    background: #dafbe1;
    color: #1a7f37;
}

.status--expired,
.status--revoked,
.status--voided {
    background: #ffebe9;
    color: var(--danger);
}

/* License ---------------------------------------------------------------------- */

.notice--success {
    border-color: #2da44e;
    background: #dafbe1;
}

.license .card + .card {
    margin-top: 16px;
}

.license ol {
    margin: 12px 0;
    padding-left: 20px;
}

.license li + li {
    margin-top: 6px;
}

.button--cta {
    display: block;
    margin-top: 12px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.license .page-subtitle {
    margin-bottom: 24px;
}

.verify__fields {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 16px;
    margin: 0 0 16px;
}

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

.verify__fields dd {
    margin: 0;
    font-weight: 600;
}

.verify__status {
    display: inline-block;
    margin: 0;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 600;
}

.verify__status--valid {
    background: #dafbe1;
    color: #1a7f37;
}

.verify__status--invalid {
    background: #ffebe9;
    color: var(--danger);
}

/* Language menu (header, right) -------------------------------------------- */

.lang-menu {
    position: relative;
}

.lang-menu summary {
    cursor: pointer;
    list-style: none;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
}

.lang-menu summary::-webkit-details-marker {
    display: none;
}

.lang-menu summary::after {
    content: " \25BE";
    color: var(--text-muted);
}

.lang-menu__list {
    position: absolute;
    right: 0;
    z-index: 10;
    min-width: 140px;
    margin: 6px 0 0;
    padding: 6px 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.lang-menu__item {
    display: block;
    padding: 6px 14px;
    color: var(--text);
}

.lang-menu__item:hover {
    background: var(--bg);
    text-decoration: none;
}

.lang-menu__item.is-active {
    font-weight: 600;
}
