@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --background: #fafafa;
    --foreground: #18181b;
    --card: #ffffff;
    --card-foreground: #18181b;
    --muted: #f4f4f5;
    --muted-foreground: #71717a;
    --border: #e4e4e7;
    --input: #e4e4e7;
    --ring: #2f6b3a;

    --primary: #2f6b3a;
    --primary-hover: #245530;
    --primary-foreground: #ffffff;
    --primary-soft: #eef5ef;

    --secondary: #f4f4f5;
    --secondary-foreground: #18181b;

    --destructive: #dc2626;
    --destructive-hover: #b91c1c;
    --destructive-foreground: #ffffff;
    --destructive-soft: #fef2f2;

    --warning: #9a6a17;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;

    --radius-lg: 0.75rem;
    --radius-md: 0.5rem;
    --radius-sm: 0.375rem;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);

    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

/* ---------- Top nav ---------- */

.app-header {
    background: var(--card);
    color: var(--foreground);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.6rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-header .brand {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    color: var(--primary);
}

.app-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.4rem;
    align-items: center;
}

.app-nav a {
    color: var(--muted-foreground);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 500;
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    transition: background-color 120ms ease, color 120ms ease;
}

.app-nav a:hover { color: var(--foreground); background: var(--muted); text-decoration: none; }
.app-nav a.active { color: var(--primary); background: var(--primary-soft); }

.app-nav span.muted {
    color: var(--muted-foreground) !important;
    font-size: 0.8rem;
    margin: 0 0.2rem;
}

.app-nav button {
    background: var(--card);
    color: var(--foreground);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
}
.app-nav button:hover { background: var(--muted); }

/* ---------- Layout ---------- */

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.2rem 3rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 0.9rem; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat { text-align: left; }
.stat .value { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; color: var(--foreground); }
.stat .label { color: var(--muted-foreground); font-size: 0.82rem; margin-top: 0.2rem; }

/* ---------- Forms ---------- */

label {
    display: block;
    margin: 0.75rem 0 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--foreground);
}
label:first-child { margin-top: 0; }

input, select, textarea {
    width: 100%;
    height: 2.35rem;
    padding: 0 0.75rem;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--card);
    color: var(--foreground);
    box-shadow: var(--shadow-sm);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

input::placeholder, textarea::placeholder { color: var(--muted-foreground); }

input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea { height: auto; min-height: 4.5rem; padding: 0.6rem 0.75rem; resize: vertical; }

/* ---------- Buttons ---------- */

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    height: 2.35rem;
    background: var(--primary);
    color: var(--primary-foreground);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 0 1.1rem;
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;
}
button:hover, .btn:hover { background: var(--primary-hover); text-decoration: none; }

button.secondary {
    background: var(--card);
    color: var(--foreground);
    border: 1px solid var(--border);
}
button.secondary:hover { background: var(--muted); }

button.danger { background: var(--destructive); color: var(--destructive-foreground); }
button.danger:hover { background: var(--destructive-hover); }

button:disabled { opacity: 0.5; cursor: not-allowed; }

select { appearance: auto; cursor: pointer; }

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 150px; }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
th, td { text-align: left; padding: 0.65rem 0.6rem; vertical-align: top; }
thead th {
    color: var(--muted-foreground);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background-color 120ms ease; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--muted); }
.table-wrap { overflow-x: auto; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.6rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    background: var(--primary-soft);
    color: var(--primary-hover);
}
.badge.warn { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.badge.danger { background: var(--destructive-soft); color: var(--destructive-hover); }

/* ---------- Notices / alerts ---------- */

.notice {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: #78450b;
    padding: 1.1rem 1.25rem;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: 0.92rem;
}

.error-text { color: var(--destructive); font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.2em; }
.success-text { color: var(--primary-hover); font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.2em; }
.muted { color: var(--muted-foreground); }

/* ---------- Auth page ---------- */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--background);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { text-align: center; color: var(--foreground); margin-bottom: 1.5rem; }

.tabs {
    display: flex;
    gap: 0.2rem;
    margin-bottom: 1.25rem;
    background: var(--muted);
    border-radius: var(--radius-md);
    padding: 0.25rem;
}
.tabs button {
    flex: 1;
    height: 2rem;
    background: transparent;
    color: var(--muted-foreground);
    border: none;
    border-radius: var(--radius-sm);
    box-shadow: none;
    padding: 0.4rem;
    font-weight: 500;
}
.tabs button.active { color: var(--foreground); background: var(--card); box-shadow: var(--shadow-sm); }
.tabs button:hover:not(.active) { background: transparent; color: var(--foreground); }

@media (max-width: 600px) {
    .app-header { flex-direction: column; align-items: flex-start; }
    main { padding: 1rem 0.9rem 2.5rem; }
    .card { padding: 1.1rem; }
}
