:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --primary: #2f6fed;
    --primary-dark: #1e56c8;
    --danger: #d64545;
    --success: #2e9e5b;
    --border: #e2e5ea;
    --radius: 10px;
}

* { box-sizing: border-box; }

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

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

.topbar { background: var(--card); border-bottom: 1px solid var(--border); }
.topbar-inner {
    max-width: 1000px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.nav-links { display: flex; gap: 16px; }
.nav-links a { font-weight: 600; }
.nav-user { display: flex; align-items: center; gap: 8px; }

.page { max-width: 1000px; margin: 0 auto; padding: 20px 16px 48px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h3 { margin: 0; font-size: 16px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.inline { display: inline; }

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }
.alert-error { background: #fdeaea; color: #9c2222; border: 1px solid #f3c1c1; }
.alert-success { background: #e8f7ee; color: #1d6b3c; border: 1px solid #bfe6cd; }

/* Buttons */
.btn {
    display: inline-block; padding: 7px 14px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--card); color: var(--text);
    font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fdeaea; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-wide { width: 100%; }
.btn-link {
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: 12.5px; padding: 0; text-decoration: underline;
}
.btn-link:hover { color: var(--text); }

/* Auth screens */
.auth-box {
    max-width: 360px; margin: 8vh auto 0; background: var(--card);
    padding: 28px; border-radius: var(--radius); border: 1px solid var(--border);
}
.auth-box h1 { text-align: center; }
.pin-box { text-align: center; }
.pin-input {
    font-size: 26px; letter-spacing: 10px; text-align: center; width: 100%;
    padding: 10px; margin: 8px 0 16px; border: 1px solid var(--border); border-radius: 8px;
}

/* Fields */
.field { margin-bottom: 14px; flex: 1; min-width: 140px; }
.field label, .remove-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
}
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-box { max-width: 640px; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; }
.validation { color: var(--danger); font-size: 13px; }
.validation ul { margin: 6px 0; padding-left: 18px; }

/* Date navigation */
.date-nav {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; gap: 10px;
}
.date-title { text-align: center; display: flex; flex-direction: column; gap: 2px; }
.date-big { font-weight: 700; font-size: 17px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
}
.card-done { opacity: 0.75; }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.card-actions { margin-top: 10px; display: flex; gap: 8px; }
.desc { margin: 0; color: var(--muted); font-size: 13.5px; }
.badge {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    padding: 2px 8px; border-radius: 20px; background: #eef1f6; color: var(--muted); white-space: nowrap;
}
.badge-daily { background: #e7f0fe; color: #1e56c8; }
.badge-weekly { background: #e8f7ee; color: #1d6b3c; }
.badge-monthly { background: #fdeef7; color: #a3287e; }

.progress-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.progress-label { font-weight: 600; font-size: 13px; }
.pips { display: flex; gap: 4px; flex-wrap: wrap; }
.pip { width: 16px; height: 8px; border-radius: 4px; background: #e6e8ec; }
.pip-on { background: var(--success); }

/* Goal progress bars */
.bar {
    flex: 1; min-width: 90px; max-width: 220px; height: 10px;
    background: #e6e8ec; border-radius: 5px; overflow: hidden; align-self: center;
}
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 5px; }
.bar-fill.bar-complete { background: var(--success); }
.goal-preview .progress-row { margin-bottom: 3px; }

.subtask-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 10px; background: #f8f9fb; border-radius: 8px; font-size: 13px;
}
.subtask-name { font-weight: 600; }

.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.complete-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.file-input { font-size: 12px; max-width: 190px; }
.req-note { font-size: 11px; color: var(--danger); }
.text-danger { color: var(--danger); }
.done-note { color: var(--success); font-weight: 600; font-size: 13.5px; }
.done-note.not-done { color: var(--muted); font-weight: 400; }
.undo-form { margin-top: 2px; }

.empty { background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }
.rule-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.rule-list .card { padding: 14px 16px; }

/* Split button with dropdown menu (used in admin tables) */
.split { display: inline-flex; position: relative; vertical-align: top; }
.split .split-main { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split .split-caret {
    border-top-left-radius: 0; border-bottom-left-radius: 0;
    border-left: none; padding: 4px 8px; margin-left: -1px;
    list-style: none; user-select: none;
}
.split .split-caret::-webkit-details-marker { display: none; }
.split .split-caret::before { content: none; }
.menu[open] .split-caret { background: #e4e7ec; }
.menu-drop form { margin: 0; }
.menu-drop {
    position: absolute; right: 0; top: 100%; z-index: 20; min-width: 160px;
    margin-top: 4px; padding: 6px 0;
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}
.menu-drop a, .menu-drop button {
    display: block; width: 100%; padding: 7px 14px; border: none; background: none;
    text-align: left; font-size: 13.5px; font-family: inherit; color: var(--text);
    cursor: pointer; text-decoration: none; white-space: nowrap;
}
.menu-drop a:hover, .menu-drop button:hover { background: #f0f2f5; text-decoration: none; }
.menu-drop button.danger { color: var(--danger); }
.menu-drop button.danger:hover { background: #fdeaea; }
.menu-drop hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

/* Tables — separate borders (not collapse) so border-radius renders without overflow: hidden,
   which would clip the actions dropdown menu */
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: #f8f9fb; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.table th:first-child { border-top-left-radius: var(--radius); }
.table th:last-child { border-top-right-radius: var(--radius); }
.table tr:last-child td { border-bottom: none; }
.actions-cell { white-space: nowrap; }
.actions-cell form, .actions-cell .btn { margin: 2px 4px 2px 0; }
.quick-cell code { font-size: 12px; }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.page-head > div { display: flex; gap: 8px; }

/* Subtask editor */
.subtask-editor { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 14px; margin: 14px 0 0; }
.subtask-editor legend { font-weight: 700; font-size: 13px; padding: 0 6px; }
.subtask-edit-row {
    display: grid; grid-template-columns: 1.1fr 1.6fr 70px 130px auto;
    gap: 8px; align-items: center; margin-bottom: 8px;
}
.subtask-edit-row input, .subtask-edit-row select {
    padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; width: 100%;
}
.remove-label { display: flex; align-items: center; gap: 5px; font-weight: 400; font-size: 12.5px; white-space: nowrap; }
.remove-label input { width: auto; }

/* Outstanding goals/orders panel under the task list */
.outstanding { max-width: 720px; margin-top: 28px; display: flex; flex-direction: column; gap: 14px; }
.outstanding h2 { margin: 0; font-size: 1.1rem; }

/* Reward bound-condition repeatable dropdowns */
.condition-selects { display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.condition-select { width: 100%; }
