/* =========================================================
   Matrix System - App CSS
   Version: Auth Final Spacing v09
   Path: /public_html/assets/app.css

   หลักรอบนี้:
   - เขียนใหม่แบบสะอาด ไม่ patch ซ้อน
   - Font ใช้ Sarabun อย่างเดียว
   - Login/Register card สูงเท่ากัน
   - หมายเหตุอยู่ด้านล่าง มี padding ล่างเท่ากับ padding บน
   - ถ้าหน้า Register ไม่พอ ให้ขยาย card ลง ไม่บีบ content
   ========================================================= */

:root {
    --bg-1: #1f2d3d;
    --bg-2: #111a24;
    --bg-3: #1a102f;

    --accent-green: #2ecc71;
    --accent-green-dark: #27ae60;
    --accent-blue: #3498db;
    --accent-blue-dark: #2587c7;

    --text-main: #243244;
    --text-muted: #7c8da1;
    --line: #dce6f2;

    --white-card: rgba(255, 255, 255, .965);
    --glass-card: rgba(255, 255, 255, .075);
    --glass-border: rgba(255, 255, 255, .13);

    --radius-lg: 22px;
    --radius-sm: 11px;

    --shadow-main: 0 22px 60px rgba(0, 0, 0, .52);

    /* จุดปรับหลัก */
    --auth-card-height: 680px;
    --auth-hero-width: 505px;
    --auth-form-width: 455px;
    --auth-gap: 24px;
    --auth-card-padding-y: 32px;
    --auth-card-padding-x: 34px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Sarabun" !important;
}

html,
body {
    min-height: 100%;
}

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

button {
    border: 0;
    cursor: pointer;
}

a {
    color: inherit;
}

/* =========================
   Auth Background
   ========================= */
body.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
    position: relative;
    overflow: hidden;
}

body.auth-page::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(74, 144, 226, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 144, 226, .045) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center;
    z-index: 1;
    pointer-events: none;
}

body.auth-page::after {
    content: "";
    position: fixed;
    width: 520px;
    height: 520px;
    background: radial-gradient(circle, rgba(52, 152, 219, .10) 0%, transparent 70%);
    top: -12%;
    left: -10%;
    z-index: 2;
    pointer-events: none;
}

.auth-ambient {
    position: fixed;
    right: -180px;
    bottom: -210px;
    width: 590px;
    height: 590px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(46, 204, 113, .09), transparent 68%);
    z-index: 2;
    pointer-events: none;
    filter: blur(2px);
}

/* =========================
   Layout
   ========================= */
.auth-layout {
    width: min(100%, calc(var(--auth-hero-width) + var(--auth-form-width) + var(--auth-gap)));
    display: grid;
    grid-template-columns: minmax(0, var(--auth-hero-width)) minmax(0, var(--auth-form-width));
    gap: var(--auth-gap);
    align-items: stretch;
    position: relative;
    z-index: 5;
}

/* =========================
   Left Hero
   ========================= */
.hero-panel {
    height: var(--auth-card-height);
    border-radius: var(--radius-lg);
    background: var(--glass-card);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-main);
    backdrop-filter: blur(16px);
    padding: 34px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.hero-brand {
    display: flex;
    gap: 14px;
    align-items: center;
}

.hero-logo {
    width: 52px;
    height: 52px;
    border-radius: 17px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 1.25rem;
    box-shadow: 0 12px 30px rgba(52, 152, 219, .25);
    flex: 0 0 auto;
}

.hero-brand h1 {
    font-size: 1.08rem;
    line-height: 1.18;
    color: #ffffff;
}

.hero-brand small {
    display: block;
    margin-top: 2px;
    color: rgba(255, 255, 255, .64);
    font-size: .85rem;
}

.hero-title {
    margin-top: 52px;
}

.hero-title h2 {
    font-size: clamp(2rem, 3.05vw, 3.05rem);
    line-height: 1.32;
    letter-spacing: 0.005em;
    font-weight: 800;
    max-width: 430px;
    color: #ffffff;
}

.hero-title p {
    margin-top: 24px;
    color: rgba(255, 255, 255, .72);
    line-height: 1.85;
    font-size: .96rem;
    max-width: 430px;
}

.feature-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.feature-card {
    min-height: 92px;
    border-radius: 16px;
    background: rgba(255, 255, 255, .075);
    border: 1px solid rgba(255, 255, 255, .12);
    padding: 12px;
}

.feature-card strong {
    display: block;
    font-size: .9rem;
    margin-bottom: 5px;
    color: #ffffff;
}

.feature-card span {
    display: block;
    color: rgba(255, 255, 255, .62);
    font-size: .78rem;
    line-height: 1.45;
}

/* =========================
   Right Auth Card
   ========================= */
.auth-card-wrapper {
    height: var(--auth-card-height);
    position: relative;
    padding: 2px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-main);
    display: flex;
}

.auth-card-wrapper::before {
    content: "";
    position: absolute;
    top: -55%;
    left: -55%;
    width: 210%;
    height: 210%;
    background: conic-gradient(
        transparent,
        rgba(46, 204, 113, .08),
        var(--accent-green) 24%,
        transparent 48%,
        rgba(52, 152, 219, .08),
        var(--accent-blue) 74%,
        transparent 100%
    );
    animation: rotateBorderLight 5s linear infinite;
}

.auth-container {
    position: relative;
    z-index: 3;
    flex: 1;
    width: 100%;
    height: 100%;
    border-radius: 18px;
    background: var(--white-card);
    color: var(--text-main);
    padding: var(--auth-card-padding-y) var(--auth-card-padding-x);
    display: flex;
    flex-direction: column;
}

/* ด้านบนทุกหน้าเริ่มเหมือนกัน */
.auth-header {
    text-align: center;
    margin-bottom: 18px;
    flex: 0 0 auto;
}

.auth-header h2 {
    font-size: 1.65rem;
    line-height: 1.2;
    margin-bottom: 6px;
    font-weight: 800;
    color: var(--text-main);
}

.auth-header p {
    color: var(--text-muted);
    font-size: .92rem;
}

.auth-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: #f1f5f9;
    padding: 5px;
    border-radius: 13px;
    margin-bottom: 18px;
    flex: 0 0 auto;
}

.auth-switch a,
.auth-switch span {
    display: block;
    text-align: center;
    text-decoration: none;
    border-radius: 10px;
    padding: 9px 10px;
    color: #64748b;
    font-weight: 800;
    font-size: .88rem;
}

.auth-switch .active {
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .16);
}

/* หน้า Login: ปุ่มที่เลือกเป็นสีเขียว */
.auth-container:not(.register-mode) .auth-switch .active {
    background: var(--accent-green);
}

/* หน้า Register: ปุ่มที่เลือกเป็นสีฟ้า */
.auth-container.register-mode .auth-switch .active {
    background: var(--accent-blue);
}

/* ปุ่มที่ไม่ได้เลือก */
.auth-switch a,
.auth-switch span {
    color: #64748b;
}

.auth-switch a:not(.active):hover {
    color: var(--text-main);
}

/* =========================
   Forms
   ========================= */
.auth-form {
    flex: 0 0 auto;
    width: 100%;
}

.form-group {
    margin-bottom: 14px;
}

.auth-container.register-mode .form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #334155;
    font-weight: 700;
    font-size: .88rem;
}

.form-control {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    outline: none;
    background: #ffffff;
    color: var(--text-main);
    font-size: .96rem;
    transition: .18s ease;
}

.form-control:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, .11);
}

.btn-submit {
    width: 100%;
    display: block;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--accent-green);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 800;
    margin-top: 4px;
    transition: .18s ease;
}

.btn-submit:hover {
    background: var(--accent-green-dark);
    box-shadow: 0 8px 18px rgba(46, 204, 113, .34);
    transform: translateY(-1px);
}

.btn-submit.btn-register {
    background: var(--accent-blue);
}

.btn-submit.btn-register:hover {
    background: var(--accent-blue-dark);
    box-shadow: 0 8px 18px rgba(52, 152, 219, .30);
}

/* =========================
   Alerts / Footer / Note
   ========================= */
.alert-error,
.alert-success,
.alert-warning {
    padding: 11px 12px;
    border-radius: 12px;
    font-size: .86rem;
    line-height: 1.45;
    margin-bottom: 14px;
    font-weight: 600;
    flex: 0 0 auto;
}

.alert-error {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

/* ตัวดันระยะ: ดัน footer+note ลงล่าง แต่ไม่ให้ note ชิดขอบ */
.auth-spacer {
    flex: 1 1 auto;
    min-height: 20px;
}

.auth-footer-links {
    text-align: center;
    font-size: .86rem;
    color: #566579;
    line-height: 1.5;
    flex: 0 0 auto;
}

.auth-footer-links a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 800;
}

.auth-footer-links a:hover {
    text-decoration: underline;
}

.system-note {
    margin-top: 16px;
    padding: 11px 12px;
    border-radius: 12px;
    background: #ecfeff;
    border: 1px solid #a5f3fc;
    color: #155e75;
    font-size: .82rem;
    line-height: 1.45;
    flex: 0 0 auto;
}

/* =========================
   Animation / Responsive
   ========================= */
@keyframes rotateBorderLight {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-height: 760px) and (min-width: 921px) {
    body.auth-page {
        overflow-y: auto;
        align-items: start;
    }

    .auth-layout {
        margin-top: 20px;
        margin-bottom: 20px;
    }
}

@media (max-width: 920px) {
    body.auth-page {
        align-items: start;
        overflow-y: auto;
    }

    .auth-layout {
        grid-template-columns: 1fr;
        width: min(100%, 520px);
    }

    .hero-panel {
        height: auto;
        min-height: auto;
        padding: 24px;
    }

    .hero-title {
        margin-top: 24px;
    }

    .hero-title h2 {
        font-size: 2.05rem;
    }

    .feature-row {
        margin-top: 26px;
    }

    .auth-card-wrapper {
        height: auto;
        min-height: auto;
    }

    .auth-container {
        min-height: auto;
        padding: 30px;
    }

    .auth-spacer {
        display: none;
    }

    .auth-footer-links {
        margin-top: 18px;
    }
}

@media (max-width: 540px) {
    body.auth-page {
        padding: 14px;
    }

    .hero-panel {
        display: none;
    }

    .auth-container {
        padding: 24px;
    }

    .auth-header h2 {
        font-size: 1.42rem;
    }
}

.hero-logo img,
.home-logo img {
    width: 68%;
    height: 68%;
    object-fit: contain;
    display: block;
}


/* =========================================================
   Matrix Board / Popup / Drag Drop
   Version: Matrix Board Integrated v12
   Path: /public_html/assets/app.css

   หลัก:
   - ใช้ร่วมกับ Auth CSS เดิม
   - CSS ของหน้า Matrix อยู่ในไฟล์นี้เท่านั้น
   - JavaScript อยู่ที่ /assets/script.js
   ========================================================= */

.hidden {
    display: none !important;
}

.svg-icon {
    width: 1em;
    height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

body.matrix-app-page {
    min-height: 100vh;
    padding: 16px;
    color: #d1d5db;
    background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
    position: relative;
    overflow-x: hidden;
}

body.matrix-app-page::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(74, 144, 226, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 144, 226, .045) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center;
    z-index: 0;
    pointer-events: none;
}

body.matrix-app-page::after {
    content: "";
    position: fixed;
    right: -180px;
    bottom: -210px;
    width: 590px;
    height: 590px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(46, 204, 113, .09), transparent 68%);
    z-index: 0;
    pointer-events: none;
    filter: blur(2px);
}

.matrix-shell {
    width: min(100%, 1600px);
    min-height: calc(100vh - 32px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    z-index: 2;
}

.system-panel-bg,
.matrix-header,
.matrix-footer,
.matrix-quadrant {
    background: rgba(23, 29, 38, .78);
    border: 1px solid rgba(255, 255, 255, .10);
    box-shadow: 0 16px 38px rgba(0, 0, 0, .30);
    backdrop-filter: blur(18px);
}

.matrix-header {
    border-radius: 22px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.matrix-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.matrix-logo-box {
    width: 42px;
    height: 42px;
    border-radius: 15px;
    background: linear-gradient(135deg, #4f46e5, #2ecc71);
    display: grid;
    place-items: center;
    box-shadow: 0 10px 26px rgba(79, 70, 229, .30);
    flex: 0 0 auto;
}

.matrix-logo-icon {
    display: grid;
    grid-template-columns: repeat(2, 8px);
    grid-template-rows: repeat(2, 8px);
    gap: 3px;
}

.matrix-logo-icon span {
    display: block;
    border-radius: 2px;
    background: #ffffff;
}

.matrix-title {
    min-width: 0;
}

.matrix-title h1 {
    font-size: 1.08rem;
    line-height: 1.35;
    color: #ffffff;
    font-weight: 800;
    letter-spacing: .01em;
}

.matrix-title p {
    margin-top: 2px;
    color: #94a3b8;
    font-size: .78rem;
    line-height: 1.45;
}

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

.matrix-btn {
    min-height: 38px;
    border-radius: 13px;
    padding: 0 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-size: .78rem;
    font-weight: 800;
    transition: .16s ease;
    white-space: nowrap;
}

.matrix-btn-primary {
    background: #4f46e5;
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(79, 70, 229, .25);
}

.matrix-btn-primary:hover {
    background: #6366f1;
}

.matrix-btn-secondary {
    background: rgba(255, 255, 255, .08);
    color: #dbeafe;
    border: 1px solid rgba(255, 255, 255, .10);
}

.matrix-btn-secondary:hover {
    background: rgba(255, 255, 255, .13);
    color: #ffffff;
}

.matrix-btn-danger {
    background: rgba(239, 68, 68, .12);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, .20);
}

.matrix-btn-danger:hover {
    background: rgba(239, 68, 68, .22);
    color: #ffffff;
}

.user-pill {
    min-height: 38px;
    border-radius: 999px;
    padding: 0 13px 0 5px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .10);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #d1d5db;
    font-size: .78rem;
    font-weight: 800;
    white-space: nowrap;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5, #2ecc71);
    font-size: .78rem;
    font-weight: 900;
}

.matrix-board {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.matrix-quadrant {
    border-radius: 22px;
    padding: 18px;
    min-height: 390px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.quad-header {
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, .07);
    padding: 12px 14px;
    margin-bottom: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255, 255, 255, .035);
    flex: 0 0 auto;
}

.quad-name {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.quad-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    flex: 0 0 auto;
}

.quad-name h2 {
    color: #f8fafc;
    font-size: .86rem;
    line-height: 1.35;
    font-weight: 900;
}

.quad-name p {
    margin-top: 1px;
    color: #94a3b8;
    font-size: .68rem;
    line-height: 1.3;
}

.quad-count {
    color: #94a3b8;
    font-size: .70rem;
    font-weight: 900;
    white-space: nowrap;
}

.task-grid {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 10px;
    overflow-y: auto;
    max-height: 290px;
    padding: 2px 2px 4px 2px;
}

.task-grid::-webkit-scrollbar,
.modal-scroll::-webkit-scrollbar {
    width: 8px;
}

.task-grid::-webkit-scrollbar-thumb,
.modal-scroll::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(148, 163, 184, .30);
}

.task-card {
    min-height: 132px;
    border-radius: 15px;
    background: rgba(34, 42, 54, .90);
    border: 1px solid rgba(148, 163, 184, .20);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    box-shadow: 5px 7px 15px rgba(0, 0, 0, .18);
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.task-card:hover {
    background: rgba(40, 50, 66, .96);
    border-color: rgba(203, 213, 225, .30);
    box-shadow: 7px 9px 18px rgba(0, 0, 0, .24);
}

.card-red { border-color: rgba(248, 113, 113, .18); }
.card-blue { border-color: rgba(96, 165, 250, .18); }
.card-yellow { border-color: rgba(251, 191, 36, .18); }
.card-gray { border-color: rgba(148, 163, 184, .18); }

.task-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 9px;
}

.task-card h3 {
    color: #ffffff;
    font-size: .82rem;
    font-weight: 900;
    line-height: 1.38;
    min-width: 0;
}

.task-card p {
    color: #94a3b8;
    font-size: .70rem;
    line-height: 1.55;
}

.task-actions {
    display: inline-flex;
    gap: 6px;
    flex: 0 0 auto;
}

.icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    color: #94a3b8;
    background: rgba(255, 255, 255, .055);
    border: 1px solid rgba(255, 255, 255, .075);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: .16s ease;
}

.icon-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, .11);
}

.drag-handle {
    touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    cursor: grab !important;
}

.drag-handle:active {
    cursor: grabbing !important;
}

.task-meta {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-size: .66rem;
    font-weight: 800;
}

.status-pill {
    border-radius: 999px;
    padding: 3px 7px;
    font-size: .64rem;
    font-weight: 900;
    white-space: nowrap;
}

.status-todo {
    color: #cbd5e1;
    background: rgba(148, 163, 184, .12);
    border: 1px solid rgba(148, 163, 184, .20);
}

.status-doing {
    color: #fbbf24;
    background: rgba(245, 158, 11, .12);
    border: 1px solid rgba(245, 158, 11, .22);
}

.status-review {
    color: #c7d2fe;
    background: rgba(99, 102, 241, .14);
    border: 1px solid rgba(99, 102, 241, .25);
}

.status-done {
    color: #86efac;
    background: rgba(34, 197, 94, .12);
    border: 1px solid rgba(34, 197, 94, .22);
}

.add-inline-card {
    min-height: 132px;
    border-radius: 15px;
    border: 1px dashed rgba(148, 163, 184, .28);
    color: #94a3b8;
    background: rgba(17, 22, 34, .28);
    display: grid;
    place-items: center;
    text-align: center;
    font-size: .72rem;
    font-weight: 800;
    transition: .16s ease;
}

.add-inline-card:hover {
    color: #ffffff;
    border-color: rgba(129, 140, 248, .62);
    background: rgba(79, 70, 229, .13);
}

.quad-do .quad-dot { background: #ef4444; }
.quad-schedule .quad-dot { background: #3b82f6; }
.quad-delegate .quad-dot { background: #f59e0b; }
.quad-eliminate .quad-dot { background: #94a3b8; }

.matrix-footer {
    min-height: 44px;
    border-radius: 18px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    font-size: .70rem;
    color: rgba(209, 213, 219, .78);
    font-weight: 800;
    letter-spacing: .02em;
}

/* =========================
   Modal
   ========================= */

.matrix-modal {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(0, 0, 0, .70);
    backdrop-filter: blur(7px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}

.matrix-modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: min(100%, 720px);
    max-height: 90vh;
    border-radius: 22px;
    background: #171d26;
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .58);
    overflow: hidden;
    transform: scale(.97);
    transition: transform .18s ease;
    display: flex;
    flex-direction: column;
}

.matrix-modal.show .modal-card {
    transform: scale(1);
}

.add-modal-card {
    width: min(100%, 600px);
    height: min(86vh, 820px);
}

.view-modal-card {
    width: min(100%, 740px);
    height: min(90vh, 880px);
}

.modal-header,
.modal-footer {
    flex: 0 0 auto;
    padding: 16px 22px;
    border-color: rgba(255, 255, 255, .09);
}

.modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, .09);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.modal-header h3 {
    color: #f8fafc;
    font-size: .90rem;
    font-weight: 900;
}

.modal-footer {
    border-top: 1px solid rgba(255, 255, 255, .09);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 22px;
}

.form-stack {
    display: grid;
    gap: 15px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field-label {
    display: block;
    color: #94a3b8;
    font-size: .70rem;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: 7px;
}

.matrix-input,
.matrix-select,
.matrix-textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid rgba(55, 65, 81, .95);
    background: #222a36;
    color: #f8fafc;
    outline: none;
    padding: 10px 11px;
    font-size: .78rem;
    transition: .16s ease;
}

.matrix-input:focus,
.matrix-select:focus,
.matrix-textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .14);
}

.matrix-input[readonly] {
    color: #94a3b8;
    background: rgba(34, 42, 54, .58);
}

.task-type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.task-type-option {
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, .25);
    background: #222a36;
    color: #d1d5db;
    font-size: .76rem;
    font-weight: 900;
    transition: .16s ease;
}

.task-type-option:hover {
    border-color: rgba(99, 102, 241, .55);
    background: #273247;
}

.task-type-option.active {
    background: rgba(79, 70, 229, .34);
    border-color: rgba(99, 102, 241, .85);
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, .35);
}

.routine-days-panel {
    transition: opacity .16s ease, filter .16s ease;
}

.routine-days-panel.disabled {
    opacity: .32;
    filter: grayscale(1);
    pointer-events: none;
}

.routine-day-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.routine-day-btn {
    min-height: 34px;
    border-radius: 10px;
    background: #374151;
    color: #cbd5e1;
    font-size: .70rem;
    font-weight: 900;
    border: 1px solid rgba(255, 255, 255, .06);
}

.routine-day-btn.active {
    background: #4f46e5;
    color: #ffffff;
    border-color: rgba(129, 140, 248, .85);
    box-shadow: 0 8px 18px rgba(79, 70, 229, .26);
}

.timeline-calendar,
.quick-calendar {
    border-radius: 10px;
    border: 1px solid rgba(55, 65, 81, .95);
    background: #222a36;
    padding: 12px;
}

.calendar-top,
.quick-calendar-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.calendar-title {
    color: #e5e7eb;
    font-size: .76rem;
    font-weight: 900;
}

.calendar-summary {
    color: #94a3b8;
    font-size: .68rem;
    line-height: 1.45;
    margin-top: 2px;
}

.calendar-controls,
.quick-calendar-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.calendar-select,
.calendar-year {
    min-height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(55, 65, 81, .95);
    background: rgba(17, 22, 34, .72);
    color: #e5e7eb;
    padding: 0 9px;
    font-size: .70rem;
    font-weight: 900;
    outline: none;
}

.calendar-year {
    width: 78px;
}

.calendar-grid,
.quick-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    user-select: none;
}

.calendar-head,
.quick-calendar-head {
    text-align: center;
    color: #64748b;
    font-size: .64rem;
    font-weight: 900;
    padding-bottom: 2px;
}

.cal-day,
.quick-cal-day {
    min-height: 31px;
    border-radius: 999px;
    background: transparent;
    color: #cbd5e1;
    font-size: .70rem;
    font-weight: 900;
    border: 1px solid transparent;
    transition: .12s ease;
}

.cal-day:hover,
.quick-cal-day:hover {
    border-color: rgba(129, 140, 248, .45);
    background: rgba(99, 102, 241, .10);
}

.cal-day.in-range,
.quick-cal-day.in-range {
    border-radius: 8px;
    background: rgba(79, 70, 229, .26);
    color: #ffffff;
}

.cal-day.range-start,
.cal-day.range-end,
.quick-cal-day.range-start,
.quick-cal-day.range-end {
    background: #4f46e5;
    color: #ffffff;
    border-color: rgba(199, 210, 254, .55);
    box-shadow: 0 8px 18px rgba(79, 70, 229, .28);
}

.cal-day.is-empty,
.quick-cal-day.is-empty {
    pointer-events: none;
    opacity: 0;
}

.timeline-output,
.quick-timeline-output {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr 92px;
    gap: 8px;
}

.mini-readonly,
.quick-mini-readonly {
    border-radius: 10px;
    border: 1px solid rgba(55, 65, 81, .95);
    background: rgba(17, 22, 34, .48);
    padding: 8px 10px;
    color: #d1d5db;
    font-size: .70rem;
}

.mini-readonly span,
.quick-mini-readonly span {
    display: block;
    color: #64748b;
    font-size: .64rem;
    font-weight: 900;
    margin-bottom: 2px;
}

.subtask-table,
.quick-edit-subtask-zone {
    border-top: 1px solid rgba(55, 65, 81, .75);
    padding-top: 14px;
}

.subtask-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.link-btn {
    color: #a5b4fc;
    background: transparent;
    font-size: .72rem;
    font-weight: 900;
}

.link-btn:hover {
    color: #c7d2fe;
}

.subtask-label-row,
.subtask-input-row,
.quick-edit-subtask-head,
.quick-edit-subtask-row {
    display: grid;
    grid-template-columns: 1fr 160px 38px;
    gap: 8px;
}

.subtask-label-row,
.quick-edit-subtask-head {
    margin-bottom: 7px;
    color: #94a3b8;
    font-size: .70rem;
    font-weight: 900;
}

.subtask-input-row,
.quick-edit-subtask-row {
    align-items: center;
    margin-bottom: 8px;
}

.subtask-delete-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(239, 68, 68, .16);
    color: #fca5a5;
    display: grid;
    place-items: center;
    transition: .16s ease;
}

.subtask-delete-btn:hover {
    background: rgba(239, 68, 68, .28);
    color: #ffffff;
}

.modal-btn {
    min-width: 88px;
    min-height: 38px;
    border-radius: 13px;
    padding: 0 14px;
    font-size: .76rem;
    font-weight: 900;
    transition: .16s ease;
}

.modal-btn-cancel {
    background: #374151;
    color: #e5e7eb;
}

.modal-btn-cancel:hover {
    background: #4b5563;
}

.modal-btn-confirm {
    background: #4f46e5;
    color: #ffffff;
}

.modal-btn-confirm:hover {
    background: #6366f1;
}

.modal-btn-green {
    background: #16a34a;
    color: #ffffff;
}

.modal-btn-green:hover {
    background: #22c55e;
}

/* =========================
   Quick View / Edit
   ========================= */

.quick-mode-badge {
    border-radius: 8px;
    padding: 4px 8px;
    font-size: .68rem;
    font-weight: 900;
    border: 1px solid rgba(239, 68, 68, .25);
    background: rgba(239, 68, 68, .10);
    color: #fca5a5;
    white-space: nowrap;
}

.quick-action-list {
    display: inline-flex;
    gap: 8px;
}

.quick-action-icon {
    width: 31px;
    height: 31px;
    border-radius: 10px;
    color: #94a3b8;
    background: rgba(255, 255, 255, .045);
    border: 1px solid rgba(255, 255, 255, .075);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: .16s ease;
}

.quick-action-icon:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, .10);
}

.quick-action-icon.delete:hover {
    color: #fca5a5;
    background: rgba(239, 68, 68, .12);
    border-color: rgba(239, 68, 68, .28);
}

.quick-section-title {
    color: #94a3b8;
    font-size: .70rem;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.quick-info-box {
    border-radius: 14px;
    border: 1px solid rgba(55, 65, 81, .86);
    background: #222a36;
    padding: 12px;
}

.quick-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.quick-info-item {
    border-radius: 12px;
    background: rgba(17, 22, 34, .38);
    border: 1px solid rgba(255, 255, 255, .055);
    padding: 10px;
    font-size: .70rem;
}

.quick-info-item span {
    display: block;
    color: #64748b;
    font-weight: 900;
    margin-bottom: 3px;
}

.quick-view-title {
    color: #ffffff;
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.45;
}

.quick-view-desc {
    margin-top: 5px;
    color: #94a3b8;
    font-size: .78rem;
    line-height: 1.70;
}

.quick-status-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 9px;
}

.quick-status-btn {
    min-height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(55, 65, 81, .95);
    background: #222a36;
    color: #cbd5e1;
    font-size: .70rem;
    font-weight: 900;
    transition: .16s ease;
}

.quick-status-btn:not(:disabled):hover {
    border-color: rgba(129, 140, 248, .60);
    color: #ffffff;
    background: rgba(79, 70, 229, .20);
}

.quick-status-btn.current {
    border-color: rgba(245, 158, 11, .36);
    background: rgba(245, 158, 11, .12);
    color: #fbbf24;
}

.quick-status-btn.pending {
    border-color: rgba(99, 102, 241, .75);
    background: rgba(99, 102, 241, .20);
    color: #c7d2fe;
}

.quick-status-btn:disabled {
    opacity: .38;
    cursor: not-allowed;
    filter: grayscale(.6);
}

.quick-note {
    margin-top: 7px;
    color: #64748b;
    font-size: .66rem;
    line-height: 1.55;
}

.quick-subtask-list {
    display: grid;
    gap: 8px;
}

.quick-subtask-item {
    border-radius: 14px;
    border: 1px solid rgba(55, 65, 81, .86);
    background: #222a36;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 24px 1fr auto;
    gap: 9px;
    align-items: center;
    font-size: .76rem;
}

.quick-subtask-title {
    color: #e5e7eb;
    font-weight: 800;
    line-height: 1.45;
}

.quick-subtask-title.done {
    color: #64748b;
    text-decoration: line-through;
}

.quick-subtask-dates {
    color: #94a3b8;
    font-size: .70rem;
    line-height: 1.45;
    text-align: right;
    white-space: nowrap;
}

.quick-subtask-dates strong {
    color: #fbbf24;
}

.quick-subtask-dates .completed {
    color: #86efac;
}

.quick-edit-only {
    display: none;
}

#quickViewModal.edit-mode .quick-view-only {
    display: none !important;
}

#quickViewModal.edit-mode .quick-edit-only {
    display: block !important;
}

/* =========================
   Floating Drag
   ========================= */

.floating-drag-card {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 2147483647;
    width: min(320px, 86vw);
    min-height: 118px;
    pointer-events: none;
    border-radius: 15px;
    background: linear-gradient(135deg, rgba(32, 44, 66, .98), rgba(23, 32, 51, .98));
    border: 1px solid rgba(203, 213, 225, .42);
    box-shadow:
        0 34px 80px rgba(0, 0, 0, .72),
        0 0 0 1px rgba(255, 255, 255, .12),
        0 0 38px rgba(99, 102, 241, .22);
    padding: 13px 14px;
    color: #f8fafc;
    transform-origin: 28px 28px;
    will-change: transform;
}

.floating-drag-card::after {
    content: "กำลังย้ายงาน";
    position: absolute;
    right: 10px;
    bottom: -30px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .96);
    border: 1px solid rgba(129, 140, 248, .34);
    color: #c7d2fe;
    font-size: .64rem;
    font-weight: 900;
    white-space: nowrap;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .38);
}

.floating-drag-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
}

.floating-drag-title {
    min-width: 0;
    color: #ffffff;
    font-size: .78rem;
    font-weight: 900;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.floating-drag-move {
    width: 24px;
    height: 24px;
    border-radius: 9px;
    background: rgba(255, 255, 255, .10);
    border: 1px solid rgba(255, 255, 255, .14);
    color: #c7d2fe;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.floating-drag-desc {
    color: #94a3b8;
    font-size: .70rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 10px;
}

.floating-drag-meta {
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #64748b;
    font-size: .64rem;
    font-weight: 900;
}

.floating-drag-status {
    border-radius: 8px;
    padding: 3px 7px;
    color: #fbbf24;
    background: rgba(245, 158, 11, .12);
    border: 1px solid rgba(245, 158, 11, .25);
    white-space: nowrap;
}

.task-card.task-dragging {
    opacity: .18 !important;
    filter: grayscale(.45);
}

.drag-placeholder {
    min-height: 120px;
    border-radius: 15px;
    border: 1px dashed rgba(129, 140, 248, .75) !important;
    background: linear-gradient(135deg, rgba(79, 70, 229, .14), rgba(46, 204, 113, .07)) !important;
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, .16) !important;
}

.matrix-quadrant.drag-over {
    border-color: rgba(129, 140, 248, .82) !important;
    box-shadow:
        0 0 0 2px rgba(99, 102, 241, .30),
        0 18px 42px rgba(0, 0, 0, .36) !important;
}

.matrix-quadrant.drag-over .quad-header {
    background: rgba(79, 70, 229, .18) !important;
    border-color: rgba(129, 140, 248, .36) !important;
}

.matrix-quadrant.drag-over .quad-header::after {
    content: "ปล่อยเพื่อวางในช่องนี้";
    margin-left: 8px;
    color: #c7d2fe;
    font-size: .64rem;
    font-weight: 900;
    white-space: nowrap;
}

.auto-scroll-indicator {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99998;
    pointer-events: none;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .92);
    border: 1px solid rgba(129, 140, 248, .35);
    color: #c7d2fe;
    font-size: .70rem;
    font-weight: 900;
    opacity: 0;
    transition: opacity .12s ease;
}

.auto-scroll-indicator.show {
    opacity: 1;
}

.auto-scroll-indicator.top {
    top: 12px;
}

.auto-scroll-indicator.bottom {
    bottom: 12px;
}

body.is-task-dragging {
    cursor: grabbing;
    user-select: none;
    -webkit-user-select: none;
}

/* =========================
   Home old compatibility
   ========================= */

body.matrix-home-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
}

.home-shell {
    width: min(100%, 980px);
}

.home-card {
    border-radius: 22px;
    background: rgba(23, 29, 38, .78);
    border: 1px solid rgba(255, 255, 255, .10);
    box-shadow: var(--shadow-main);
    padding: 24px;
}

/* =========================
   Responsive
   ========================= */

@media (max-width: 1024px) {
    .matrix-board {
        grid-template-columns: 1fr;
    }

    .matrix-quadrant {
        min-height: 330px;
    }

    .task-grid {
        max-height: 320px;
    }
}

@media (max-width: 768px) {
    body.matrix-app-page {
        padding: 12px;
    }

    .matrix-shell {
        min-height: calc(100vh - 24px);
        gap: 12px;
    }

    .matrix-header {
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 18px 16px;
        flex-direction: column;
    }

    .matrix-brand {
        width: 100%;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }

    .matrix-actions {
        width: 100%;
        justify-content: center;
    }

    .matrix-title h1,
    .matrix-title p {
        text-align: center;
    }

    .task-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-height: 340px;
    }

    .matrix-footer {
        min-height: 48px;
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 3px;
    }

    .calendar-top,
    .quick-calendar-top {
        flex-direction: column;
    }

    .calendar-controls,
    .quick-calendar-controls {
        width: 100%;
        justify-content: stretch;
    }

    .calendar-select {
        flex: 1;
    }

    .calendar-year {
        width: 88px;
    }

    .matrix-quadrant.drag-over .quad-header::after {
        display: none;
    }

    .view-modal-card {
        height: 94svh;
        max-height: 94svh;
    }

    .add-modal-card {
        height: 92svh;
        max-height: 92svh;
    }
}

@media (max-width: 640px) {
    .task-grid {
        grid-template-columns: 1fr;
    }

    .form-row,
    .task-type-toggle,
    .timeline-output,
    .quick-timeline-output,
    .quick-info-grid,
    .quick-status-grid {
        grid-template-columns: 1fr;
    }

    .routine-day-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }

    .subtask-label-row,
    .quick-edit-subtask-head {
        display: none;
    }

    .subtask-input-row,
    .quick-edit-subtask-row {
        grid-template-columns: 1fr;
    }

    .subtask-delete-btn {
        width: 100%;
    }

    .quick-subtask-item {
        grid-template-columns: 24px 1fr;
    }

    .quick-subtask-dates {
        grid-column: 2;
        text-align: left;
        white-space: normal;
    }
}

@media (max-width: 420px) {
    .matrix-actions {
        flex-direction: column;
    }

    .matrix-btn,
    .user-pill {
        width: 100%;
    }

    .modal-header,
    .modal-footer,
    .modal-body {
        padding-left: 16px;
        padding-right: 16px;
    }
}


/* =========================================================
   V13 Notebook width fix: 1025px - 1200px
   - กันตัวหนังสือในการ์ดงานดัน layout
   - ใช้ร่วมกับ JS truncate เฉพาะช่วงหน้าจอนี้
   ========================================================= */
@media (min-width: 1025px) and (max-width: 1200px) {
    .task-card {
        min-height: 140px;
        overflow: hidden;
    }

    .task-card h3 {
        min-height: 2.45em;
        max-height: 2.45em;
        overflow: hidden;
    }

    .task-card p {
        min-height: 4.65em;
        max-height: 4.65em;
        overflow: hidden;
    }

    .task-meta {
        flex: 0 0 auto;
    }
}


/* =========================================================
   V15 Notebook card equal height: 1025px - 1200px
   - บังคับความสูงการ์ดงานและปุ่มเพิ่มงานให้เท่ากัน
   - แก้ปัญหาช่องที่มี 1 งานดูสูงกว่า / ช่องที่มี 2 งานดูเตี้ยกว่า
   ========================================================= */
@media (min-width: 1025px) and (max-width: 1200px) {
    .task-grid {
        grid-auto-rows: 156px;
        align-items: stretch;
    }

    .task-card,
    .add-inline-card {
        height: 156px;
        min-height: 156px;
        max-height: 156px;
    }

    .task-card h3 {
        min-height: auto;
        max-height: none;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .task-card p {
        min-height: auto;
        max-height: none;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .task-meta {
        margin-top: auto;
        min-height: 27px;
        align-items: center;
    }
}


/* =========================================================
   V18 Header Notification + Setting Menu
   ========================================================= */
.matrix-header-tool {
    position: relative;
    display: inline-flex;
}

.matrix-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 13px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .10);
    color: #dbeafe;
    display: inline-grid;
    place-items: center;
    transition: .16s ease;
    position: relative;
}

.matrix-icon-btn:hover {
    background: rgba(255, 255, 255, .13);
    color: #ffffff;
}

.matrix-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: .62rem;
    font-weight: 900;
    display: grid;
    place-items: center;
    border: 2px solid #161d27;
}

.matrix-mini-popup {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(380px, calc(100vw - 28px));
    border-radius: 18px;
    background: #111827;
    border: 1px solid rgba(129, 140, 248, .30);
    box-shadow:
        0 26px 70px rgba(0,0,0,.68),
        0 0 0 1px rgba(255,255,255,.06);
    padding: 12px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(-8px) scale(.98);
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
    text-align: left;
}

.matrix-mini-popup.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.matrix-mini-popup::before {
    content: "";
    position: absolute;
    top: -7px;
    right: 18px;
    width: 14px;
    height: 14px;
    background: #111827;
    border-left: 1px solid rgba(129, 140, 248, .30);
    border-top: 1px solid rgba(129, 140, 248, .30);
    transform: rotate(45deg);
}

.mini-popup-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 4px 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 10px;
}

.mini-popup-head strong {
    display: block;
    color: #ffffff;
    font-size: .82rem;
    font-weight: 900;
    line-height: 1.35;
}

.mini-popup-head span {
    display: block;
    margin-top: 2px;
    color: #94a3b8;
    font-size: .66rem;
    font-weight: 800;
    line-height: 1.45;
}

.mini-popup-list {
    display: grid;
    gap: 8px;
    max-height: 310px;
    overflow-y: auto;
    padding-right: 2px;
}

.mini-notify-item {
    border-radius: 14px;
    background: rgba(34, 42, 54, .86);
    border: 1px solid rgba(148,163,184,.16);
    padding: 10px;
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 10px;
}

.mini-notify-icon {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 900;
    color: #c7d2fe;
    background: rgba(99,102,241,.18);
    border: 1px solid rgba(99,102,241,.26);
}

.mini-notify-item.warn .mini-notify-icon {
    color: #fbbf24;
    background: rgba(245,158,11,.15);
    border-color: rgba(245,158,11,.25);
}

.mini-notify-item.danger .mini-notify-icon {
    color: #fca5a5;
    background: rgba(239,68,68,.14);
    border-color: rgba(239,68,68,.25);
}

.mini-notify-item.success .mini-notify-icon {
    color: #86efac;
    background: rgba(34,197,94,.14);
    border-color: rgba(34,197,94,.25);
}

.mini-notify-text strong {
    display: block;
    color: #ffffff;
    font-size: .74rem;
    line-height: 1.45;
    font-weight: 900;
}

.mini-notify-text p {
    margin-top: 3px;
    color: #94a3b8;
    font-size: .67rem;
    line-height: 1.55;
}

.mini-notify-text small {
    display: block;
    margin-top: 6px;
    color: #64748b;
    font-size: .62rem;
    font-weight: 800;
}

.mini-empty {
    padding: 18px 10px;
    text-align: center;
    color: #94a3b8;
    font-size: .72rem;
    font-weight: 800;
}

.matrix-setting-menu {
    width: min(330px, calc(100vw - 28px));
}

.setting-menu-item {
    width: 100%;
    border: 0;
    border-radius: 14px;
    background: transparent;
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px;
    color: #e5e7eb;
    text-align: left;
    transition: .16s ease;
}

.setting-menu-item:hover {
    background: rgba(255,255,255,.065);
}

.setting-menu-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: .72rem;
    font-weight: 900;
    color: #c7d2fe;
    background: rgba(99,102,241,.18);
    border: 1px solid rgba(99,102,241,.26);
}

.setting-menu-item strong {
    display: block;
    color: #ffffff;
    font-size: .75rem;
    line-height: 1.4;
    font-weight: 900;
}

.setting-menu-item small {
    display: block;
    margin-top: 2px;
    color: #94a3b8;
    font-size: .66rem;
    line-height: 1.4;
    font-weight: 800;
}

.setting-menu-item.danger .setting-menu-icon {
    color: #fca5a5;
    background: rgba(239,68,68,.14);
    border-color: rgba(239,68,68,.25);
}

.matrix-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 10000;
    max-width: min(360px, calc(100vw - 32px));
    border-radius: 15px;
    background: rgba(15,23,42,.96);
    border: 1px solid rgba(129,140,248,.28);
    box-shadow: 0 18px 42px rgba(0,0,0,.45);
    color: #e5e7eb;
    padding: 12px 14px;
    font-size: .76rem;
    font-weight: 800;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: .18s ease;
}

.matrix-toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .matrix-header-tool,
    .matrix-icon-btn {
        width: 100%;
    }

    .matrix-mini-popup {
        position: fixed;
        top: 96px;
        left: 14px;
        right: 14px;
        width: auto;
    }

    .matrix-mini-popup::before {
        display: none;
    }
}



/* =========================================================
   V19 Popup Fixed Layer Fix
   - แก้ Noti/Setting ถูก panel ด้านล่างทับ
   - เปลี่ยน popup จาก absolute ให้เป็น fixed และคำนวณตำแหน่งด้วย JS
   ========================================================= */
.matrix-header {
    position: relative;
    z-index: 3000;
}

.matrix-board,
.matrix-footer {
    position: relative;
    z-index: 1;
}

.matrix-mini-popup {
    position: fixed !important;
    top: 74px;
    right: auto;
    left: auto;
    z-index: 20000 !important;
    opacity: 0;
    transform: translateY(-8px) scale(.98);
    pointer-events: none;
}

.matrix-mini-popup.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.matrix-mini-popup::before {
    right: var(--popup-arrow-right, 18px) !important;
}

@media (max-width: 768px) {
    .matrix-mini-popup {
        position: fixed !important;
        top: var(--mobile-popup-top, 92px) !important;
        left: 14px !important;
        right: 14px !important;
        width: auto !important;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }

    .matrix-mini-popup::before {
        display: none !important;
    }
}


/* =========================================================
   V20 Active Popup Icon
   - เมื่อเปิด Noti/Setting ให้ icon เป็น active
   - พื้นหลัง icon active ใช้โทนเดียวกับ popup
   - เอาลูกศร popup ออก
   - popup จะถูกจัดกลางใต้ icon ด้วย JS
   ========================================================= */
.matrix-icon-btn.active {
    background: #111827;
    border-color: rgba(129, 140, 248, .30);
    color: #ffffff;
    box-shadow:
        0 16px 34px rgba(0,0,0,.40),
        0 0 0 1px rgba(255,255,255,.06);
}

.matrix-icon-btn.active::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 16px;
    border: 1px solid rgba(129, 140, 248, .24);
    pointer-events: none;
}

.matrix-mini-popup::before {
    display: none !important;
}

.matrix-mini-popup {
    border-top-color: rgba(129, 140, 248, .34);
}


/* =========================================================
   V21 Smart Center Popup
   - Popup พยายามอยู่กึ่งกลางใต้ icon
   - ถ้าล้นซ้าย/ขวา จะ clamp กลับเข้าจอ
   - เอาลูกศร popup ออก
   ========================================================= */
.matrix-mini-popup {
    width: min(360px, calc(100vw - 28px)) !important;
}

.matrix-mini-popup::before {
    display: none !important;
}

.matrix-icon-btn.active {
    background: #111827;
    border-color: rgba(129, 140, 248, .30);
    color: #ffffff;
    box-shadow:
        0 16px 34px rgba(0,0,0,.40),
        0 0 0 1px rgba(255,255,255,.06);
}

.matrix-icon-btn.active::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 16px;
    border: 1px solid rgba(129, 140, 248, .24);
    pointer-events: none;
}

@media (max-width: 768px) {
    .matrix-mini-popup {
        left: 14px !important;
        right: 14px !important;
        width: auto !important;
    }
}


/* =========================================================
   V22 FORCE Smart Center Popup
   ใช้ร่วมกับ toggleMatrixNotifySmartV22 / toggleMatrixSettingSmartV22
   ========================================================= */
body .matrix-mini-popup {
    position: fixed !important;
    right: auto !important;
    width: min(360px, calc(100vw - 28px)) !important;
    max-width: calc(100vw - 28px) !important;
    z-index: 50000 !important;
}

body .matrix-mini-popup::before {
    display: none !important;
}

body .matrix-icon-btn.active {
    background: #111827 !important;
    border-color: rgba(129, 140, 248, .30) !important;
    color: #ffffff !important;
    box-shadow:
        0 16px 34px rgba(0,0,0,.40),
        0 0 0 1px rgba(255,255,255,.06) !important;
}

body .matrix-icon-btn.active::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 16px;
    border: 1px solid rgba(129, 140, 248, .24);
    pointer-events: none;
}

@media (max-width: 768px) {
    body .matrix-mini-popup {
        left: 14px !important;
        right: 14px !important;
        width: auto !important;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
}


/* =========================================================
   V23 BODY-LEVEL Popup Fix
   สาเหตุเดิม: popup ยังอยู่ใน header/tool ทำให้ fixed positioning เพี้ยนจาก layout/ancestor
   รอบนี้ย้าย popup ออกมาไว้ระดับ body แล้วบังคับตำแหน่งแบบ viewport จริง
   ========================================================= */
body > #matrixNotifyPopup,
body > #matrixSettingMenu {
    position: fixed !important;
    right: auto !important;
    bottom: auto !important;
    width: min(360px, calc(100vw - 28px)) !important;
    max-width: calc(100vw - 28px) !important;
    z-index: 999999 !important;
}

body > #matrixNotifyPopup::before,
body > #matrixSettingMenu::before {
    display: none !important;
}

body > #matrixNotifyPopup.show,
body > #matrixSettingMenu.show {
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
}

body > #matrixNotifyPopup:not(.show),
body > #matrixSettingMenu:not(.show) {
    opacity: 0 !important;
    transform: translateY(-8px) scale(.98) !important;
    pointer-events: none !important;
}

@media (max-width: 768px) {
    body > #matrixNotifyPopup,
    body > #matrixSettingMenu {
        left: 14px !important;
        right: 14px !important;
        width: auto !important;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
}

/* =========================
   Auth Password Eye Toggle
   ========================= */
.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    width: 30px;
    height: 30px;
    transform: translateY(-50%);
    border-radius: 9px;
    border: 0;
    background: transparent;
    color: #98a6b8;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: .16s ease;
}

.password-toggle:hover {
    color: #2f4058;
    background: rgba(226, 234, 243, .92);
}

.password-toggle.active {
    color: #ffffff;
    background: var(--accent-blue);
    box-shadow: 0 8px 18px rgba(52, 152, 219, .25);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.password-toggle .icon-eye-off {
    display: none;
}

.password-toggle.active .icon-eye {
    display: none;
}

.password-toggle.active .icon-eye-off {
    display: block;
}

/* =========================
   Auth Password Eye Toggle
   ========================= */
.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    width: 30px;
    height: 30px;
    transform: translateY(-50%);
    border-radius: 9px;
    border: 0;
    background: transparent;
    color: #98a6b8;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: .16s ease;
}

.password-toggle:hover {
    color: #2f4058;
    background: rgba(226, 234, 243, .92);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.password-toggle .icon-eye-off {
    display: none;
}

.password-toggle.active .icon-eye {
    display: none;
}

.password-toggle.active .icon-eye-off {
    display: block;
}

/* หน้า Login: ดวงตา active เป็นสีเขียวเหมือนปุ่ม Login */
.auth-container:not(.register-mode) .password-toggle.active {
    color: #ffffff;
    background: var(--accent-green);
    box-shadow: 0 8px 18px rgba(46, 204, 113, .25);
}

/* หน้า Register: ดวงตา active เป็นสีฟ้าเหมือนปุ่ม Register */
.auth-container.register-mode .password-toggle.active {
    color: #ffffff;
    background: var(--accent-blue);
    box-shadow: 0 8px 18px rgba(52, 152, 219, .25);
}


/* =========================================================
   V1.0.1 Remember This Device
   - Checkbox หน้า Login
   ========================================================= */
.remember-row {
    margin: -2px 0 14px;
}

.remember-check {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #566579;
    font-size: .82rem;
    font-weight: 800;
    line-height: 1.45;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.remember-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.remember-box {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1px solid #cbd8e6;
    background: #ffffff;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    transition: .16s ease;
}

.remember-box::after {
    content: "";
    width: 8px;
    height: 5px;
    border-left: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    transform: rotate(-45deg) translateY(-1px);
    opacity: 0;
    transition: .16s ease;
}

.remember-check input:checked + .remember-box {
    background: var(--accent-green);
    border-color: var(--accent-green);
    box-shadow: 0 8px 18px rgba(46, 204, 113, .24);
}

.remember-check input:checked + .remember-box::after {
    opacity: 1;
}

.remember-check:hover .remember-text {
    color: var(--text-main);
}

.remember-check:hover .remember-box {
    border-color: var(--accent-green);
}

/* Login page: eye active green / Register page: eye active blue */
.auth-container:not(.register-mode) .password-toggle.active {
    color: #ffffff;
    background: var(--accent-green);
    box-shadow: 0 8px 18px rgba(46, 204, 113, .25);
}

.auth-container.register-mode .password-toggle.active {
    color: #ffffff;
    background: var(--accent-blue);
    box-shadow: 0 8px 18px rgba(52, 152, 219, .25);
}


/* =========================================================
   V1.0.1 Tablet Drag Fix
   - ป้องกัน Browser long-press menu ตอนลากงานบน Tablet
   - เน้นแก้เฉพาะพื้นที่การ์ดงาน/ปุ่มย้ายงาน ไม่ปิด interaction ทั้งหน้า
   ========================================================= */
.drag-handle,
.drag-handle *,
.task-card,
.task-card * {
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

/* ปิด browser gesture เฉพาะปุ่มลากงานเท่านั้น เพื่อไม่ให้กระทบการ scroll ในพื้นที่อื่น */
.drag-handle,
.drag-handle * {
    touch-action: none !important;
}

.task-card {
    -webkit-tap-highlight-color: transparent;
}


/* =========================================================
   V1.0.2 Subtask Progress on Task Card
   - แสดงงานย่อย 2/5 แถวเดียวกับ Timeline
   ========================================================= */
.task-meta-left {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.subtask-progress-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 20px;
    border-radius: 999px;
    padding: 3px 8px;
    color: #c7d2fe;
    background: rgba(99, 102, 241, .14);
    border: 1px solid rgba(99, 102, 241, .24);
    font-size: .64rem;
    font-weight: 900;
    white-space: nowrap;
}

.subtask-progress-pill.is-empty {
    color: #94a3b8;
    background: rgba(148, 163, 184, .10);
    border-color: rgba(148, 163, 184, .18);
}

.subtask-progress-pill.is-done {
    color: #86efac;
    background: rgba(34, 197, 94, .12);
    border-color: rgba(34, 197, 94, .22);
}

@media (max-width: 420px) {
    .task-meta-left {
        gap: 6px;
    }

    .subtask-progress-pill {
        padding-left: 7px;
        padding-right: 7px;
    }
}


/* =========================================================
   V1.0.2 Card Layout Fix
   - แก้ข้อความในการ์ดล้น/ซ้อนขอบเมื่อจอถูกบีบ
   - ใช้ line-clamp เป็นหลัก และให้ JS truncate เป็นตัวเสริม
   ========================================================= */

/* บังคับไม่ให้ content ภายในการ์ดดันเกินกรอบ */
.task-card {
    overflow: hidden !important;
}

/* หัวข้องาน: จำกัด 2 บรรทัด */
.task-card h3 {
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* รายละเอียดงาน: จำกัด 2 บรรทัด */
.task-card p {
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    min-height: 3.10em;
    max-height: 3.10em;
}

/* แถวล่าง: ซ้ายเป็น Timeline + งานย่อย / ขวาเป็น Status */
.task-meta {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: end !important;
    gap: 8px !important;
    min-height: 30px;
    overflow: hidden;
}

.task-meta-left {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px 8px;
    flex-wrap: wrap;
    line-height: 1.25;
    overflow: hidden;
}

.task-meta-left > span:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subtask-progress-pill {
    flex: 0 0 auto;
    max-width: 110px;
}

.status-pill {
    flex: 0 0 auto;
    align-self: end;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ช่วงจอกลาง: การ์ดแคบที่สุด เพราะ board 2 คอลัมน์ + task 2 คอลัมน์ */
@media (min-width: 1025px) and (max-width: 1280px) {
    .task-grid {
        grid-auto-rows: 168px !important;
        align-items: stretch !important;
    }

    .task-card,
    .add-inline-card {
        height: 168px !important;
        min-height: 168px !important;
        max-height: 168px !important;
    }

    .task-card h3 {
        min-height: 2.76em !important;
        max-height: 2.76em !important;
    }

    .task-card p {
        min-height: 3.10em !important;
        max-height: 3.10em !important;
    }

    .task-meta {
        margin-top: auto !important;
    }
}

/* ช่วงที่แคบกว่า notebook: ให้ meta ยืดหยุ่นขึ้น */
@media (max-width: 1024px) {
    .task-card {
        min-height: 148px;
    }

    .task-meta-left {
        gap: 5px 7px;
    }
}

/* มือถือเล็ก: ไม่ให้ status บีบ meta จนแตก */
@media (max-width: 420px) {
    .task-meta {
        grid-template-columns: 1fr !important;
        align-items: start !important;
    }

    .status-pill {
        justify-self: start;
    }

    .subtask-progress-pill {
        max-width: none;
    }
}


/* =========================================================
   V1.0.2 Mobile Card Meta Fix v02
   - iPhone / Mobile: ให้ Timeline + งานย่อย + Status อยู่แถวเดียวกัน
   - แก้การ์ดล่างถูกตัด/แหว่งจาก task-grid max-height บนมือถือ
   ========================================================= */

/* มือถือควรให้แต่ละ quadrant ขยายตามจำนวนการ์ด แล้ว scroll ที่หน้าเว็บหลักแทน */
@media (max-width: 768px) {
    .matrix-quadrant {
        overflow: visible !important;
    }

    .task-grid {
        max-height: none !important;
        overflow-y: visible !important;
    }
}

/* แก้ override เดิมที่เคยทำให้ status ลงบรรทัดใหม่ตอนจอเล็ก */
@media (max-width: 520px) {
    .task-card {
        min-height: 156px !important;
        height: auto !important;
        max-height: none !important;
    }

    .task-meta {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        align-items: center !important;
        gap: 6px !important;
        min-height: 26px !important;
        overflow: visible !important;
    }

    .task-meta-left {
        display: flex !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 6px !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    .task-meta-left > span:first-child {
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-size: .64rem !important;
    }

    .subtask-progress-pill {
        flex: 0 0 auto !important;
        max-width: none !important;
        padding: 2px 7px !important;
        min-height: 19px !important;
        font-size: .60rem !important;
        line-height: 1.1 !important;
    }

    .status-pill {
        justify-self: end !important;
        align-self: center !important;
        max-width: none !important;
        padding: 3px 8px !important;
        font-size: .60rem !important;
        line-height: 1.1 !important;
        white-space: nowrap !important;
    }

    .task-card p {
        min-height: 3.10em !important;
        max-height: 3.10em !important;
    }
}

/* จอเล็กมากค่อยยอมให้ status ลงบรรทัดใหม่ ไม่งั้นจะเบียดจนอ่านไม่ได้ */
@media (max-width: 340px) {
    .task-meta {
        grid-template-columns: 1fr !important;
        align-items: start !important;
    }

    .status-pill {
        justify-self: start !important;
    }
}




/* =========================================================
   V1.0.3 Function Noti
   - Notification แสดงรายการงานจริง
   - Highlight งานเฉพาะตัวที่ยังไม่ได้เปิดดู
   ========================================================= */

.task-card.task-notify-highlight {
    border-color: rgba(96, 165, 250, .85) !important;
    box-shadow:
        0 0 0 2px rgba(59, 130, 246, .28),
        0 0 34px rgba(59, 130, 246, .16),
        5px 7px 15px rgba(0, 0, 0, .18) !important;
    position: relative;
}

.task-card.task-notify-highlight::before {
    content: "งานแจ้งเตือน";
    position: absolute;
    top: -10px;
    left: 12px;
    z-index: 5;
    border-radius: 999px;
    padding: 2px 8px;
    background: #2563eb;
    color: #ffffff;
    font-size: .58rem;
    font-weight: 900;
    line-height: 1.25;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .28);
}

.task-card.task-notify-focus {
    animation: matrixNotifyPulse 1.15s ease-in-out 2;
}

@keyframes matrixNotifyPulse {
    0% {
        box-shadow:
            0 0 0 2px rgba(59, 130, 246, .28),
            0 0 34px rgba(59, 130, 246, .16);
    }
    50% {
        box-shadow:
            0 0 0 4px rgba(96, 165, 250, .42),
            0 0 52px rgba(96, 165, 250, .34);
    }
    100% {
        box-shadow:
            0 0 0 2px rgba(59, 130, 246, .28),
            0 0 34px rgba(59, 130, 246, .16);
    }
}

.noti-group {
    border-radius: 14px;
    background: rgba(34, 42, 54, .86);
    border: 1px solid rgba(148, 163, 184, .16);
    padding: 10px;
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 10px;
}

.noti-group-icon {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 900;
    color: #fbbf24;
    background: rgba(245, 158, 11, .15);
    border: 1px solid rgba(245, 158, 11, .25);
}

.noti-group-icon.overdue {
    color: #fca5a5;
    background: rgba(239, 68, 68, .14);
    border-color: rgba(239, 68, 68, .25);
}

.noti-group-main {
    min-width: 0;
}

.noti-group-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 3px;
}

.noti-group-title strong {
    display: block;
    color: #ffffff;
    font-size: .76rem;
    font-weight: 900;
    line-height: 1.35;
}

.noti-group-title small {
    color: #64748b;
    font-size: .62rem;
    font-weight: 900;
    white-space: nowrap;
}

.noti-group-desc {
    color: #94a3b8;
    font-size: .66rem;
    line-height: 1.45;
    font-weight: 700;
    margin-bottom: 8px;
}

.noti-task-list {
    display: grid;
    gap: 6px;
}

.noti-task-card {
    border-radius: 12px;
    background: #171f2d;
    border: 1px solid rgba(129, 140, 248, .26);
    padding: 8px 9px;
    display: grid;
    gap: 5px;
    position: relative;
}

.noti-task-card.is-highlight::before {
    content: "งานแจ้งเตือน";
    position: absolute;
    top: -8px;
    left: 10px;
    border-radius: 999px;
    background: #2563eb;
    color: #ffffff;
    font-size: .56rem;
    font-weight: 900;
    padding: 2px 7px;
}

.noti-task-card b {
    display: block;
    color: #dbeafe;
    font-size: .70rem;
    font-weight: 900;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.noti-task-card span {
    display: block;
    color: #94a3b8;
    font-size: .62rem;
    font-weight: 800;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.noti-task-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
}

.noti-task-btn {
    min-height: 27px;
    border-radius: 9px;
    padding: 0 9px;
    font-size: .64rem;
    font-weight: 900;
}

.noti-task-btn.primary {
    background: rgba(79, 70, 229, .28);
    color: #c7d2fe;
    border: 1px solid rgba(129, 140, 248, .38);
}

.noti-task-btn.soft {
    background: rgba(255, 255, 255, .06);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, .09);
}

.noti-popup-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding: 10px 4px 2px;
    margin-top: 10px;
}

.noti-popup-footer button {
    background: transparent;
    color: #a5b4fc;
    font-size: .68rem;
    font-weight: 900;
}

.noti-popup-footer span {
    color: #64748b;
    font-size: .62rem;
    font-weight: 800;
    text-align: right;
}

@media (max-width: 420px) {
    .noti-group {
        grid-template-columns: 1fr;
    }

    .noti-group-icon {
        display: none;
    }

    .noti-task-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}


/* =========================================================
   V1.0.3 Function Noti Fix v02
   - เพิ่มพื้นที่ให้ label "งานแจ้งเตือน" ไม่โดนการ์ดด้านบนทับ
   - คุม spacing ระหว่างการ์ดให้ยังดูสะอาด
   ========================================================= */

/* เพิ่มช่องว่างด้านบน task-grid ให้ label ที่อยู่เหนือการ์ดมีพื้นที่แสดง */
.task-grid {
    padding-top: 14px !important;
    row-gap: 18px !important;
}

/* เฉพาะการ์ดที่เป็นงานแจ้งเตือน เพิ่ม buffer บนเล็กน้อย */
.task-card.task-notify-highlight {
    margin-top: 4px !important;
    overflow: visible !important;
    z-index: 2;
}

/* ให้ label อยู่เหนือการ์ดเสมอ */
.task-card.task-notify-highlight::before {
    top: -12px !important;
    z-index: 8 !important;
    white-space: nowrap;
}

/* กัน label ถูก clip ใน mobile ด้วย */
@media (max-width: 768px) {
    .task-grid {
        padding-top: 16px !important;
        row-gap: 20px !important;
    }

    .task-card.task-notify-highlight {
        margin-top: 5px !important;
    }
}




/* =========================================================
   V1.0.3 Browser Notification Lite
   - ปุ่ม/สถานะ Browser Notification ใน Noti popup
   ========================================================= */
.browser-noti-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    border-radius: 9px;
    padding: 0 9px;
    background: rgba(79, 70, 229, .22);
    color: #c7d2fe;
    border: 1px solid rgba(129, 140, 248, .34);
    font-size: .64rem;
    font-weight: 900;
    white-space: nowrap;
}

.browser-noti-control:hover {
    background: rgba(79, 70, 229, .32);
    color: #ffffff;
}

.browser-noti-state {
    color: #64748b;
    font-size: .62rem;
    font-weight: 800;
    line-height: 1.35;
}

.browser-noti-state.ok {
    color: #86efac;
}

.browser-noti-state.warn {
    color: #fbbf24;
}

.browser-noti-state.danger {
    color: #fca5a5;
}


/* =========================================================
   V1.0.3 Function Noti Reopen Fix v03
   - คุมการเปิด/ปิด popup ด้วย class ไม่ใช้ inline display ค้าง
   ========================================================= */
#matrixNotifyPopup.hidden,
.noti-popup.hidden,
.notification-popup.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
}

#matrixNotifyPopup.show,
#matrixNotifyPopup.open,
#matrixNotifyPopup.active,
.noti-popup.show,
.noti-popup.open,
.noti-popup.active,
.notification-popup.show,
.notification-popup.open,
.notification-popup.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

#matrixNotifyPopup,
.noti-popup,
.notification-popup {
    transition: opacity .16s ease, transform .16s ease;
}


/* =========================================================
   V1.0.3 Function Noti Reopen Fix v04
   Safety: ถ้า #matrixNotifyPopup มีทั้ง hidden และ show ให้ show ชนะ
   ========================================================= */
#matrixNotifyPopup.show.hidden {
    display: block !important;
}


/* =========================================================
   Matrix V1.0.4 Routine Live v01
   - แยก UI งานทั่วไป / งานประจำ Routine ใน popup เดิม
   ========================================================= */

#routineDaysPanel {
    display: none !important;
}

.matrix-normal-only,
.matrix-routine-only {
    display: none;
}

.matrix-normal-only.active,
.matrix-routine-only.active {
    display: grid;
    gap: 15px;
}

.matrix-routine-builder {
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.08);
    background: rgba(17,22,34,.36);
    padding: 13px;
    display: grid;
    gap: 13px;
}

.routine-tabs-v104 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.routine-tab-v104,
.remind-btn-v104,
.month-day-btn-v104 {
    min-height: 36px;
    border-radius: 10px;
    background: #374151;
    color: #cbd5e1;
    font-size: .70rem;
    font-weight: 900;
    border: 1px solid rgba(255,255,255,.06);
    transition: .16s ease;
}

.routine-tab-v104:hover,
.remind-btn-v104:hover,
.month-day-btn-v104:hover {
    color: #ffffff;
    background: #424f63;
}

.routine-tab-v104.active,
.remind-btn-v104.active,
.month-day-btn-v104.active {
    background: #4f46e5;
    color: #ffffff;
    border-color: rgba(129,140,248,.85);
    box-shadow: 0 8px 18px rgba(79,70,229,.26);
}

.routine-config-v104 {
    display: none;
    gap: 13px;
}

.routine-config-v104.active {
    display: grid;
}

.month-day-grid-v104 {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 6px;
}

.month-day-btn-v104 {
    min-height: 32px;
    padding: 0 4px;
}

.month-day-btn-v104.last {
    grid-column: span 2;
}

.remind-grid-v104 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
}

.routine-preview-v104 {
    border-radius: 12px;
    border: 1px solid rgba(245,158,11,.22);
    background: rgba(245,158,11,.08);
    padding: 11px 12px;
    color: #f8fafc;
    font-size: .72rem;
    line-height: 1.55;
}

.routine-preview-v104 strong {
    color: #fde68a;
}

.routine-help-v104 {
    color: #64748b;
    font-size: .68rem;
    line-height: 1.45;
    margin-top: 6px;
}

.task-card .routine-card-pill {
    border-radius: 999px;
    padding: 3px 7px;
    font-size: .62rem;
    font-weight: 900;
    white-space: nowrap;
    color: #c7d2fe;
    background: rgba(99,102,241,.14);
    border: 1px solid rgba(99,102,241,.25);
}

@media (max-width: 900px) {
    .routine-tabs-v104,
    .remind-grid-v104 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .month-day-grid-v104 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 540px) {
    .routine-tabs-v104,
    .remind-grid-v104 {
        grid-template-columns: 1fr;
    }

    .month-day-grid-v104 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}



/* =========================================================
   Matrix V1.0.4 Routine Detail/Edit Fix v02
   - Quick View แยก Normal / Routine
   ========================================================= */
.quick-routine-panel-v104 {
    border-radius: 15px;
    border: 1px solid rgba(255,255,255,.09);
    background: rgba(17,22,34,.42);
    padding: 14px;
    margin: 12px 0;
    display: grid;
    gap: 12px;
}

.quick-routine-summary-v104 {
    border-radius: 12px;
    border: 1px solid rgba(245,158,11,.22);
    background: rgba(245,158,11,.08);
    color: #f8fafc;
    padding: 12px 13px;
    font-size: .74rem;
    line-height: 1.65;
}

.quick-routine-summary-v104 strong { color: #fde68a; }

.quick-routine-lock-v104 {
    border-radius: 11px;
    border: 1px solid rgba(96,165,250,.20);
    background: rgba(59,130,246,.08);
    color: #bfdbfe;
    padding: 10px 12px;
    font-size: .70rem;
    line-height: 1.5;
    font-weight: 800;
}

.quick-routine-edit-v104 { display: grid; gap: 13px; }

.quick-normal-hidden-v104 { display: none !important; }

.quick-routine-edit-tabs-v104 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.quick-routine-edit-tab-v104,
.quick-routine-edit-remind-v104,
.quick-routine-edit-monthday-v104 {
    min-height: 34px;
    border-radius: 10px;
    background: #374151;
    color: #cbd5e1;
    font-size: .70rem;
    font-weight: 900;
    border: 1px solid rgba(255,255,255,.06);
    transition: .16s ease;
}

.quick-routine-edit-tab-v104.active,
.quick-routine-edit-remind-v104.active,
.quick-routine-edit-monthday-v104.active {
    background: #4f46e5;
    color: #ffffff;
    border-color: rgba(129,140,248,.85);
    box-shadow: 0 8px 18px rgba(79,70,229,.26);
}

.quick-routine-edit-config-v104 { display: none; gap: 13px; }
.quick-routine-edit-config-v104.active { display: grid; }

.quick-routine-edit-monthdays-v104 {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 6px;
}

.quick-routine-edit-monthday-v104 {
    min-height: 32px;
    padding: 0 4px;
}

.quick-routine-edit-monthday-v104.last { grid-column: span 2; }

.quick-routine-edit-reminds-v104 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
}

.quick-routine-type-pill-v104 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    color: #c7d2fe;
    background: rgba(99,102,241,.14);
    border: 1px solid rgba(99,102,241,.25);
    font-size: .66rem;
    font-weight: 900;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .quick-routine-edit-tabs-v104,
    .quick-routine-edit-reminds-v104 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .quick-routine-edit-monthdays-v104 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 540px) {
    .quick-routine-edit-tabs-v104,
    .quick-routine-edit-reminds-v104 { grid-template-columns: 1fr; }
    .quick-routine-edit-monthdays-v104 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
