:root {
    --color-bg: #f5f7fb;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;
    --color-text: #111827;
    --color-muted: #6b7280;
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-danger: #dc2626;
    --color-danger-dark: #991b1b;
    --sidebar-width: 250px;
    --topbar-height: 64px;
    --content-max-width: 1280px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
}

a {
    color: inherit;
}

.topbar {
    min-height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    min-width: 0;
}

.topbar__logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}

.topbar__title {
    font-weight: 800;
    line-height: 1.2;
}

.topbar__subtitle {
    font-size: 13px;
    color: var(--color-muted);
    line-height: 1.3;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.topbar__user {
    font-size: 14px;
    color: var(--color-muted);
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layout {
    display: flex;
    min-height: calc(100vh - var(--topbar-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 18px 12px;
    flex-shrink: 0;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: calc(var(--topbar-height) + 18px);
}

.sidebar__link {
    color: var(--color-muted);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
}

.sidebar__link:hover {
    background: #eef2ff;
    color: var(--color-primary);
}

.sidebar__link--active {
    background: #dbeafe;
    color: var(--color-primary);
    font-weight: 800;
}

.sidebar__link-icon {
    width: 22px;
    flex-shrink: 0;
    text-align: center;
}

.content {
    flex: 1;
    min-width: 0;
    padding: 28px;
}

.content__inner {
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
}

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

.page-header h1 {
    margin: 0 0 6px;
    font-size: 28px;
    line-height: 1.2;
}

.page-header p {
    margin: 0;
    color: var(--color-muted);
    line-height: 1.5;
}

.page-header__actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.button {
    border: 0;
    border-radius: 9px;
    padding: 10px 14px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    line-height: 1.2;
    min-height: 40px;
    white-space: nowrap;
    font: inherit;
    font-weight: 800;
}

.button:disabled,
.button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.button--primary {
    background: var(--color-primary);
    color: white;
}

.button--primary:hover {
    background: var(--color-primary-dark);
}

.button--secondary {
    background: #eef2ff;
    color: var(--color-primary);
    text-decoration: none;
}

.button--secondary:hover {
    background: #dbeafe;
}

.button--small {
    padding: 7px 10px;
    font-size: 13px;
    min-height: 34px;
}

.button--ghost {
    background: #f8fafc;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.button--ghost:hover {
    background: #f1f5f9;
}

.button--danger {
    background: #fee2e2;
    color: var(--color-danger-dark);
}

.button--danger:hover {
    background: #fecaca;
}

.button--full {
    width: 100%;
    justify-content: center;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    min-width: 0;
}

.card + .card,
.card-grid + .card,
.card-grid + .card-grid,
.card + .card-grid {
    margin-top: 18px;
}

.card h2 {
    margin: 0 0 10px;
    font-size: 18px;
    line-height: 1.3;
}

.card p {
    color: var(--color-muted);
    line-height: 1.5;
}

.card ul {
    margin: 0;
    padding-left: 18px;
    color: var(--color-muted);
}

.flash-list {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    line-height: 1.4;
}

.flash--warning {
    border-color: #facc15;
    background: #fefce8;
    color: #854d0e;
}

.flash--success {
    border-color: #86efac;
    background: #f0fdf4;
    color: #166534;
}

.flash--danger {
    border-color: #fca5a5;
    background: #fef2f2;
    color: #991b1b;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, #dbeafe 0, transparent 30%),
        var(--color-bg);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.auth-card__header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.auth-card__header h1 {
    margin: 0 0 4px;
    font-size: 26px;
}

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

.form {
    display: grid;
    gap: 16px;
}

.form-card {
    max-width: 820px;
}

.form__group {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.form__label {
    font-size: 14px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.form__control {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 11px 12px;
    font: inherit;
    color: var(--color-text);
    background: white;
    min-height: 42px;
}

.form__control:focus {
    outline: 3px solid #bfdbfe;
    border-color: var(--color-primary);
}

.form__control--textarea {
    resize: vertical;
    min-height: 110px;
}

.form__control--color {
    height: 44px;
    padding: 4px;
}

.form__control--select-multiple {
    min-height: 150px;
}

.form__error {
    font-size: 13px;
    color: var(--color-danger);
}

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

.form__row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 16px;
}

.form__row--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text);
    font-weight: 700;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.info-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    border-radius: 999px;
    border: 1px solid #93c5fd;
    background: #eff6ff;
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    cursor: help;
    user-select: none;
}

.info-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 9px);
    transform: translateX(-50%);
    width: max-content;
    max-width: 260px;
    padding: 9px 11px;
    border-radius: 9px;
    background: #111827;
    color: white;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
    z-index: 30;
    white-space: normal;
}

.info-icon::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 4px);
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #111827;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
    z-index: 31;
}

.info-icon:hover::after,
.info-icon:focus::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

.info-icon:hover::before,
.info-icon:focus::before {
    opacity: 1;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.table-header h2 {
    margin: 0 0 4px;
}

.table-header p {
    margin: 0;
    color: var(--color-muted);
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
}

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

.data-table th {
    text-align: left;
    color: var(--color-muted);
    font-weight: 800;
    border-bottom: 1px solid var(--color-border);
    padding: 10px 12px;
    white-space: nowrap;
    background: #f8fafc;
}

.data-table td {
    border-bottom: 1px solid var(--color-border);
    padding: 12px;
    vertical-align: middle;
}

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

.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
    margin: 0;
}

.color-dot {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    flex-shrink: 0;
}

.color-dot--small {
    width: 10px;
    height: 10px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 13px;
    font-weight: 800;
}

.status-badge--active {
    background: #dcfce7;
    color: #166534;
}

.status-badge--inactive {
    background: #f1f5f9;
    color: #64748b;
}

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

.empty-state {
    border: 1px dashed var(--color-border);
    border-radius: 14px;
    padding: 28px;
    text-align: center;
    background: #f9fafb;
}

.empty-state h3 {
    margin: 0 0 8px;
}

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

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 0;
    margin: 0;
    list-style: none;
}

.tag-list li {
    border: 1px solid var(--color-border);
    background: #f9fafb;
    border-radius: 999px;
    padding: 7px 11px;
    color: var(--color-muted);
    font-size: 14px;
}

.multi-dropdown {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: white;
}

.multi-dropdown__summary {
    cursor: pointer;
    padding: 11px 12px;
    font-weight: 700;
    color: var(--color-text);
    min-height: 42px;
    display: flex;
    align-items: center;
}

.multi-dropdown__panel {
    display: grid;
    gap: 6px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--color-border);
    max-height: 220px;
    overflow-y: auto;
}

.multi-dropdown__option {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 4px;
    border-radius: 8px;
    cursor: pointer;
}

.multi-dropdown__option:hover {
    background: #f8fafc;
}

.multi-dropdown__option input {
    width: 16px;
    height: 16px;
}

.time-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 8px;
}

.time-select {
    cursor: pointer;
}

.filter-card {
    margin-bottom: 18px;
}

.filter-form {
    display: grid;
    grid-template-columns: 150px 150px 1fr 1fr minmax(220px, 1.4fr) auto;
    gap: 14px;
    align-items: end;
}

.filter-form__actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.entry-list {
    display: grid;
    gap: 12px;
}

.entry-card {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 14px;
    background: #ffffff;
    min-width: 0;
}

.entry-card__main {
    display: flex;
    gap: 18px;
    min-width: 0;
    flex: 1;
}

.entry-card__date {
    width: 140px;
    flex-shrink: 0;
    display: grid;
    gap: 4px;
    align-content: start;
}

.entry-card__date span {
    color: var(--color-muted);
    font-size: 14px;
}

.entry-card__content {
    display: grid;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.entry-card__title {
    font-weight: 800;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.entry-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.entry-card__duration {
    font-weight: 800;
    white-space: nowrap;
    color: var(--color-primary);
    flex-shrink: 0;
}

.entry-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-pill,
.tag-pill,
.source-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 13px;
    color: var(--color-muted);
    background: #f8fafc;
    line-height: 1.3;
}

.category-pill {
    color: var(--color-text);
    font-weight: 800;
}

.source-pill {
    color: var(--color-muted);
}

.dashboard-grid {
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    margin-top: 18px;
}

.dashboard-card-wide {
    min-width: 0;
}

.category-summary-list {
    display: grid;
    gap: 16px;
}

.category-summary-item {
    display: grid;
    gap: 7px;
}

.category-summary-item__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.category-summary-item__percent {
    color: var(--color-muted);
    font-size: 13px;
    text-align: right;
}

.progress-bar {
    height: 8px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.progress-bar__value {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--color-primary);
}

@media (max-width: 1180px) {
    .filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-form__search,
    .filter-form__actions {
        grid-column: span 2;
    }

    .filter-form__actions {
        justify-content: flex-start;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .topbar {
        align-items: flex-start;
        padding: 14px 18px;
    }

    .topbar__subtitle {
        display: none;
    }

    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--color-border);
        padding: 10px 12px;
        position: sticky;
        top: var(--topbar-height);
        z-index: 15;
    }

    .sidebar__nav {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 2px;
    }

    .sidebar__link {
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 40px;
    }

    .content {
        padding: 22px 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .page-header__actions {
        justify-content: flex-start;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .form__row,
    .form__row--three {
        grid-template-columns: 1fr;
    }

    .table-header {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 700px) {
    .topbar {
        position: static;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .topbar__actions {
        justify-content: space-between;
    }

    .topbar__user {
        max-width: 190px;
    }

    .sidebar {
        top: 0;
    }

    .content {
        padding: 18px 12px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .page-header__actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .page-header__actions .button,
    .page-header > .button {
        width: 100%;
    }

    .card {
        padding: 16px;
        border-radius: 14px;
    }

    .auth-card {
        padding: 22px;
    }

    .form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

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

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

    .filter-form__search,
    .filter-form__actions {
        grid-column: span 1;
    }

    .filter-form__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-form__actions .button {
        width: 100%;
    }

    .time-input-row {
        grid-template-columns: 1fr;
    }

    .entry-card {
        flex-direction: column;
        gap: 12px;
    }

    .entry-card__main {
        flex-direction: column;
        gap: 10px;
    }

    .entry-card__date {
        width: auto;
    }

    .entry-card__duration {
        align-self: flex-start;
    }

    .entry-card__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .entry-card__actions .button,
    .entry-card__actions .inline-form,
    .entry-card__actions .inline-form button {
        width: 100%;
    }

    .category-summary-item__header {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 430px) {
    .topbar__brand {
        align-items: flex-start;
    }

    .topbar__title {
        font-size: 15px;
    }

    .button {
        white-space: normal;
    }

    .sidebar__link-icon {
        width: auto;
    }

    .data-table {
        font-size: 13px;
    }
}

.timer-card {
    max-width: 820px;
}

.timer-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 18px;
    background: #f8fafc;
}

.timer-status h2 {
    margin: 0 0 6px;
}

.timer-status p {
    margin: 0;
}

.timer-status--running {
    border-color: #86efac;
    background: #f0fdf4;
}

.timer-display {
    font-size: 38px;
    font-weight: 900;
    color: var(--color-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.timer-start-form,
.timer-stop-form {
    margin-top: 18px;
}

@media (max-width: 700px) {
    .timer-status {
        flex-direction: column;
        align-items: flex-start;
    }

    .timer-display {
        font-size: 32px;
    }
}