/* =================================================================
   Lottery Syndicate — mobile-first stylesheet
   Small, hand-written. No framework, no reset dependency.
   ================================================================= */

:root {
    --c-bg:           #f4f6f5;
    --c-card:         #ffffff;
    --c-fg:           #1b2421;
    --c-muted:        #6b7670;
    --c-border:       #e3e7e4;

    --c-primary:      #0b7b5f;
    --c-primary-dk:   #075f49;
    --c-primary-ft:   #ffffff;

    --c-danger:       #b93b3b;
    --c-danger-bg:    #fde9e9;
    --c-warn:         #a76600;
    --c-warn-bg:      #fff1d6;
    --c-ok:           #0b7b5f;
    --c-ok-bg:        #ddf3eb;
    --c-info:         #1d4c8f;
    --c-info-bg:      #dbe7f7;

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 2px 10px rgba(0,0,0,.08);

    --tap: 44px;     /* iOS/HIG minimum tap target */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
    background: var(--c-bg);
    color: var(--c-fg);
    -webkit-text-size-adjust: 100%;
    min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: .85em; }
code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .9em; }

.muted { color: var(--c-muted); }
.small { font-size: .85em; }
.inline { display: inline; }

/* -------------------- Auth screens -------------------- */
body.auth, body.install {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.5rem 1rem;
    background:
        radial-gradient(900px 500px at 50% -10%, #e9f6f0 0%, transparent 60%),
        var(--c-bg);
}
.auth-wrap { width: 100%; max-width: 440px; }
.brand-block { text-align: center; margin-bottom: 1.5rem; }
.brand-dot {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 56px; height: 56px;
    background: var(--c-primary); color: #fff;
    border-radius: 16px;
    font: 700 28px/1 Georgia, serif;
    box-shadow: var(--shadow-md);
}
.brand-title { margin: .75rem 0 .25rem; font-size: 1.4rem; }
.brand-tag { color: var(--c-muted); margin: 0; }
.auth-card { padding: 1.25rem; }
.auth-heading { margin-top: 0; }
.auth-aux { margin-top: 1rem; text-align: center; }
.auth-footer { text-align: center; margin-top: 1rem; }
.install-card { max-width: 520px; }

/* -------------------- App chrome -------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    background: var(--c-primary);
    color: var(--c-primary-ft);
    padding-top: calc(.75rem + env(safe-area-inset-top));
    box-shadow: var(--shadow-sm);
}
.topbar .brand {
    display: flex; align-items: center; gap: .5rem;
    color: var(--c-primary-ft); font-weight: 600;
    flex: 1;
    min-width: 0;
}
.topbar .brand-title {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .brand-dot {
    width: 32px; height: 32px; font-size: 16px;
    border-radius: 8px;
    box-shadow: none;
    background: rgba(255,255,255,.2);
}
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.role-tag {
    background: rgba(255,255,255,.15);
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .8rem;
}
.menu-btn {
    width: var(--tap); height: var(--tap);
    display: inline-flex; flex-direction: column;
    justify-content: center; align-items: center; gap: 5px;
    background: rgba(255,255,255,.12);
    border: 0; border-radius: var(--r-sm);
    cursor: pointer;
}
.menu-btn span { display: block; width: 20px; height: 2px; background: #fff; border-radius: 2px; }

.sidebar {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 30;
    display: none;
    padding: 1rem;
}
.sidebar.is-open { display: block; }
.sidebar-head { background: #fff; padding: 1rem; border-radius: var(--r-md) var(--r-md) 0 0; }
.sidebar nav {
    background: #fff;
    border-radius: 0 0 var(--r-md) var(--r-md);
    overflow: hidden;
}
.sidebar nav a {
    display: block;
    padding: 1rem;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-fg);
    min-height: var(--tap);
}
.sidebar nav a:last-child { border-bottom: 0; }
.sidebar nav a.is-active { background: var(--c-ok-bg); color: var(--c-primary); font-weight: 600; }

.main {
    padding: 1rem 1rem 6rem;
    max-width: 920px;
    margin: 0 auto;
}

/* Bottom tab bar — the core mobile navigation */
.tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--c-border);
    display: flex;
    justify-content: space-around;
    z-index: 10;
    padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: .5rem .25rem;
    color: var(--c-muted);
    font-size: .75rem;
    min-height: var(--tap);
}
.tabbar a.is-active { color: var(--c-primary); font-weight: 600; }
.tabbar-icon { font-size: 1.2rem; line-height: 1; }

/* -------------------- Cards, heads, stacks -------------------- */
.card {
    background: var(--c-card);
    border-radius: var(--r-md);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.card-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: .5rem;
}
.card h2, section > h2 { margin: 0 0 .5rem; font-size: 1.1rem; }

.page-head {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin: .25rem 0 1rem;
}
.page-head h1 { margin: 0; font-size: 1.3rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.stack > * + * { margin-top: .9rem; }

/* -------------------- Forms -------------------- */
label {
    display: block;
    font-size: .9rem;
    color: var(--c-muted);
}
label > input:not([type="checkbox"]):not([type="radio"]),
label > select,
label > textarea {
    display: block;
    width: 100%;
    margin-top: .25rem;
    padding: .75rem;
    font-size: 1rem;
    color: var(--c-fg);
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    min-height: var(--tap);
    -webkit-appearance: none;
    appearance: none;
}
textarea { resize: vertical; min-height: 90px; }
label > input:focus, label > select:focus, label > textarea:focus {
    outline: 2px solid var(--c-primary);
    outline-offset: -1px;
}
label.check {
    display: flex; align-items: center; gap: .6rem;
    color: var(--c-fg);
    font-size: 1rem;
    padding: .25rem 0;
}
label.check input { width: 20px; height: 20px; }

.form-row {
    display: grid;
    gap: .75rem;
}
@media (min-width: 520px) {
    .form-row { grid-template-columns: 1fr 1fr; }
}
fieldset {
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: 1rem;
    margin: 0;
}
fieldset legend { padding: 0 .4rem; font-weight: 600; }

/* -------------------- Buttons -------------------- */
.btn {
    display: inline-flex;
    align-items: center; justify-content: center;
    min-height: var(--tap);
    padding: .6rem 1rem;
    font: 600 1rem/1 inherit;
    border-radius: var(--r-sm);
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary {
    background: var(--c-primary);
    color: var(--c-primary-ft);
}
.btn-primary:hover { background: var(--c-primary-dk); }
.btn-ghost {
    background: #fff;
    border-color: var(--c-border);
    color: var(--c-fg);
}
.btn-danger {
    background: var(--c-danger);
    color: #fff;
}
.btn-lg { font-size: 1.05rem; padding: .85rem 1.25rem; width: 100%; }
.btn-sm { font-size: .85rem; min-height: 36px; padding: .4rem .75rem; }

/* -------------------- Alerts + pills -------------------- */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--r-sm);
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-success { background: var(--c-ok-bg);    color: var(--c-ok);     border-color: #bfe6d6; }
.alert-error   { background: var(--c-danger-bg);color: var(--c-danger); border-color: #f0c8c8; }
.alert-info    { background: var(--c-info-bg);  color: var(--c-info);   border-color: #c5d8f2; }
.alert-warning { background: var(--c-warn-bg);  color: var(--c-warn);   border-color: #f4dfb4; }

.pill {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    background: #eee;
}
.pill-ok     { background: var(--c-ok-bg);     color: var(--c-ok); }
.pill-warn   { background: var(--c-warn-bg);   color: var(--c-warn); }
.pill-danger { background: var(--c-danger-bg); color: var(--c-danger); }
.pill-info   { background: var(--c-info-bg);   color: var(--c-info); }
.pill-muted  { background: #eceeec;            color: var(--c-muted); }

/* -------------------- Stats -------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
    margin-bottom: 1rem;
}
@media (min-width: 720px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
.stat-card {
    background: var(--c-card);
    border-radius: var(--r-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: .2rem;
    min-height: 88px;
}
.stat-label { font-size: .8rem; color: var(--c-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-value-sm { font-size: 1.05rem; font-weight: 600; }
.stat-money { background: var(--c-ok-bg); color: var(--c-ok); }
.stat-warn   { background: var(--c-warn-bg);  color: var(--c-warn); }
.stat-danger { background: var(--c-danger-bg);color: var(--c-danger); }
.stat-ok     { background: var(--c-ok-bg);    color: var(--c-ok); }
.stat-inline { max-width: 320px; }

.pinned-card {
    background: #fff6dd;
    border: 1px solid #efd989;
    border-radius: var(--r-md);
    padding: 1rem;
    margin-bottom: 1rem;
}
.pinned-card p { margin: .4rem 0 0; }

/* -------------------- List items (stacked cards) -------------------- */
.list-stack { display: flex; flex-direction: column; gap: .75rem; }
.list-item {
    background: var(--c-card);
    border-radius: var(--r-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: .5rem;
    color: inherit;
}
.list-item-link { display: flex; flex-direction: column; gap: .5rem; }
.list-item-link:hover { text-decoration: none; background: #fbfcfb; }
.list-item-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: .75rem;
}
.list-item-body {
    display: flex; flex-wrap: wrap; gap: .4rem .9rem;
    font-size: .95rem;
    color: var(--c-fg);
}
.list-item-foot {
    display: flex; flex-wrap: wrap; gap: .4rem;
    margin-top: .25rem;
}
.list-item-body .notes {
    flex-basis: 100%;
    font-size: .9rem;
    color: var(--c-muted);
    background: #f8f9f9;
    padding: .4rem .6rem;
    border-radius: var(--r-sm);
}
.line-clip {
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2;
    line-clamp: 2; -webkit-box-orient: vertical;
    color: var(--c-muted); font-size: .9rem; margin: .25rem 0 0;
}

/* -------------------- Filter bar -------------------- */
.filter-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    margin-bottom: 1rem;
}
.filter-bar input, .filter-bar select, .filter-bar button {
    width: 100%;
    min-height: var(--tap);
    padding: .55rem .75rem;
    font-size: 1rem;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
}
.filter-bar input[type="search"] { grid-column: 1 / -1; }
@media (min-width: 720px) {
    .filter-bar { grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; }
    .filter-bar input[type="search"] { grid-column: auto; }
}

/* -------------------- Stack list (simple rows) -------------------- */
.stack-list { list-style: none; padding: 0; margin: 0; }
.stack-list > li {
    display: flex; justify-content: space-between; align-items: center;
    padding: .6rem 0;
    border-bottom: 1px solid var(--c-border);
    gap: .75rem;
}
.stack-list > li:last-child { border-bottom: 0; }
.stack-list .row { display: flex; justify-content: space-between; width: 100%; gap: .75rem; }

/* -------------------- Numbers (lottery balls) -------------------- */
.numbers-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.numbers-list > li { display: flex; flex-direction: column; gap: .2rem; }
.balls { display: flex; gap: .35rem; flex-wrap: wrap; }
.ball {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--c-primary); color: #fff;
    font-weight: 700; font-size: .95rem;
}
.ball-bonus { background: var(--c-warn); }
.ball-sep { align-self: center; color: var(--c-muted); font-weight: bold; }

/* -------------------- Bank details / KV -------------------- */
.bank-details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; }
.bank-details dt { color: var(--c-muted); }
.bank-details dd { margin: 0; font-weight: 600; }
.kv { padding-left: 1rem; }
.kv li { margin-bottom: .25rem; }

/* -------------------- Thumbnails (ticket images) -------------------- */
.thumb-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .5rem;
}
@media (min-width: 520px) { .thumb-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 720px) { .thumb-grid { grid-template-columns: repeat(4, 1fr); } }
.thumb {
    background: #f8f9f9;
    border-radius: var(--r-sm);
    overflow: hidden;
    display: flex; flex-direction: column; gap: .25rem;
    padding-bottom: .35rem;
    text-align: center;
}
.thumb img { aspect-ratio: 1 / 1; object-fit: cover; width: 100%; }

/* -------------------- Messages -------------------- */
.message-body .prose { font-size: 1rem; color: var(--c-fg); }
.message-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.reply-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.reply {
    background: #f8fbf9;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: .75rem;
}
.reply-meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.reply-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--c-border); }

.repeater-row { border-bottom: 1px dashed var(--c-border); padding-bottom: .75rem; margin-bottom: .75rem; }
.repeater-row:last-child { border-bottom: 0; }

.empty-state {
    background: #fff;
    border: 1px dashed var(--c-border);
    border-radius: var(--r-md);
    padding: 2rem 1rem;
    text-align: center;
    color: var(--c-muted);
}
.link { color: var(--c-primary); font-weight: 600; font-size: .9rem; }

/* Desktop polish — sidebar becomes permanent, top bar keeps menu hidden */
@media (min-width: 960px) {
    .menu-btn { display: none; }
    .sidebar {
        display: block;
        position: fixed;
        top: 56px; bottom: 0; left: 0;
        width: 240px;
        background: transparent;
        padding: 1rem;
    }
    .sidebar-head, .sidebar nav { background: #fff; box-shadow: var(--shadow-sm); }
    .main { margin-left: 240px; max-width: none; padding: 1.5rem 2rem; }
    .tabbar { display: none; }
    .page-head {
        flex-direction: row; align-items: center; justify-content: space-between;
    }
    .page-head h1 { font-size: 1.6rem; }
    .btn-lg { width: auto; }
}
