/* ============ Base ============ */
* {
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #16a34a;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

h1 {
    font-size: 1.5rem;
    margin: 0 0 0.5rem;
}

h2 {
    font-size: 1.1rem;
    margin: 1.25rem 0 0.75rem;
}

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

/* ============ Topbar ============ */
.topbar {
    background: #0f172a;
    color: #fff;
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
}

.main-nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    flex: 1;
}

.main-nav a {
    color: #cbd5e1;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
}

.main-nav a:hover {
    background: #1e293b;
    color: #fff;
    text-decoration: none;
}

.main-nav a.active {
    background: var(--primary);
    color: #fff;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    color: #e2e8f0;
    font-size: 0.9rem;
}

/* ============ Layout ============ */
.container {
    max-width: 1100px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card h2:first-child {
    margin-top: 0;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.card-grid .card {
    margin-bottom: 0;
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
}

.empty-state {
    text-align: center;
    color: var(--muted);
}

.footer {
    text-align: center;
    color: var(--muted);
    padding: 1.5rem 0 2rem;
}

/* ============ Flash messages ============ */
.flash {
    border-radius: var(--radius);
    padding: 0.7rem 1rem;
    margin-bottom: 0.9rem;
    border: 1px solid transparent;
    font-size: 0.95rem;
}

.flash-success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

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

.flash-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

/* ============ Buttons ============ */
.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    background: #e2e8f0;
    color: var(--text);
    text-decoration: none;
}

.btn:hover {
    filter: brightness(0.95);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: inherit;
}

.topbar .btn-outline {
    border-color: #475569;
    color: #e2e8f0;
}

.btn-small {
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ============ Forms ============ */
label {
    display: block;
    margin: 0.75rem 0 0.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    background: #fff;
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

form .btn[type="submit"] {
    margin-top: 1rem;
}

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

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

.checkbox-field {
    display: flex;
    align-items: end;
    padding-bottom: 0.4rem;
}

.checkbox-field label {
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.filter-form {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.filter-form label {
    margin-top: 0;
}

.filter-form .btn {
    margin-top: 0;
}

.inline-form {
    display: inline-flex;
    gap: 0.3rem;
}

/* ============ Tables ============ */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

th,
td {
    text-align: left;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:last-child td {
    border-bottom: none;
}

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

.actions {
    white-space: nowrap;
}

.cell-progress {
    min-width: 180px;
}

/* ============ Badges & alerts ============ */
.badge {
    display: inline-block;
    background: #e2e8f0;
    color: #334155;
    border-radius: 999px;
    font-size: 0.75rem;
    padding: 0.1rem 0.6rem;
    white-space: nowrap;
}

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

.badge-muted {
    background: #f1f5f9;
    color: var(--muted);
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.alert-tag {
    display: inline-block;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    margin-left: 0.4rem;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* ============ Progress bars ============ */
.progress {
    background: #e2e8f0;
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
    margin: 0.4rem 0;
}

.progress-sm {
    height: 8px;
}

.progress-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
}

.bar-ok {
    background: var(--success);
}

.bar-warning {
    background: var(--warning);
}

.bar-danger {
    background: var(--danger);
}

.progress-label {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0.2rem 0 0;
}

/* ============ Project cards & stats ============ */
.project-card-head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 0.5rem;
}

.project-card h2 {
    margin: 0;
}

.stat-card {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-dark);
}

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

/* ============ Timer ============ */
.timer-banner {
    background: #1e3a8a;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.55rem 1rem;
    justify-content: center;
}

.timer-banner .timer-elapsed {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.timer-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4ade80;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.tracker-card {
    max-width: 640px;
}

.tracker-running {
    border-left: 5px solid var(--success);
}

.big-elapsed {
    font-size: 2.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin: 0.5rem 0;
    color: var(--success);
}

/* ============ Auth (login / installer) ============ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    padding: 1rem;
}

.auth-card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    text-align: center;
}

.auth-card .muted {
    text-align: center;
    margin-top: 0;
}

.auth-card .btn {
    margin-top: 1.25rem;
}

/* ============ Responsive ============ */
@media (max-width: 720px) {
    .two-cols,
    .form-row {
        grid-template-columns: 1fr;
    }

    .topbar-inner {
        gap: 0.5rem;
    }

    .page-head {
        flex-direction: column;
        align-items: flex-start;
    }
}
