/* ==========================================================================
   BillEase Design System — 2. Base
   Reset, typography, focus handling and small layout utilities.
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-padding-top: calc(var(--topbar-h) + var(--sp-4));
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--app-background);
    color: var(--app-text);
    font-family: var(--app-font);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

img {
    height: auto;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    color: var(--app-text);
    line-height: var(--lh-tight);
    letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-title); font-weight: 800; }
h2 { font-size: var(--fs-section); font-weight: 700; }
h3 { font-size: var(--fs-card-title); font-weight: 700; }
h4 { font-size: var(--fs-body); font-weight: 700; }

p {
    margin: 0 0 var(--sp-3);
}

p:last-child {
    margin-bottom: 0;
}

small {
    font-size: var(--fs-support);
}

b,
strong {
    font-weight: 700;
}

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

a:hover {
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
    letter-spacing: normal;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

hr {
    border: 0;
    border-top: 1px solid var(--app-border);
    margin: var(--sp-4) 0;
}

code,
kbd,
.mono {
    font-family: var(--app-font-mono);
    font-size: 0.92em;
}

::selection {
    background: rgba(var(--app-primary-rgb), 0.18);
}

/* Focus: visible for keyboard users only */
:focus {
    outline: none;
}

:focus-visible {
    outline: 3px solid rgba(var(--app-primary-rgb), 0.45);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---- Utilities -------------------------------------------------------- */
.hidden,
[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

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

.subtle {
    color: var(--app-text-subtle);
}

.grow {
    flex: 1 1 auto;
    min-width: 0;
}

.align-right,
.text-right,
.num {
    text-align: right;
}

.num,
.tabular {
    font-variant-numeric: tabular-nums;
}

.nowrap {
    white-space: nowrap;
}

.ellipsis {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.text-success { color: var(--app-success); }
.text-warning { color: var(--app-warning); }
.text-error { color: var(--app-error); }
.text-info { color: var(--app-info); }
.text-primary { color: var(--app-primary); }

.stack { display: grid; gap: var(--sp-3); }
.stack-lg { display: grid; gap: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }

.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mb-0 { margin-bottom: 0 !important; }

@media print {
    .no-print {
        display: none !important;
    }
}
