* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    min-height: 100vh;
    color: #0f172a;
}

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

a:hover {
    text-decoration: underline;
}

.container {
    width: min(1720px, 96%);
    margin: 0 auto;
}

.topbar {
    background: var(--brand-primary);
    color: #fff;
    border-bottom: 4px solid var(--brand-secondary);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 72px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    font-weight: 700;
}

.brand img {
    height: 38px;
    width: auto;
    display: block;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: #fff;
    font-weight: 600;
}

.link-button {
    border: 0;
    background: transparent;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.page-content {
    padding: 2rem 0 3rem;
}

.card {
    background: #fff;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
}

.card + .card {
    margin-top: 1rem;
}

h1, h2, h3 {
    margin-top: 0;
}

.grid {
    display: grid;
    gap: 1rem;
}

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

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.92rem;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.62rem 0.95rem;
    border-radius: 8px;
    border: 0;
    cursor: pointer;
    font-weight: 700;
    background: var(--brand-secondary);
    color: #fff;
}

.button-secondary {
    background: #475569;
}

.button-danger {
    background: #b91c1c;
}

.button-muted {
    background: #e2e8f0;
    color: #0f172a;
}

.form-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.alert {
    margin-bottom: 1rem;
    padding: 0.8rem 0.9rem;
    border-radius: 8px;
    border: 1px solid;
}

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

.alert.error {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.alert ul {
    margin: 0;
    padding-left: 1rem;
}

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

th,
td {
    padding: 0.65rem 0.6rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: top;
}

th {
    font-size: 0.88rem;
    color: #334155;
}

.table-sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: inherit;
    text-decoration: none;
}

.table-sort-link:hover {
    text-decoration: none;
    color: var(--brand-primary);
}

.table-sort-link.is-active {
    color: var(--brand-primary);
}

.table-sort-icon {
    font-size: 0.72rem;
    color: #64748b;
}

.badge {
    display: inline-block;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: #e2e8f0;
}

.badge-priority-high,
.badge-priority-urgent {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-priority-medium {
    background: #fef3c7;
    color: #92400e;
}

.badge-priority-low {
    background: #dcfce7;
    color: #166534;
}

.kanban {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: start;
    min-width: 1500px;
}

.kanban-scroll {
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.kanban-column {
    border: 1px solid #d6dee7;
    border-radius: 12px;
    min-height: 420px;
    padding: 0.75rem;
}

.kanban-column h3 {
    margin: 0 0 0.75rem;
    font-size: 0.98rem;
}

.kanban-column[data-status="new"] {
    background: linear-gradient(180deg, #eff6ff 0%, #f8fbff 100%);
    border-color: #bfdbfe;
}

.kanban-column[data-status="triage"] {
    background: linear-gradient(180deg, #fff7ed 0%, #fffbf5 100%);
    border-color: #fed7aa;
}

.kanban-column[data-status="in_progress"] {
    background: linear-gradient(180deg, #f0fdf4 0%, #f8fff9 100%);
    border-color: #bbf7d0;
}

.kanban-column[data-status="waiting_customer"] {
    background: linear-gradient(180deg, #fff7ed 0%, #fffaf0 100%);
    border-color: #fdba74;
}

.kanban-column[data-status="done"] {
    background: linear-gradient(180deg, #f1f5f9 0%, #f8fafc 100%);
    border-color: #cbd5e1;
}

.kanban-list {
    min-height: 320px;
    display: grid;
    gap: 0.6rem;
}

.ticket-card {
    background: #fff;
    border: 1px solid #dbe2ea;
    border-left: 4px solid #94a3b8;
    border-radius: 10px;
    padding: 0.6rem;
    cursor: grab;
}

.kanban-column[data-status="new"] .ticket-card {
    border-left-color: #3b82f6;
}

.kanban-column[data-status="triage"] .ticket-card {
    border-left-color: #f59e0b;
}

.kanban-column[data-status="in_progress"] .ticket-card {
    border-left-color: #10b981;
}

.kanban-column[data-status="waiting_customer"] .ticket-card {
    border-left-color: #f97316;
}

.kanban-column[data-status="done"] .ticket-card {
    border-left-color: #64748b;
}

.ticket-card.dragging {
    opacity: 0.45;
}

.ticket-card p {
    margin: 0.4rem 0;
    font-size: 0.9rem;
    color: #334155;
}

.small {
    font-size: 0.84rem;
    color: #475569;
}

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

.stat {
    border-left: 4px solid var(--brand-secondary);
    padding: 0.8rem;
    background: #fff;
    border-radius: 8px;
}

.stat strong {
    display: block;
    font-size: 1.5rem;
}

.time-report-filters {
    align-items: end;
}

.time-report-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.time-report-chart {
    display: grid;
    gap: 0.85rem;
}

.time-report-bar-card {
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    padding: 0.9rem;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(241, 245, 249, 0.9) 100%),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.14), transparent 36%);
}

.time-report-bar-top {
    display: flex;
    justify-content: space-between;
    gap: 0.85rem;
    align-items: center;
    flex-wrap: wrap;
}

.time-report-bar-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

.time-report-bar-track {
    margin-top: 0.7rem;
    height: 14px;
    border-radius: 999px;
    background: #dbeafe;
    overflow: hidden;
}

.time-report-bar-fill {
    height: 100%;
    min-width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
}

.time-distribution-wrap {
    overflow-x: auto;
    padding-bottom: 0.35rem;
}

.time-distribution-chart {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 0.9rem;
    padding: 1rem;
    border: 1px solid #dbe2ea;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(241, 245, 249, 0.9) 0%, rgba(255, 255, 255, 0.96) 100%),
        radial-gradient(circle at top right, rgba(15, 23, 42, 0.06), transparent 24%);
}

.time-distribution-scale {
    height: 320px;
    padding-top: 1.35rem;
    padding-bottom: 2.6rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
}

.time-distribution-scale-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: #64748b;
    transform: translateY(50%);
}

.time-distribution-plot-scroll {
    overflow-x: auto;
    overflow-y: hidden;
}

.time-distribution-plot {
    min-width: max-content;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(36px, 42px);
    gap: 0.65rem;
    align-items: end;
    height: 320px;
}

.time-distribution-column {
    display: grid;
    grid-template-rows: minmax(1.1rem, auto) 240px 2.2rem;
    gap: 0.45rem;
    align-items: end;
}

.time-distribution-column-value {
    min-height: 1.1rem;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    color: #0f172a;
}

.time-distribution-column-area {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 240px;
    border-bottom: 2px solid rgba(100, 116, 139, 0.26);
    background-image: repeating-linear-gradient(
        to top,
        rgba(148, 163, 184, 0.24) 0,
        rgba(148, 163, 184, 0.24) 1px,
        transparent 1px,
        transparent 25%
    );
    background-size: 100% 25%;
    background-position: bottom;
}

.time-distribution-column-bar {
    width: 18px;
    min-height: 0;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(180deg, #9fd45f 0%, #77b83a 100%);
    box-shadow: 0 10px 18px rgba(119, 184, 58, 0.22);
}

.time-distribution-column-label {
    min-height: 2.2rem;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    color: #334155;
    white-space: nowrap;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    justify-self: center;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.project-summary-toggle {
    cursor: pointer;
    font-weight: 700;
    list-style: none;
}

.project-summary-toggle::-webkit-details-marker {
    display: none;
}

.project-list-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.project-filters {
    display: grid;
    gap: 0.7rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    width: min(520px, 100%);
}

.project-list {
    display: grid;
    gap: 0.75rem;
}

.project-item {
    border: 1px solid #dbe2ea;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.04);
}

.project-item[open] {
    border-color: #bcd0e2;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.project-item-summary {
    cursor: pointer;
    list-style: none;
    padding: 0.75rem 0.85rem;
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    align-items: center;
}

.project-item-summary::-webkit-details-marker {
    display: none;
}

.project-item-title {
    display: inline-flex;
    align-items: baseline;
    gap: 0.45rem;
}

.project-item-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.project-item-body {
    padding: 0 0.85rem 0.85rem;
    border-top: 1px solid #e2e8f0;
    margin-top: 0.2rem;
}

.project-status-badge {
    color: #0f172a;
}

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

.project-status-inactive {
    background: #fee2e2;
    color: #b91c1c;
}

.file-list {
    margin: 0;
    padding-left: 1rem;
}

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.8rem;
    max-height: 560px;
    overflow-y: auto;
    background: linear-gradient(180deg, #f2efe9 0%, #ece8df 100%);
    background-image:
        radial-gradient(circle at 20% 12%, rgba(255, 255, 255, 0.35), transparent 32%),
        radial-gradient(circle at 78% 76%, rgba(255, 255, 255, 0.2), transparent 28%);
}

.chat-panel {
    border: 1px solid #d8d5cf;
    border-radius: 12px;
    overflow: hidden;
    background: #f0f2f5;
}

.chat-message-row {
    display: flex;
    width: 100%;
}

.chat-message-row.is-own {
    justify-content: flex-end;
}

.chat-message-row.is-other {
    justify-content: flex-start;
}

.chat-message-bubble {
    position: relative;
    max-width: min(78%, 700px);
    background: #ffffff;
    border-radius: 8px;
    padding: 0.48rem 0.62rem 0.5rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.06);
}

.chat-message-row.is-own .chat-message-bubble {
    background: #dcf8c6;
    border-color: #bde9a2;
}

.chat-message-row.is-other .chat-message-bubble::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 10px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid #ffffff;
}

.chat-message-row.is-own .chat-message-bubble::after {
    content: "";
    position: absolute;
    right: -7px;
    top: 10px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid #dcf8c6;
}

.chat-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
    font-size: 0.76rem;
    color: #64748b;
}

.chat-author {
    color: #0f172a;
    font-size: 0.79rem;
}

.chat-time {
    white-space: nowrap;
    margin-left: auto;
    font-size: 0.72rem;
    color: #64748b;
}

.chat-body {
    margin: 0.3rem 0 0;
    white-space: pre-line;
    font-size: 0.92rem;
    line-height: 1.45;
}

.chat-attachments {
    margin-top: 0.45rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.chat-thumb {
    width: 156px;
    height: 112px;
    object-fit: cover;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    display: block;
    background: #fff;
}

.chat-file-link {
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 0.33rem 0.5rem;
    background: #fff;
    font-size: 0.83rem;
}

.chat-composer {
    border-top: 1px solid #d7dce2;
    background: #f0f2f5;
    padding: 0.7rem;
}

.chat-composer-label {
    margin-bottom: 0.4rem;
    color: #334155;
}

.chat-composer-input {
    border-radius: 9px;
    background: #fff;
    min-height: 90px;
}

.chat-composer-footer {
    margin-top: 0.55rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.chat-file-input-wrap {
    min-width: 240px;
    flex: 1 1 auto;
}

.chat-send-button {
    background: var(--brand-secondary);
    color: #fff;
    min-width: 110px;
    border-radius: 999px;
}

.chat-send-button:hover {
    filter: brightness(0.95);
}

.pagination-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
}

.pagination-nav-simple {
    justify-content: flex-end;
}

.pagination-summary {
    margin: 0;
    font-size: 0.84rem;
    color: #475569;
}

.pagination-summary strong {
    color: #0f172a;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.pagination-link,
.pagination-current,
.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.6rem;
    min-height: 2.6rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1;
}

.pagination-link {
    color: #0f172a;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.pagination-link:hover {
    text-decoration: none;
    border-color: var(--brand-secondary);
    color: var(--brand-primary);
    background: #f8fbff;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.12);
}

.pagination-link-prev,
.pagination-link-next {
    gap: 0.35rem;
    min-width: auto;
    white-space: nowrap;
}

.pagination-current {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
    color: #fff;
}

.pagination-ellipsis {
    color: #64748b;
}

.pagination-link.is-disabled,
.pagination-link[aria-disabled="true"] {
    color: #94a3b8;
    background: #f8fafc;
    border-color: #dbe2ea;
    cursor: not-allowed;
    box-shadow: none;
}

.pagination-arrow {
    font-size: 1rem;
    line-height: 1;
}

@media (max-width: 760px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.8rem 0;
    }

    .container {
        width: min(1720px, 94%);
    }

    .project-item-summary {
        flex-direction: column;
        align-items: flex-start;
    }

    .time-report-bar-top {
        align-items: flex-start;
    }

    .time-distribution-chart {
        grid-template-columns: 58px minmax(0, 1fr);
    }

    .time-distribution-plot {
        grid-auto-columns: minmax(28px, 34px);
        gap: 0.5rem;
    }

    .time-distribution-column-area {
        height: 180px;
    }

    .time-distribution-column {
        grid-template-rows: minmax(1rem, auto) 180px 2rem;
    }

    .time-distribution-column-bar {
        width: 14px;
    }

    .pagination-nav {
        align-items: stretch;
    }

    .pagination-summary {
        width: 100%;
    }

    .pagination-controls {
        width: 100%;
    }
}
