/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0f1117;
    --surface:   #1a1d27;
    --surface2:  #22263a;
    --border:    #2e3347;
    --text:      #e2e8f0;
    --text-muted:#8892a4;
    --accent:    #4f8ef7;
    --error:     #f87171;
    --success:   #34d399;
    --radius:    10px;
    --shadow:    0 2px 12px rgba(0,0,0,.4);
}

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    flex: 1;
    margin-left: 1rem;
}

.nav-item {
    padding: .35rem .8rem;
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: background .15s, color .15s;
    white-space: nowrap;
}

.nav-item:hover {
    background: var(--surface2);
    color: var(--text);
    text-decoration: none;
}

.nav-item.active {
    background: rgba(79, 142, 247, .15);
    color: var(--accent);
}

.topbar-title {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: .02em;
    color: var(--text);
}

/* ── Container ───────────────────────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.2rem;
    border-radius: 6px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .85; text-decoration: none; }

.btn-primary  { background: var(--accent);  color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm       { padding: .35rem .85rem; font-size: .8rem; }
.btn-block    { width: 100%; justify-content: center; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
    padding: .9rem 1.2rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: .9rem;
    line-height: 1.5;
}
.alert-error { background: #7f1d1d30; border: 1px solid #f8717140; color: var(--error); }
.alert-info  { background: #1e3a5f30; border: 1px solid #4f8ef740; color: #93c5fd; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
}

.login-box h1 {
    font-size: 1.5rem;
    margin-bottom: .25rem;
}

.login-box .subtitle {
    color: var(--text-muted);
    font-size: .9rem;
    margin-bottom: 2rem;
}

/* ── Form elements ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .4rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-group input,
select {
    width: 100%;
    padding: .65rem .9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface2);
    color: var(--text);
    font-size: .95rem;
    outline: none;
    transition: border-color .15s;
}

.form-group input:focus,
select:focus { border-color: var(--accent); }

/* ── Week form ───────────────────────────────────────────────────────────── */
.week-form {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.week-form label {
    font-weight: 600;
    font-size: .9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

.week-form select { width: auto; min-width: 260px; }

.period-label {
    font-size: .9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* ── Week total ──────────────────────────────────────────────────────────── */
.week-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.75rem;
}

.week-total-label {
    font-size: .85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}

.week-total-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
}

/* ── Project card ────────────────────────────────────────────────────────── */
.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--project-color, var(--accent));
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.project-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,.02);
}

.project-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--project-color, var(--accent));
    flex-shrink: 0;
}

.project-header h2 {
    font-size: 1rem;
    font-weight: 700;
    flex: 1;
}

.project-total {
    font-size: .85rem;
    font-weight: 700;
    color: var(--project-color, var(--accent));
    background: color-mix(in srgb, var(--project-color, var(--accent)) 15%, transparent);
    padding: .2em .7em;
    border-radius: 999px;
}

/* ── Days list ───────────────────────────────────────────────────────────── */
.days-list { padding: .5rem 0; }

.day-block { padding: .75rem 1.25rem; }

.day-block + .day-block {
    border-top: 1px solid var(--border);
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .5rem;
}

.day-name {
    font-weight: 600;
    font-size: .9rem;
    color: var(--text);
}

.day-total {
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* ── Entry list ──────────────────────────────────────────────────────────── */
.entry-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.entry {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    font-size: .875rem;
    padding: .2rem .4rem;
    border-radius: 4px;
    background: var(--surface2);
}

.entry:hover { background: rgba(255,255,255,.04); }

.wi-project {
    flex-shrink: 0;
    font-size: .7rem;
    font-weight: 600;
    color: var(--project-color, var(--accent));
    background: rgba(255,255,255,.07);
    border-radius: 4px;
    padding: .1em .45em;
    margin-right: .25rem;
    white-space: nowrap;
}

.wi-id {
    flex-shrink: 0;
    font-size: .75rem;
    font-weight: 600;
    color: var(--accent);
    font-family: 'SFMono-Regular', Consolas, monospace;
    min-width: 4rem;
    text-decoration: none;
}
.wi-id:hover { text-decoration: underline; }

.wi-title {
    flex: 1;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wi-comment {
    color: var(--text-muted);
    font-size: .8rem;
}

.wi-hours {
    flex-shrink: 0;
    font-weight: 700;
    font-size: .85rem;
    color: var(--project-color, var(--accent));
    min-width: 3.5rem;
    text-align: right;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (min-width: 1600px) {
    .container, .topbar-inner { max-width: 1500px; }
}
@media (min-width: 1920px) {
    .container, .topbar-inner { max-width: 1800px; }
}
@media (min-width: 2560px) {
    .container, .topbar-inner { max-width: 2000px; }
}

@media (max-width: 600px) {
    .container { padding: 1rem .75rem 3rem; }
    .week-form select { min-width: 100%; }

    .topbar-inner {
        flex-wrap: wrap;
        padding: .6rem 1rem;
        gap: .5rem;
    }

    /* Sign out button stays on the same row as the title */
    .topbar-inner > .btn {
        order: 2;
        margin-left: auto;
    }

    /* Nav drops to a second full-width row */
    .topbar-nav {
        order: 3;
        flex-basis: 100%;
        margin-left: 0;
        flex-wrap: wrap;
        border-top: 1px solid var(--border);
        padding-top: .5rem;
        gap: .3rem;
    }

    .nav-item {
        padding: .3rem .6rem;
        font-size: .8rem;
    }
}

/* ── Work item table (SLA page) ──────────────────────────────────────────── */
.wi-table-wrap {
    margin-top: .5rem;
    overflow-x: auto;
}

.wi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.wi-table th,
.wi-table td {
    padding: .6rem .9rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.wi-table th {
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--surface);
}

.wi-table th:first-child { border-radius: var(--radius) 0 0 0; }
.wi-table th:last-child  { border-radius: 0 var(--radius) 0 0; }

.wi-table tbody tr:hover { background: rgba(255,255,255,.03); }

.col-follow   { width: 2rem; text-align: center !important; }
.col-logged   { width: 5rem; text-align: right !important; font-weight: 600; color: var(--accent); }
.col-id       { width: 5rem; }
.col-type     { width: 8rem; }
.col-title    { white-space: normal; min-width: 200px; }
.col-state    { width: 8rem; }
.col-priority { width: 5rem; text-align: center !important; }
.col-comments { width: 5rem; text-align: center !important; }
.col-assigned { min-width: 10rem; }

.follow-star {
    color: #f5c518;
    font-size: 1rem;
    line-height: 1;
}

.wi-link {
    color: var(--accent);
    text-decoration: none;
}
.wi-link:hover { text-decoration: underline; }

.state-badge {
    display: inline-block;
    padding: .2em .6em;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 600;
}
.state-new      { background: rgba(142,68,173,.2);  color: #c39bd3; }
.state-active   { background: rgba(79,142,247,.2);  color: #4f8ef7; }
.state-resolved { background: rgba(52,168,83,.2);   color: #34a853; }
.state-closed   { background: rgba(78,157,93,.2);   color: rgb(78,157,93); }
.state-fordev   { background: rgba(251,188,61,.2);   color: rgb(251,188,61); }
.state-ack      { background: rgba(170,156,223,.2);  color: rgb(170,156,223); }
.state-waiting  { background: rgba(86,136,224,.2);   color: rgb(86,136,224); }
.state-foracc   { background: rgba(195,216,76,.2);   color: rgb(195,216,76); }
.state-hotfixed { background: rgba(251,188,61,.2);   color: rgb(251,188,61); }
.state-other    { background: rgba(142,152,164,.15); color: #8e98a4; }

.row-weekend {
    background: rgba(255,255,255,.08);
}
.row-weekend .summary-day {
    color: var(--text-muted);
    font-style: italic;
}
.row-weekend:hover {
    background: rgba(255,255,255,.12) !important;
}
.row-weekend .summary-week-total,
.row-weekend:hover .summary-week-total {
    background: var(--bg);
}

.row-holiday {
    background: rgba(255,160,80,.12);
}
.row-holiday .summary-day {
    color: #e8964a;
}
.row-holiday .summary-week-total,
.row-holiday:hover .summary-week-total {
    background: var(--bg);
}
.row-holiday:hover {
    background: rgba(255,160,80,.18) !important;
}
.holiday-name {
    font-size: .72em;
    color: #e8964a;
    opacity: .8;
    font-style: italic;
}

.wi-table-count {
    margin-top: .75rem;
    font-size: .8rem;
    color: var(--text-muted);
    text-align: right;
}


/* ── Month stats bar ─────────────────────────────────────────────────────── */
.month-stats {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.month-stat {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    flex-shrink: 0;
}

.month-stat-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
}

.month-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.month-progress-wrap {
    flex: 1;
    min-width: 220px;
}

.month-progress-header {
    display: flex;
    justify-content: space-between;
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: .4rem;
}

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

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width .4s ease;
}

.progress-bar-fill.over-goal { background: var(--success); }

.progress-bar-expected { margin-top: 4px; }

.progress-bar-fill-expected { background: var(--error); }

.month-progress-expected {
    margin-top: .45rem;
    font-size: .8rem;
    color: var(--text-muted);
}

.delta { font-weight: 700; }
.delta-positive { color: var(--success); }
.delta-negative { color: var(--error); }

/* ── Summary table ───────────────────────────────────────────────────────── */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
    margin-top: .5rem;
}

.summary-table th,
.summary-table td {
    padding: .6rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.summary-table th:first-child,
.summary-table td:first-child {
    text-align: left;
}

.summary-table thead th {
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--surface);
}

.summary-table thead th:first-child { border-radius: var(--radius) 0 0 0; }
.summary-table thead th:last-child  { border-radius: 0 var(--radius) 0 0; }

.summary-table tbody tr:hover { background: rgba(255,255,255,.06); }

.summary-day {
    color: var(--text-muted);
    font-size: .82rem;
}

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

.summary-cell.has-hours {
    color: var(--col-color, var(--accent));
    font-weight: 600;
}

.summary-total {
    font-weight: 700;
    color: var(--text);
}

.summary-week-total {
    font-weight: 700;
    color: var(--accent);
    border-left: 2px solid var(--border);
    vertical-align: middle;
    text-align: center;
}

.summary-table tfoot td {
    border-top: 2px solid var(--border);
    border-bottom: none;
    background: var(--surface);
}

.summary-table tfoot .summary-day {
    color: var(--text);
    font-weight: 600;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 1rem;
}

.modal-overlay[hidden] { display: none; }

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 460px;
    padding: 1.75rem;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 .25rem;
    transition: color .15s;
}
.modal-close:hover { color: var(--text); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row-3 {
    grid-template-columns: 2fr 1fr 1fr;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: 1.5rem;
}

.modal-box .alert {
    margin-top: 1rem;
    margin-bottom: 0;
}


/* ── Trends ─────────────────────────────────────────────────────────────── */

.trends-chart-wrap {
    margin-bottom: 2rem;
}

.trends-toggles {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.trends-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    user-select: none;
    font-size: .9rem;
}

.trends-toggle-swatch {
    display: inline-block;
    width: 28px;
    height: 3px;
    border-radius: 2px;
}
