/* ImportServices dashboard — shadcn/ui design system ported to plain CSS.
   Tokens taken from shadcn's default (zinc) theme globals.css. */

:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --success: 142 71% 45%;
    --success-foreground: 0 0% 98%;
    --warning: 38 92% 50%;
    --warning-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 5.9% 10%;
    --radius: 0.5rem;

    --sidebar: 0 0% 98%;
    --sidebar-foreground: 240 5.3% 26.1%;
    --sidebar-border: 240 5.9% 90%;
    --sidebar-accent: 240 4.8% 95.9%;
    --sidebar-accent-foreground: 240 5.9% 10%;
}

.dark {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 5.9%;
    --card-foreground: 0 0% 98%;
    --popover: 240 10% 3.9%;
    --popover-foreground: 0 0% 98%;
    --primary: 0 0% 98%;
    --primary-foreground: 240 5.9% 10%;
    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 50.6%;
    --destructive-foreground: 0 0% 98%;
    --success: 142 61% 45%;
    --success-foreground: 0 0% 98%;
    --warning: 38 92% 50%;
    --warning-foreground: 240 5.9% 10%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 240 4.9% 83.9%;

    --sidebar: 240 10% 5.9%;
    --sidebar-foreground: 240 4.8% 95.9%;
    --sidebar-border: 240 3.7% 15.9%;
    --sidebar-accent: 240 3.7% 15.9%;
    --sidebar-accent-foreground: 0 0% 98%;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; margin: 0; }

.muted { color: hsl(var(--muted-foreground)); }
.text-sm { font-size: 0.8125rem; }
.text-destructive { color: hsl(var(--destructive)); }
.text-success { color: hsl(var(--success)); }

/* ---- App shell: sidebar + topbar ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: hsl(var(--sidebar));
    border-right: 1px solid hsl(var(--sidebar-border));
    color: hsl(var(--sidebar-foreground));
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px;
    font-weight: 600;
    font-size: 0.95rem;
    color: hsl(var(--foreground));
    border-bottom: 1px solid hsl(var(--sidebar-border));
}
.sidebar-brand .logo {
    display: grid; place-items: center;
    width: 30px; height: 30px;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-radius: calc(var(--radius) - 2px);
}

.sidebar-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-section { padding: 14px 10px 4px; font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: hsl(var(--muted-foreground)); }

.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: calc(var(--radius) - 2px);
    color: hsl(var(--sidebar-foreground));
    font-weight: 500;
    transition: background-color .12s ease, color .12s ease;
}
.sidebar-link:hover { background: hsl(var(--sidebar-accent)); color: hsl(var(--sidebar-accent-foreground)); }
.sidebar-link.active { background: hsl(var(--sidebar-accent)); color: hsl(var(--sidebar-accent-foreground)); }
.sidebar-link svg { width: 16px; height: 16px; opacity: .85; }

.content-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px;
    height: 56px;
    padding: 0 24px;
    background: hsl(var(--background) / 0.8);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid hsl(var(--border));
}
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); display: flex; align-items: center; gap: 10px; }

.main { padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }

.sidebar-toggle { display: none; }

/* ---- Breadcrumb ---- */
.breadcrumb { display: flex; align-items: center; gap: 6px; color: hsl(var(--muted-foreground)); font-size: 0.8125rem; margin-bottom: 14px; }
.breadcrumb a:hover { color: hsl(var(--foreground)); }
.breadcrumb .sep { opacity: .5; }

.page-header { margin-bottom: 20px; }
.page-header h1 { margin-bottom: 4px; }

/* ---- Card ---- */
.card {
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 1px 2px 0 hsl(240 5% 10% / 0.04);
}
.card + .card { margin-top: 16px; }
.card-header { padding: 18px 20px; border-bottom: 1px solid hsl(var(--border)); }
.card-header.no-border { border-bottom: none; padding-bottom: 0; }
.card-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.card-description { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.card-content { padding: 20px; }
.card-content.flush { padding: 0; }

/* ---- Stat grid ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; }
.stat .label { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-bottom: 4px; }
.stat .value { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.02em; }

/* ---- Button ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 36px; padding: 0 16px;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.8125rem; font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .12s ease, border-color .12s ease, opacity .12s ease;
    user-select: none;
}
.btn:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 15px; height: 15px; }

.btn-default { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-default:hover { background: hsl(var(--primary) / 0.9); }
.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover { background: hsl(var(--secondary) / 0.8); }
.btn-outline { background: hsl(var(--background)); border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.btn-outline:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-ghost { background: transparent; color: hsl(var(--foreground)); }
.btn-ghost:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-destructive:hover { background: hsl(var(--destructive) / 0.9); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 0.78rem; }
.btn-icon { height: 36px; width: 36px; padding: 0; }
.btn-block { width: 100%; }

/* spinning icon for busy state */
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Badge ---- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem; font-weight: 500;
    border: 1px solid transparent;
    line-height: 1.4;
}
.badge-default { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-outline { border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.badge-destructive { background: hsl(var(--destructive) / 0.12); color: hsl(var(--destructive)); }
.badge-success { background: hsl(var(--success) / 0.14); color: hsl(var(--success)); }
.badge-warning { background: hsl(var(--warning) / 0.16); color: hsl(38 92% 38%); }
.dark .badge-warning { color: hsl(var(--warning)); }

/* ---- Input ---- */
.input {
    display: block; width: 100%;
    height: 40px; padding: 0 12px;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--input));
    border-radius: calc(var(--radius) - 2px);
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.input::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus-visible { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2); }
.label { display: block; font-size: 0.8125rem; font-weight: 500; margin-bottom: 6px; }

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table thead th {
    text-align: left; padding: 12px 16px;
    color: hsl(var(--muted-foreground));
    font-weight: 500; font-size: 0.8125rem;
    border-bottom: 1px solid hsl(var(--border));
}
.table tbody td { padding: 12px 16px; border-bottom: 1px solid hsl(var(--border)); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color .1s ease; }
.table tbody tr:hover { background: hsl(var(--muted) / 0.5); }
.table a.link { color: hsl(var(--foreground)); font-weight: 500; }
.table a.link:hover { text-decoration: underline; }

/* search bar */
.search-bar { position: relative; max-width: 360px; margin-bottom: 16px; }
.search-bar .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: hsl(var(--muted-foreground)); display: inline-flex; pointer-events: none; }
.search-bar .search-icon svg { width: 16px; height: 16px; }
.search-input { padding-left: 34px; height: 38px; }
.search-input::-webkit-search-cancel-button { cursor: pointer; }

.row-between { display: flex; align-items: center; justify-content: space-between; }
.row { display: flex; align-items: center; gap: 8px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* source row in location detail */
.source-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid hsl(var(--border)); }
.source-row:last-child { border-bottom: none; }
.source-row .source-name { min-width: 150px; font-weight: 500; display: flex; align-items: center; gap: 8px; }

/* alert (sync result message) */
.alert { border-radius: calc(var(--radius) - 2px); padding: 12px 14px; font-size: 0.8125rem; border: 1px solid hsl(var(--border)); margin-bottom: 16px; }
.alert-success { border-color: hsl(var(--success) / 0.4); background: hsl(var(--success) / 0.08); color: hsl(var(--success)); }
.alert-error { border-color: hsl(var(--destructive) / 0.4); background: hsl(var(--destructive) / 0.08); color: hsl(var(--destructive)); }

/* ---- Login ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .card-content > * + * { margin-top: 14px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card form button { margin-top: 4px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 18px; font-weight: 600; }
.auth-brand .logo { display: grid; place-items: center; width: 32px; height: 32px; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-radius: calc(var(--radius) - 2px); }

/* ---- Responsive ---- */
@media (max-width: 820px) {
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 40;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 10px 30px hsl(240 5% 10% / 0.2);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; }
    .main { padding: 16px; }
}
