/* ============================================================
   TaskFlow — Modern Blue Dashboard
   ============================================================ */
:root {
    --blue:        #2563eb;
    --blue-dark:   #1d4ed8;
    --blue-light:  #dbeafe;
    --teal:        #0d9488;
    --amber:       #d97706;
    --green:       #16a34a;
    --red:         #dc2626;
    --ink:         #0f172a;
    --slate:       #475569;
    --muted:       #94a3b8;
    --line:        #e2e8f0;
    --bg:          #f1f5f9;
    --card:        #ffffff;
    --radius:      14px;
    --shadow:      0 4px 20px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
.muted { color: var(--slate); }
.small { font-size: .82rem; }
.hint  { color: var(--muted); font-size: .82rem; margin-top: 6px; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    padding: 10px 16px; border-radius: 10px; font-size: .9rem; font-weight: 600;
    cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.full { width: 100%; }
.btn.small { padding: 8px 12px; font-size: .82rem; }
.btn.tiny  { padding: 6px 10px; font-size: .78rem; border-radius: 8px; }

/* ---------------- Auth pages ---------------- */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
    padding: 24px;
}
.auth-wrap { width: 100%; max-width: 520px; }
.auth-wrap.narrow { max-width: 420px; }
.brand { text-align: center; color: #fff; margin-bottom: 18px; }
.brand h1 { font-size: 1.8rem; letter-spacing: -.5px; }
.brand-sub { color: #dbeafe; font-size: .92rem; margin-top: 4px; }
.brand-logo {
    width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 16px;
    background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.3rem; color: #fff;
}
.brand-logo.sm { width: 38px; height: 38px; font-size: 1rem; border-radius: 11px;
    background: var(--blue); border: none; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; }

/* tabs (home) */
.tabs { display: flex; gap: 8px; background: #f1f5f9; padding: 5px; border-radius: 12px; margin-bottom: 20px; }
.tab-btn { flex: 1; border: none; background: transparent; padding: 10px; border-radius: 9px;
    font-weight: 600; color: var(--slate); cursor: pointer; transition: .15s; }
.tab-btn.active { background: #fff; color: var(--blue); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fade .2s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* fields */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: var(--slate); margin-bottom: 6px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
    font-size: .92rem; font-family: inherit; background: #fff; transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* alerts */
.alert { padding: 12px 14px; border-radius: 10px; font-size: .88rem; margin-bottom: 16px; }
.alert.error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* result box */
.result-box { background: #f8fafc; border: 1px dashed var(--line); border-radius: 12px; padding: 16px; margin-bottom: 18px; }
.result-box label { display: block; font-size: .78rem; font-weight: 700; color: var(--slate); margin: 10px 0 5px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
    font-size: .85rem; background: #fff; }
.foot-note { text-align: center; color: #dbeafe; font-size: .8rem; margin-top: 18px; }
.ws-head { text-align: center; margin-bottom: 18px; }
.ws-head h2 { font-size: 1.3rem; }

/* ---------------- App layout ---------------- */
.app { background: var(--bg); }
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px; background: #0f172a; color: #cbd5e1; flex-shrink: 0;
    display: flex; flex-direction: column; padding: 18px 14px;
    position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; border-bottom: 1px solid #1e293b; }
.side-brand strong { color: #fff; display: block; }
.ws-tag { display: inline-block; font-size: .68rem; color: #93c5fd; background: #1e293b;
    padding: 2px 8px; border-radius: 20px; margin-top: 3px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 10px;
    font-weight: 500; color: #cbd5e1; transition: .15s; }
.side-nav a span { font-size: 1.05rem; }
.side-nav a:hover { background: #1e293b; color: #fff; }
.side-nav a.active { background: var(--blue); color: #fff; }
.side-nav a.logout { margin-top: auto; color: #fca5a5; }
.side-nav a.logout:hover { background: #7f1d1d33; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 16px 26px;
    display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 20; }
.topbar h2 { font-size: 1.15rem; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; }
.content { padding: 26px; max-width: 1100px; width: 100%; }

/* stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
    border-left: 4px solid var(--blue); display: flex; flex-direction: column; gap: 4px; }
.stat-card.blue  { border-color: var(--blue); }
.stat-card.teal  { border-color: var(--teal); }
.stat-card.amber { border-color: var(--amber); }
.stat-card.green { border-color: var(--green); }
.stat-num { font-size: 1.9rem; font-weight: 800; color: var(--ink); }
.stat-label { font-size: .85rem; color: var(--slate); }

/* panels */
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.panel h3 { font-size: 1.05rem; margin-bottom: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h3 { margin: 0; }

/* status bars */
.status-bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 12px; }
.bar-label { font-size: .85rem; color: var(--slate); }
.bar-track { background: #f1f5f9; border-radius: 20px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; background: var(--blue); transition: width .4s; }
.bar-val { font-weight: 700; text-align: right; }
.s-not_started { background: var(--muted) !important; }
.s-open    { background: var(--blue) !important; }
.s-process { background: var(--amber) !important; }
.s-done    { background: var(--green) !important; }
.s-cancelled { background: var(--red) !important; }

/* tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th { text-align: left; padding: 11px 12px; color: var(--slate); font-size: .78rem;
    text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--line); }
.data-table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.empty { text-align: center; color: var(--muted); padding: 26px !important; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* pills */
.pill { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: .74rem; font-weight: 700; color: #fff; }
.pill.ok  { background: var(--green); }
.pill.off { background: var(--muted); }
.pill.s-not_started { background: var(--muted); }
.pill.s-open    { background: var(--blue); }
.pill.s-process { background: var(--amber); }
.pill.s-done    { background: var(--green); }
.pill.s-cancelled { background: var(--red); }

/* modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5);
    z-index: 100; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal.open { display: flex; }
.modal-card { background: #fff; border-radius: var(--radius); width: 100%; max-width: 540px;
    padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: fade .2s; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-close { background: none; border: none; font-size: 1.6rem; cursor: pointer; color: var(--muted); }
.form-msg { font-size: .85rem; margin: 6px 0 12px; min-height: 18px; }
.form-msg.err { color: var(--red); }
.form-msg.ok  { color: var(--green); }

/* user dashboard sections */
.dash-section { display: none; }
.dash-section.active { display: block; }
.section-head { margin-bottom: 16px; }
.section-head h3 { font-size: 1.25rem; }

.task-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; background: #fff;
    padding: 6px; border-radius: 12px; box-shadow: var(--shadow); }
.ttab { border: none; background: transparent; padding: 9px 16px; border-radius: 9px;
    font-weight: 600; color: var(--slate); cursor: pointer; font-size: .87rem; }
.ttab.active { background: var(--blue); color: #fff; }

.task-list { display: none; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.task-list.active { display: grid; }
.task-card { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
    border-top: 3px solid var(--blue); }
.task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.task-top h4 { font-size: 1rem; }
.task-desc { font-size: .87rem; color: var(--slate); margin-bottom: 12px; }
.task-meta { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--slate); margin-bottom: 12px; }
.task-actions { display: flex; gap: 8px; }
.cancelled-note { background: #fef2f2; color: #991b1b; font-size: .82rem; padding: 7px 10px;
    border-radius: 8px; margin-bottom: 10px; font-weight: 600; }

.assign-form .btn { margin-top: 6px; }

/* notifications */
.notif-wrap { position: relative; margin-left: auto; }
.notif-btn { position: relative; background: #f1f5f9; border: none; width: 42px; height: 42px;
    border-radius: 11px; font-size: 1.15rem; cursor: pointer; }
.notif-dot { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px;
    background: var(--red); border-radius: 50%; border: 2px solid #fff; }
.notif-panel { position: absolute; right: 0; top: 50px; width: 320px; background: #fff;
    border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.18); border: 1px solid var(--line);
    z-index: 50; overflow: hidden; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 13px 15px;
    border-bottom: 1px solid var(--line); font-weight: 700; font-size: .9rem; }
.link-btn { background: none; border: none; color: var(--blue); font-size: .8rem; cursor: pointer; font-weight: 600; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { padding: 12px 15px; border-bottom: 1px solid var(--line); font-size: .85rem; }
.notif-item.unread { background: var(--blue-light); }
.notif-item .nt { color: var(--muted); font-size: .72rem; margin-top: 3px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .sidebar { position: fixed; left: -260px; z-index: 200; transition: left .25s; box-shadow: 4px 0 30px rgba(0,0,0,.3); }
    .sidebar.open { left: 0; }
    .menu-toggle { display: block; }
}
@media (max-width: 560px) {
    .grid-2 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .content { padding: 16px; }
    .topbar { padding: 14px 16px; }
    .notif-panel { width: 280px; }
    .auth-wrap { max-width: 100%; }
}

/* ---------------- Incentives / leaderboard / score ---------------- */
.score-badge {
    margin-left: auto; background: #fff7ed; color: #b45309; border: 1px solid #fed7aa;
    padding: 8px 14px; border-radius: 11px; font-weight: 800; font-size: .95rem; white-space: nowrap;
}
.notif-wrap { margin-left: 14px; }
.rank-badge {
    display: inline-flex; align-items: center; justify-content: center; min-width: 38px;
    padding: 4px 10px; border-radius: 20px; font-weight: 800; font-size: .8rem;
    background: #e2e8f0; color: var(--slate);
}
.rank-badge.r1 { background: #fef3c7; color: #b45309; }
.rank-badge.r2 { background: #e2e8f0; color: #475569; }
.rank-badge.r3 { background: #fde2c8; color: #c2410c; }
.score-num { color: var(--blue); font-size: 1.05rem; }

.my-score-card {
    background: linear-gradient(135deg, #1e3a8a, #2563eb); color: #fff;
    border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px; box-shadow: var(--shadow);
}
.big-score { font-size: 2.4rem; font-weight: 900; line-height: 1; margin-top: 4px; }
.my-score-card .muted { color: #dbeafe; }
.rule-note { background: rgba(255,255,255,.15); padding: 8px 14px; border-radius: 10px; font-size: .85rem; }

.me-row { background: var(--blue-light); }
.you-tag { background: var(--blue); color: #fff; font-size: .68rem; padding: 2px 8px; border-radius: 20px; margin-left: 6px; }
